Skip to content

Instantly share code, notes, and snippets.

@ajayhn
ajayhn / create-nets-and-routers.sh
Last active August 29, 2015 14:13
Script to create 5000 VMs in 5000 Networks
#!/bin/bash
set -x
#mgmt_netid=$(neutron net-create mgmtnet | grep " id " | awk '{ print $4 }')
#neutron subnet-create --name mgmtsubnet $mgmt_netid 10.10.0.0/16
mgmt_netid=$(neutron net-show mgmtnet | grep " id " | awk '{ print $4 }')
for ((i=1501; i<4501; i=i+2)); do
netid1=$(neutron net-create scalenet$i | grep " id " | awk '{ print $4 }')
netid2=$(neutron net-create scalenet$(expr $i + 1) | grep " id " | awk '{ print $4 }')
@ajayhn
ajayhn / delete_nets_ports_routers
Last active August 29, 2015 14:14
delete nets/ports/routers
#!/bin/bash
set -x
nova list | grep scalevm | awk '{ print $2 }' | xargs nova delete
for p in $(neutron port-list | grep scalemgmtport | awk '{ print $2 }'); do neutron port-delete $p; done
for p in $(neutron port-list | grep scaleport | awk '{ print $2 }'); do neutron port-delete $p; done
for r in $(neutron router-list | grep scalertr | awk '{ print $2 }'); do for x in $(neutron router-port-list $r | grep subnet_id | awk '{ prin
t $9 }' | sed -e 's/"//g' -e 's/,//'); do neutron router-interface-delete $r $x; done; done
for x in $(neutron net-list | grep scalenet | awk '{ print $2 }'); do neutron net-delete $x; done
for x in $(neutron router-list | grep scalertr | awk '{ print $2 }'); do neutron router-delete $x; done
@ajayhn
ajayhn / neutron-api-calls
Last active August 12, 2016 17:23
neutron-api-calls
== net-create ==
2015-02-03 14:28:14.149 DEBUG [neutron_plugin_contrail.plugins.opencontrail.contrail_plugin] get_network_count(): {u'count': 3}
2015-02-03 14:28:14.150 INFO [neutron.quota] Loaded quota_driver: <neutron_plugin_contrail.plugins.opencontrail.quota.driver.QuotaDriver object at 0x3831e50>.
2015-02-03 14:28:14.560 DEBUG [neutron_plugin_contrail.plugins.opencontrail.contrail_plugin] create_network(): {u'status': u'ACTIVE', u'router:external': False, u'subnets': [], u'name': u'n10', u'admin_state_up': True, u'tenant_id': u'7acd1c8574a9441e9363e112b58a1f02', u'shared': False, u'contrail:instance_count': 0, u'id': u'cc70388a-515a-4c9c-aae8-5d50faf60b53', u'contrail:fq_name': [u'default-domain', u'admin', u'n10']}
== subnet-create ==
2015-02-03 14:29:51.324 DEBUG [neutron_plugin_contrail.plugins.opencontrail.contrail_plugin] get_network(): filters: {u'name': [u'n10']} data: [{u'shared': False, u'router:external': False, u'id': u'cc70388a-515a-4c9c-aae8-5d50faf60b53', u'tenant_id': u'7acd1
@ajayhn
ajayhn / simple-gw-with-internet-access
Last active January 30, 2018 22:02
Simple gateway from compute using iptables from vgw1 to vhost0 on linux host
This assumes a single net n1 with 1.1.1.0/24 and vgw1 interface. Can be extended to use a public net and vgw1 on the public net
python /opt/contrail/utils/provision_vgw_interface.py --oper create --interface vgw1 --subnets 1.1.1.0/24 --routes 0.0.0.0/0 --vrf default-domain:admin:n1:n1
If you run into error running above script, instead of `import InstanceService` and `import ttypes` use
`from contrail_vrouter_api.gen_py.instance_service import InstanceService, ttypes`
Now do `ifconfig` and verify `vgw1` is present
diff --git a/cfgm_common/vnc_kombu.py b/cfgm_common/vnc_kombu.py
index fbf637e..d8d5fd5 100644
--- a/cfgm_common/vnc_kombu.py
+++ b/cfgm_common/vnc_kombu.py
@@ -6,6 +6,7 @@ import amqp.exceptions
import kombu
import gevent
import time
+import json
@ajayhn
ajayhn / create-scale-parallel-bash
Last active August 29, 2015 14:15
Creating scaled workload in parallel using neutron API
#!/bin/bash
set -x
OS_TOKEN=$(keystone token-get | grep " id " | awk '{ print $4 }')
NEUTRON_URL=${NEUTRON_URL:-"http://10.84.25.29:9696/"}
NOVA_URL=${NOVA_URL:-"http://10.84.25.29:8774/v2/"}
TENANT_FLAG=${TENANT_FLAG:-''}
#net_id=a89ecda4-15ea-447e-a723-aa5da86a8135 #cassnet
@ajayhn
ajayhn / api-workers-diff
Last active August 29, 2015 14:15
api-workers-diff
commit 9dad980977d7e16f108235d832ee10ff27e86475
Author: Hampapur Ajay <[email protected]>
Date: Tue Feb 10 11:49:22 2015 -0800
config: Add support for contrail-api workers
Change-Id: If20f6a86d556e420eba72c8d3f593867cc0abef9
diff --git a/src/config/api-server/vnc_auth_keystone.py b/src/config/api-server/vnc_auth_keystone.py
index b4e15f9..b599634 100644
@ajayhn
ajayhn / bash-one-liners-for-openstack-opencontrail
Last active November 21, 2016 23:25
bash one-liners for openstack + opencontrail
=== Find count of number of objects in config db obj_uuid_table ===
cat << EOF | pycassaShell -H 10.84.25.206 -k config_db_uuid -f /dev/stdinprint "Number of rows in obj_uuid_table: %s" %(len(list(OBJ_UUID_TABLE.get_range(column_count=1))))
exit()
EOF
=== Find count of objects of different types in config db ===
echo "for r,c in OBJ_FQ_NAME_TABLE.get_range(): print r; print OBJ_FQ_NAME_TABLE.get_count(r)" | pycassaShell -H 10.84.11.2 -k config_db_uuid -f /dev/stdin
=== Execute a command for certain duration only ===
grep -e api -e schema -e snmp <(timeout 20s tcpdump -ni any port 9100 -A -s 1500 | grep "X-Contrail-Useragent") | sort | uniq -c
@ajayhn
ajayhn / centos7-provisioning-for-non-openstack
Created March 13, 2015 18:54
centos7-provisioning-for-non-openstack
[centos@ip-172-31-34-194 ~]$ cat controller-provisioning
sed -i 's/Xss180k/Xss280k/' /etc/cassandra/conf/cassandra-env.sh
echo "api-server:api-server" >> /etc/ifmap-server/basicauthusers.properties
echo "schema-transformer:schema-transformer" >> /etc/ifmap-server/basicauthusers.properties
echo "svc-monitor:svc-monitor" >> /etc/ifmap-server/basicauthusers.properties
echo "control-user:control-user-passwd" >> /etc/ifmap-server/basicauthusers.properties
sed 's/911%(process_num)01d/5998/' /etc/contrail/supervisord_config_files/contrail-discovery.ini
sed -i 's/91%(process_num)02d/8082/' /etc/contrail/supervisord_config_files/contrail-api.ini
@ajayhn
ajayhn / setup-keystone-using-apache-modwsgi
Created March 18, 2015 23:29
setup-keystone-using-apache-modwsgi
sudo service keystone stop
sudo mkdir -p /var/www/cgi-bin/keystone/
( cat | sudo tee /var/www/cgi-bin/keystone/admin /var/www/cgi-bin/keystone/main ) <<EOF
import logging
import os
from paste import deploy
from keystone.openstack.common import gettextutils