Skip to content

Instantly share code, notes, and snippets.

@ajayhn
Last active November 21, 2016 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajayhn/dbb3475d3584be381285 to your computer and use it in GitHub Desktop.
Save ajayhn/dbb3475d3584be381285 to your computer and use it in GitHub Desktop.
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
=== Monitor mysql for when parallel boots of VM has been created/deleted ===
watch -n1 -d "mysql -e \"select count(*) from nova.instances where display_name like '%xscalevm82%' and vm_state='active';\""
=== Delete ports named scaleport8200-8700 ===
for x in $(curl http://localhost:8082/virtual-machine-interfaces | python -m json.tool | grep -A6 fq_name | grep -A3 "scaleport8[2-7][0-9][0-9]" | grep uuid | awk '{ print $2 }'| sed 's/"//g'); do (neutron port-delete $x &) ; done
=== Delete active VMs named xscalevm8* ===
for x in $(mysql -e "select display_name,uuid from nova.instances where display_name like '%xscalevm8%' and vm_state='active';" | grep xscalevm8 | awk '{ print $2 }'); do (nova delete $x &); done
=== Get keystone token for use in curl ===
OS_TOKEN=$(keystone token-get | grep " id " | awk '{ print $4 }')
=== Get multisecond api response from api server ===
grep "POST /neutron" /var/log/contrail/contrail-api-0-stdout.log | awk '{ print $4 $5 $11 }' | grep -v "]0" | less
=== Get haproxy session timeouts for quantum backend on Feb 24 ===
less /var/log/haproxy.log.2.gz | awk '{ print $1 $2 $3 $9 $10 $12 }' | grep -v "\-\-$" | grep Feb24 | grep -i quantum | less
=== Read details of a collection one-by-one ===
for x in $(curl -u admin:contrail123 http://localhost:8095/virtual-machine-interfaces | python -m json.tool | grep href | awk '{ print $2 }' | sed -e 's/"//g' -e 's/,//' ); do curl -u admin:contrail123 $x; done
=== Create instance-ip with a specific ip address ref'ing a specific port ===
curl -u admin:contrail123 localhost:8095/instance-ips -H "Content-Type:application/json" -X POST -d '{"instance-ip": {"fq_name": ["r2eserve-for-fw"], "virtual_network_refs": [{"uuid": "191d562e-5a9c-44b6-9d85-7ed9a75d6fb1", "to": ["default-domain", "demo", "test-net"]}], "virtual_machine_interface_refs": [{"uuid": "6fee24fb-0979-448f-bfca-758a33c379bd", "to": ["default-domain", "demo", "6fee24fb-0979-448f-bfca-758a33c379bd"]}], "instance_ip_address": "1.1.1.11"}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment