forked from metal3-io/metal3-dev-env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntu_bridge_network_configuration.sh
executable file
·67 lines (60 loc) · 2.44 KB
/
ubuntu_bridge_network_configuration.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -xe
# shellcheck disable=SC1091
source lib/logging.sh
# shellcheck disable=SC1091
source lib/common.sh
# shellcheck disable=SC1091
source lib/network.sh
if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
# Adding an IP address in the libvirt definition for this network results in
# dnsmasq being run, we don't want that as we have our own dnsmasq, so set
# the IP address here.
# Create a veth iterface peer.
sudo ip link add ironicendpoint type veth peer name ironic-peer
# Create provisioning bridge.
sudo brctl addbr provisioning
# sudo ifconfig provisioning 172.22.0.1 netmask 255.255.255.0 up
# Use ip command. ifconfig commands are deprecated now.
sudo ip link set provisioning up
if [[ "${PROVISIONING_IPV6}" == "true" ]]; then
sudo ip -6 addr add "$PROVISIONING_IP"/"$PROVISIONING_CIDR" dev ironicendpoint
else
sudo ip addr add dev ironicendpoint "$PROVISIONING_IP"/"$PROVISIONING_CIDR"
fi
sudo brctl addif provisioning ironic-peer
sudo ip link set ironicendpoint up
sudo ip link set ironic-peer up
# Need to pass the provision interface for bare metal
if [ "$PRO_IF" ]; then
sudo brctl addif provisioning "$PRO_IF"
fi
fi
if [ "$MANAGE_INT_BRIDGE" == "y" ]; then
# Create the baremetal bridge
if ! [[ $(ip a show baremetal) ]]; then
sudo brctl addbr baremetal
# sudo ifconfig baremetal 192.168.111.1 netmask 255.255.255.0 up
# Use ip command. ifconfig commands are deprecated now.
if [[ -n "${EXTERNAL_SUBNET_V4_HOST}" ]]; then
sudo ip addr add dev baremetal "${EXTERNAL_SUBNET_V4_HOST}/${EXTERNAL_SUBNET_V4_PREFIX}"
fi
if [[ -n "${EXTERNAL_SUBNET_V6_HOST}" ]]; then
sudo ip addr add dev baremetal "${EXTERNAL_SUBNET_V6_HOST}/${EXTERNAL_SUBNET_V6_PREFIX}"
fi
sudo ip link set baremetal up
fi
# Add the internal interface to it if requests, this may also be the interface providing
# external access so we need to make sure we maintain dhcp config if its available
if [ "$INT_IF" ]; then
sudo brctl addif "$INT_IF"
fi
fi
# restart the libvirt network so it applies an ip to the bridge
if [ "$MANAGE_BR_BRIDGE" == "y" ] ; then
sudo virsh net-destroy baremetal
sudo virsh net-start baremetal
if [ "$INT_IF" ]; then #Need to bring UP the NIC after destroying the libvirt network
sudo ifup "$INT_IF"
fi
fi