[lib.sh] Add veth pair handling support 57/61357/3
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Sat, 18 Aug 2018 00:10:36 +0000 (02:10 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 28 Aug 2018 23:27:28 +0000 (01:27 +0200)
Upcoming docker integration requires special care for network
interfaces Docker will hook to, so virsh networks can be mixed with
Docker networks.
We'll use veth pair(s) to hook together the Docker network(s) to their
counterpart virsh-managed Linux bridge(s).

JIRA: FUEL-383

Change-Id: I1a714dc8be73e79539d85bacac311d1ed05cc18d
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
mcp/scripts/lib.sh

index d7af97c..f5affb0 100644 (file)
@@ -376,9 +376,9 @@ function jumpserver_check_requirements {
 }
 
 function create_networks {
-  local vnode_networks=("$@")
+  local all_vnode_networks=("mcpcontrol" "$@")
   # create required networks, including constant "mcpcontrol"
-  for net in "mcpcontrol" "${vnode_networks[@]}"; do
+  for net in "${all_vnode_networks[@]}"; do
     if virsh net-info "${net}" >/dev/null 2>&1; then
       virsh net-destroy "${net}" || true
       virsh net-undefine "${net}"
@@ -391,6 +391,14 @@ function create_networks {
       virsh net-start "${net}"
     fi
   done
+  # create veth pairs for relevant networks (mcpcontrol, pxebr, mgmt)
+  for i in $(seq 0 2 4); do
+    sudo ip link del "veth_mcp$i" || true
+    sudo ip link add "veth_mcp$i" type veth peer name "veth_mcp$((i+1))"
+    sudo ip link set "veth_mcp$i" up mtu 9000
+    sudo ip link set "veth_mcp$((i+1))" up mtu 9000
+    sudo brctl addif "${all_vnode_networks[$((i/2))]}" "veth_mcp$i"
+  done
 }
 
 function create_vms {