tripleo-incubator/scripts/setup-network
Gael Chamoulaud 64b94692a5 Fix bashate errors
- Excluding awk and python scripts.
- The Bashate E012 rule ('heredoc did not end before EOF') could be simply
  ignored until the bashate bug will be fixed.

Change-Id: Id72665aba83df753364940c82db08edcb11e1217
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2015-03-13 19:11:05 +01:00

32 lines
941 B
Bash
Executable File

#!/bin/bash
set -eu
BASE=$(dirname $0)/../
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 --persistent | grep "${BRIDGE_NAME} ") && virsh net-destroy ${BRIDGE_NAME}
(virsh net-list --inactive --persistent | grep "${BRIDGE_NAME} ") && virsh net-undefine ${BRIDGE_NAME}
virsh net-define <(sed s/brbm/$BRIDGE_NAME/ $BASE/templates/brbm.xml)
virsh net-autostart ${BRIDGE_NAME}
virsh net-start ${BRIDGE_NAME}
# start default if needed and configure it to autostart
default_net=$(sudo virsh net-list --all --persistent | grep default | awk 'BEGIN{OFS=":";} {print $2,$3}')
state=${default_net%%:*}
autostart=${default_net##*:}
if [ "$state" != "active" ]; then
virsh net-start default
fi
if [ "$autostart" != "yes" ]; then
virsh net-autostart default
fi