blob: c4128f30f06de7b19dbd78e5e33dce939ba90003 [file] [log] [blame]
Scott Baker761e1062016-06-20 17:18:17 -07001#!/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] }}
13VCPE=vcpe-$STAG-$CTAG
14
15docker inspect $VCPE > /dev/null 2>&1
16if [ "$?" == 1 ]
17then
18 docker pull andybavier/docker-vcpe
19 docker run -d --name=$VCPE --privileged=true --net=none -v /etc/$VCPE/dnsmasq.d:/etc/dnsmasq.d andybavier/docker-vcpe
20else
21 docker start $VCPE
22fi
23
24# Set up networking via pipework
25WAN_IFACE=$( mac_to_iface {{ wan_mac }} )
26docker exec $VCPE ifconfig eth0 >> /dev/null || pipework $WAN_IFACE -i eth0 $VCPE {{ 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 $VCPE ifconfig eth1 >> /dev/null || pipework $LAN_IFACE.$STAG -i eth1 $VCPE 192.168.0.1/24 @$CTAG
38fi
39
40#HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
41#docker exec $VCPE ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VCPE {{ 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 $VCPE service dnsmasq start
48
49# Attach to container
50docker start -a $VCPE