Use Vagrantfile to build virtual site
[icn.git] / deploy / metal3-vm / ubuntu_bridge_network_configuration.sh
1 #!/usr/bin/env bash
2 set -eux -o pipefail
3
4 # shellcheck disable=SC1091
5 source lib/logging.sh
6 # shellcheck disable=SC1091
7 source lib/common.sh
8
9 if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
10      # Adding an IP address in the libvirt definition for this network results in
11      # dnsmasq being run, we don't want that as we have our own dnsmasq, so set
12      # the IP address here
13      sudo ip link add dev provisioning type bridge
14      sudo ip addr add dev provisioning 172.22.0.1/24
15      sudo ip link set provisioning up
16
17      # Need to pass the provision interface for bare metal
18      if [ "$PRO_IF" ]; then
19        sudo ip link set dev "$PRO_IF" master provisioning
20      fi
21  fi
22
23  if [ "$MANAGE_INT_BRIDGE" == "y" ]; then
24      # Create the baremetal bridge
25      if ! [[  $(ip a show baremetal) ]]; then
26        sudo ip link add dev baremetal type bridge
27        sudo ip addr add dev baremetal 192.168.111.1/24
28        sudo ip link set baremetal up
29      fi
30
31      # Add the internal interface to it if requests, this may also be the interface providing
32      # external access so we need to make sure we maintain dhcp config if its available
33      if [ "$INT_IF" ]; then
34        sudo ip link set dev "$INT_IF" master baremetal
35      fi
36  fi
37
38  # restart the libvirt network so it applies an ip to the bridge
39  if [ "$MANAGE_BR_BRIDGE" == "y" ] ; then
40      sudo virsh net-destroy baremetal
41      sudo virsh net-start baremetal
42      if [ "$INT_IF" ]; then #Need to bring UP the NIC after destroying the libvirt network
43          sudo ip link set dev "$INT_IF" up
44      fi
45  fi