blob: 5f21abfd9958b1d9e804151d29d46967539306e0 [file] [log] [blame]
Andrea Campanellaedfdbca2017-02-01 17:33:47 -08001#!/bin/bash
2
3function mac_to_iface {
4 MAC=$1
5 ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
6}
7
8iptables -L > /dev/null
9ip6tables -L > /dev/null
10
11STAG={{ s_tags[0] }}
12CTAG={{ c_tags[0] }}
13VEG=veg-$STAG-$CTAG
14
15docker inspect $VEG > /dev/null 2>&1
16if [ "$?" == 1 ]
17then
18 docker pull andybavier/docker-veg
19 docker run -d --name=$VEG --privileged=true --net=none -v /etc/$VEG/dnsmasq.d:/etc/dnsmasq.d andybavier/docker-veg
20else
21 docker start $VEG
22fi
23
24# Set up networking via pipework
25WAN_IFACE=$( mac_to_iface {{ wan_mac }} )
26docker exec $VEG ifconfig eth0 >> /dev/null || pipework $WAN_IFACE -i eth0 $VEG {{ wan_ip }}/24@{{ wan_next_hop }} {{ wan_container_mac }}
27
28# LAN_IFACE=$( mac_to_iface {{ lan_mac }} )
29# Need to encapsulate VLAN traffic so that Neutron doesn't eat it
30# Assumes that br-lan has been set up appropriately by a previous step
31LAN_IFACE=br-lan
32ifconfig $LAN_IFACE >> /dev/null
33if [ "$?" == 0 ]
34then
35 ifconfig $LAN_IFACE.$STAG >> /dev/null || ip link add link $LAN_IFACE name $LAN_IFACE.$STAG type vlan id $STAG
36 ifconfig $LAN_IFACE.$STAG up
37 docker exec $VEG ifconfig eth1 >> /dev/null || pipework $LAN_IFACE.$STAG -i eth1 $VEG 192.168.0.1/24 @$CTAG
38fi
39
40#HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
41#docker exec $VEG ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VEG {{ hpc_client_ip }}/24
42
43# Make sure VM's eth0 (hpc_client) has no IP address
44#ifconfig $HPC_IFACE 0.0.0.0
45
46# Now can start up dnsmasq
47docker exec $VEG service dnsmasq start
48
49# Attach to container
50docker start -a $VEG