Last active
December 27, 2015 18:39
-
-
Save jcpowermac/7371888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#http://docs.openstack.org/network-admin/admin/content/figures/2/figures/under-the-hood-scenario-2-ovs-compute.png | |
#http://www.markhneedham.com/blog/2013/06/26/unixawk-extracting-substring-using-a-regular-expression-with-capture-groups/ | |
ACTIVE_INSTANCE_IDS=`nova list --all-tenants | grep ACTIVE | awk '{print $2}'` | |
length=115 | |
printf -v line '%*s' "$length" | |
echo ${line// /-} | |
printf "|%30s|%15s|%15s|%15s|%15s|%9s|%s|%s\n" "instance" "tap" "linuxbridge" "veth_pair1" "veth_pair2" "ovsbridge" "tag" "vlan" | |
echo ${line// /-} | |
for INSTANCE in ${ACTIVE_INSTANCE_IDS} | |
do | |
INSTANCE_NAME=`nova list --all-tenants | grep "${INSTANCE}" | awk '{print $4}'` | |
LINUX_BRIDGE=`virsh domiflist ${INSTANCE} | grep -i '[0-9A-F]\{2\}\(:[0-9A-F]\{2\}\)\{5\}' | awk '{print $3}'` | |
TAP=`virsh domiflist ${INSTANCE} | grep -i '[0-9A-F]\{2\}\(:[0-9A-F]\{2\}\)\{5\}' | awk '{print $1}'` | |
VETH_PAIR1=`brctl show ${LINUX_BRIDGE} | grep -i qvb | awk '{print $4}'` | |
PEER_IFINDEX=`ethtool -S ${VETH_PAIR1} | grep -i peer_ifindex | awk '{print $2}'` | |
VETH_PAIR2=`ip link | grep "^${PEER_IFINDEX}:" | awk '{print $2}' | sed "s/://g"` | |
OVS_BRIDGE=`ovs-vsctl port-to-br ${VETH_PAIR2}` | |
TAG=`ovs-vsctl list port ${VETH_PAIR2} | grep -i tag | awk '{print $3}'` | |
VLAN=`ovs-ofctl dump-flows br-int | grep "mod_vlan_vid:${TAG}" | gawk '{ match($0, /dl_vlan=([0-9]+)/, arr); if(arr[1] != "") print arr[1] }'` | |
printf "|%30s|%15s|%15s|%15s|%15s|%9s|%d|%d\n" ${INSTANCE_NAME} ${TAP} ${LINUX_BRIDGE} ${VETH_PAIR1} ${VETH_PAIR2} ${OVS_BRIDGE} ${TAG} ${VLAN} | |
echo ${line// /-} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment