Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # **setup-network** |
| 4 | |
| 5 | # Setups openvswitch libvirt network suitable for |
| 6 | # running baremetal poseur nodes for ironic testing purposes |
| 7 | |
| 8 | set -exu |
| 9 | |
| 10 | # Keep track of the devstack directory |
| 11 | TOP_DIR=$(cd $(dirname "$0")/.. && pwd) |
| 12 | BRIDGE_SUFFIX=${1:-''} |
| 13 | BRIDGE_NAME=brbm$BRIDGE_SUFFIX |
| 14 | |
| 15 | # Only add bridge if missing |
| 16 | (sudo ovs-vsctl list-br | grep ${BRIDGE_NAME}$) || sudo ovs-vsctl add-br ${BRIDGE_NAME} |
| 17 | |
| 18 | # remove bridge before replacing it. |
| 19 | (virsh net-list | grep "${BRIDGE_NAME} ") && virsh net-destroy ${BRIDGE_NAME} |
| 20 | (virsh net-list --inactive | grep "${BRIDGE_NAME} ") && virsh net-undefine ${BRIDGE_NAME} |
| 21 | |
| 22 | virsh net-define <(sed s/brbm/$BRIDGE_NAME/ $TOP_DIR/templates/brbm.xml) |
| 23 | virsh net-autostart ${BRIDGE_NAME} |
| 24 | virsh net-start ${BRIDGE_NAME} |