Integration testing preparation for Ironic
Add ability to create/register qemu vms for Ironic testing purposes
Implements bp:deprecate-baremetal-driver
Change-Id: If452438fcc0ff562531b33a36cd189b235654b48
diff --git a/tools/ironic/scripts/setup-network b/tools/ironic/scripts/setup-network
new file mode 100755
index 0000000..8c3ea90
--- /dev/null
+++ b/tools/ironic/scripts/setup-network
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+# **setup-network**
+
+# Setups openvswitch libvirt network suitable for
+# running baremetal poseur nodes for ironic testing purposes
+
+set -exu
+
+# Keep track of the devstack directory
+TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
+BRIDGE_SUFFIX=${1:-''}
+BRIDGE_NAME=brbm$BRIDGE_SUFFIX
+
+# Only add bridge if missing
+(sudo ovs-vsctl list-br | grep ${BRIDGE_NAME}$) || sudo ovs-vsctl add-br ${BRIDGE_NAME}
+
+# remove bridge before replacing it.
+(virsh net-list | grep "${BRIDGE_NAME} ") && virsh net-destroy ${BRIDGE_NAME}
+(virsh net-list --inactive | grep "${BRIDGE_NAME} ") && virsh net-undefine ${BRIDGE_NAME}
+
+virsh net-define <(sed s/brbm/$BRIDGE_NAME/ $TOP_DIR/templates/brbm.xml)
+virsh net-autostart ${BRIDGE_NAME}
+virsh net-start ${BRIDGE_NAME}