blob: 83308ed416b7503c015f702f3a7a74228bc0b264 [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
Adam Gandelmanbd93f022014-03-17 16:31:49 -070010LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"}
11
Dean Troyerdc97cb72015-03-28 08:20:50 -050012# Keep track of the DevStack directory
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040013TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
14BRIDGE_SUFFIX=${1:-''}
15BRIDGE_NAME=brbm$BRIDGE_SUFFIX
16
Adam Gandelmanbd93f022014-03-17 16:31:49 -070017export VIRSH_DEFAULT_CONNECT_URI="$LIBVIRT_CONNECT_URI"
18
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040019# Only add bridge if missing
20(sudo ovs-vsctl list-br | grep ${BRIDGE_NAME}$) || sudo ovs-vsctl add-br ${BRIDGE_NAME}
21
Dean Troyerdc97cb72015-03-28 08:20:50 -050022# Remove bridge before replacing it.
Alexander Gordeev06fb29c2014-01-31 18:02:07 +040023(virsh net-list | grep "${BRIDGE_NAME} ") && virsh net-destroy ${BRIDGE_NAME}
24(virsh net-list --inactive | grep "${BRIDGE_NAME} ") && virsh net-undefine ${BRIDGE_NAME}
25
26virsh net-define <(sed s/brbm/$BRIDGE_NAME/ $TOP_DIR/templates/brbm.xml)
27virsh net-autostart ${BRIDGE_NAME}
28virsh net-start ${BRIDGE_NAME}