Skip to content

Instantly share code, notes, and snippets.

@ajayhn
ajayhn / contrail-all-in-one-in-vm.md
Last active November 18, 2016 10:01
contrail-all-in-one-in-vm
Following steps are needed in a VM environment for contrail all-in-one (assuming trusty r201)
sudo apt-get –y install curl
prep right hostname without this fab get_all_time fails
echo "127.0.0.1 $(hostname)" >>  /etc/hosts
prep keys WARNING do not do this if there is already id_rsa key.
@ajayhn
ajayhn / openstack-create-qcow2-snapshot
Created March 27, 2015 02:27
openstack-create-qcow2-snapshot
In this example, an instance was launched with flavor 80G. installation didn't consume much of the disk. When snapshot was created without below steps its size was 80G (since openstack has raw in _base and snapshot creates with that raw size). By doing below (pull ing from _base to disk, qcow2 without the raw backing file reduces size of snapshot).
root@a6s15:/var/lib/nova/instances/ed719037-2e00-4c4c-90f9-924578f93b80# qemu-img info disk
image: disk
file format: qcow2
virtual size: 80G (85899345920 bytes)
disk size: 77M
cluster_size: 65536
** backing file: /var/lib/nova/instances/_base/1d043087def843d5e081c1e2c3ea6ca1e4278547 **
Format specific information:
@ajayhn
ajayhn / scale-setup-script-contrail_neutron
Created March 30, 2015 02:56
scale-setup-script-contrail_neutron
root@ci-upgrade-scale-prototype:~# vi scale-setup-script-contrail.py
#!/usr/bin/python
import os
import uuid
from vnc_api import vnc_api
lib = vnc_api.VncApi('admin', 'secret123', 'scale-project-2', '127.0.0.1', '8082', '/')
proj_obj = lib.project_read(fq_name=['default-domain', 'scale-project-2'])
@ajayhn
ajayhn / publishing-to-aptly
Last active May 18, 2016 17:18
publishing-to-aptly
# Mainline
(OPENSTACK=${OPENSTACK:-juno}; \
rm -rf latest-packages; \
mkdir latest-packages; \
BRANCH=mainline; \
LATEST_PATH=/github-build/${BRANCH}/2619/ubuntu-14-04/${OPENSTACK}/artifacts/; \
TGZ_PACKAGES='contrail-installer-package*.tgz,contrail-install-packages*.tgz,contrail-packages*.tgz,contrail-openstack-packages*.tgz'; \
scp hajay@10.84.5.31:${LATEST_PATH}/\{${TGZ_PACKAGES}\} latest-packages/; \
BUILD=$(ls latest-packages/contrail-packages*.tgz | cut -d / -f 2 | sed -r 's/contrail-packages_(.*).tgz/\1/'); \
for x in $(ls latest-packages/*.tgz); do tar xvfz $x -C latest-packages/; rm $x; done; \
@ajayhn
ajayhn / ifmap-quotes-fixup
Last active August 29, 2015 14:19
ifmap-quotes-fixup
#!/bin/bash
set -x
sed -i 's/from xml.sax.saxutils import escape\, unescape/from xml.sax.saxutils import escape as s_esc\, unescape as s_unesc/g' /usr/lib/python2.7/dist-packages/cfgm_common/imid.py
cat << EOF >> /usr/lib/python2.7/dist-packages/cfgm_common/imid.py
def escape(string):
return s_esc(string, entities={'"':'&quot;', "'": "&apos;"})
def unescape(string):
return s_unesc(string, entities={'&quot;':'"', "&apos;": "'"})
@ajayhn
ajayhn / all-in-one-openstack-trusty-mainline
Last active May 18, 2016 17:18
all-in-one-openstack-trusty-mainline
#!/bin/bash
# E.g. (OPENSTACK=juno CONTRAIL=R2.20 BUILD=102-juno bash -x all-in-one-openstack-trusty-mainline)
set -x
# Inputs from user with defaults
OPENSTACK=${OPENSTACK:-juno}
CONTRAIL=${CONTRAIL:-mainline}
BUILD=${BUILD}
VROUTER_INTF=${VROUTER_INTF:-eth0}
@ajayhn
ajayhn / cluster-join.py
Last active August 29, 2015 14:20
cluster-join
#!/usr/bin/python
#
# Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
#
"""Contrail Cluster Join Operations."""
# Example: python join.py --zk_index 2 --new_node 1.1.1.5 --roles database
# python join.py --my_zk_index 2 --my_ip 1.1.1.5
# --other_nodes_ip 1.1.1.4 --other_nodes_name c1 --other_nodes_zk_indexes 1
# python join.py --my_zk_index 3 --my_ip 1.1.1.6
cat << EOF | pycassaShell -H localhost -k config_db_uuid -f /dev/stdin > /tmp/cassandra-out-$(date +%Y%m%d-%H%M%S)
for r,c in OBJ_UUID_TABLE.get_range(column_count=10000000, include_timestamp=True):
print r,c
print
for r,c in OBJ_FQ_NAME_TABLE.get_range(column_count=10000000, include_timestamp=True):
print r,c
print
exit()
EOF
@ajayhn
ajayhn / contrail-db-row-replication-check
Last active January 20, 2016 13:14
contrail-db-row-replication-check
# REPLACE localhost with DB-IP %s/localhost/<IP>/g
#assume obj_fq_name_table keys as utf8;
#assume obj_fq_name_table comparator as utf8;
#assume obj_fq_name_table validator as utf8;
#assume obj_uuid_table keys as utf8;
#assume obj_uuid_table comparator as utf8;
#assume obj_uuid_table validator as utf8;
LOG_FILE=repl-check.out.$(date +%Y%m%d-%H%M%S)
@ajayhn
ajayhn / .screenrc
Last active February 19, 2016 01:27
screenrc
# save contents to ~/.screenrc
#apt-get install screen
#screen -S <session-name>
# will create new screen session with <session-name>
#`d
# to exit
#screen -x <session-name>
# to connect back with share mode
#`c
# to create new window