blob: 8c3ea901b43dc728ffd5ce1f52c1d237d4499aca [file] [log] [blame]
Alexander Gordeev06fb29c2014-01-31 18:02:07 +04001#!/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
8set -exu
9
10# Keep track of the devstack directory
11TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
12BRIDGE_SUFFIX=${1:-''}
13BRIDGE_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
22virsh net-define <(sed s/brbm/$BRIDGE_NAME/ $TOP_DIR/templates/brbm.xml)
23virsh net-autostart ${BRIDGE_NAME}
24virsh net-start ${BRIDGE_NAME}