Skip to content

Instantly share code, notes, and snippets.

@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 / ifmap-server-error-handling
Created September 15, 2016 18:14
ifmap-server-error-handling
1. timeout when publishing to ifmap-server (mapclient.call())
when timeout happens keep retrying
2. ifmap-server code needs to inspect healthcheck object publish and if it misses n of them, exit() OR
config-nodemgr keeps reading healthcheck object from ifmap-server and if it can't read in n secs or value is stale, kill ifmap-server
3. control-node keeps reading healthcheck object from ifmap and it sees stale, move to a new ifmap-server
4. ifmap-publish-greenlet enqueue finds q-full, no change from current
@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 / contrail-db-wipe
Last active November 18, 2016 09:57
Contrail DB wipe.
[Cleanup-Steps]
0. Deleted all service-instances, VMs, networks.
1. service supervisor-webui stop on all contrail controllers
2. service supervisor-analytics stop on all contrail controllers
3. service supervisor-config stop on all contrail controllers
4. service supervisor-control stop on all contrail controllers
5. service supervisor-database stop on all contrail controllers
6. service zookeeper stop on all contrail controllers
7. mv /var/lib/cassandra /var/lib/cassandra.old
8. mv /var/lib/zookeeper/version-2 /var/lib/zookeeper/version-2.old
@ajayhn
ajayhn / create-net-audit-log
Last active October 11, 2016 20:21
create-net-audit-log
root@a5s8:~# neutron net-create test-net-1
Created a new network:
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| contrail:fq_name | default-domain |
| | admin |
| | test-net-1 |
| contrail:instance_count | 0 |
@ajayhn
ajayhn / gist:ab379ae36a0e07d101e4861587541828
Created September 9, 2016 06:22
satisfy any import from vnc_api.types.
in vnc_api/__init__.py
```
import sys
import imp
class MyImportFinder(object):
def find_module(self, fullname, path=None):
print fullname
@ajayhn
ajayhn / setup-aptly.sh
Created August 25, 2016 01:11
setup-aptly-on-ubuntu
#!/bin/bash
sudo echo "deb http://repo.aptly.info/ squeeze main" > /etc/apt/sources.list.d/aptly.list
wget -qO - https://www.aptly.info/pubkey.txt | sudo apt-key add -
sudo apt-get update
sudo apt-get install aptly
@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 / db_in_json.py
Last active August 10, 2016 06:38
db_in_json.py
# e.g pycassaShell -H <db-node-ip> -f db_in_json.py | sed -e '1,/contents:/d' | python -m json.tool
from pprint import pprint
import json
import kazoo.client
db_contents = {'cassandra': {},
'zookeeper': {}}
cassandra_contents = db_contents['cassandra']
for ks_name in ['config_db_uuid',
@ajayhn
ajayhn / analytics-on-separate-db-node.md
Created June 22, 2016 20:42
analytics-on-separate-db-node
  1. Install 3 new servers with base OS same s4,5,6
  2. Install analytics and database packages on the 3 new servers s4,5,6
    • which packages kafka too?
  3. service supervisor-analytics stop; service cassandra stop; kafka?
  4. Determine whether old analytics DB is to be migrated or built anew 4.1 To be anew 4.1.1 service supervisor-analytics stop on s1,2,3 4.1.2 provision cassandra.yaml and cassandra-env.sh to have a cluster of s4,5,6 4.1.3 provision analytics processes - discovery-ip should be VIP. 4.1.4 service supervisor-analytics start; service cassandra start; kafka?