blob: a4f50f7c60aae053132476ea9d473722645c7502 [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 {{ docker_remote_image_name }}
19 docker run -d --name=$VEG --privileged=true --net=none \
20 -v /var/container_volumes/$VEG/mount:/mount:ro \
21 -v /var/container_volumes/$VEG/etc/dnsmasq.d:/etc/dnsmasq.d:ro \
22 -v /var/container_volumes/$VEG/etc/service/message:/etc/service/message \
23 -v /var/container_volumes/$VEG/usr/local/sbin:/usr/local/sbin:ro \
24 {{ docker_local_image_name }}
25else
26 docker start $VEG
27fi
28
29# Set up networking via pipework
30WAN_IFACE=br-wan
31docker exec $VEG ifconfig eth0 >> /dev/null || pipework $WAN_IFACE -i eth0 $VEG {{ wan_container_ip }}/{{ wan_container_netbits }}@{{ wan_container_gateway_ip }} {{ wan_container_mac }}
32
33LAN_IFACE=eth0
34ifconfig $LAN_IFACE >> /dev/null
35if [ "$?" == 0 ]
36then
37 ifconfig $LAN_IFACE.$STAG >> /dev/null || ip link add link $LAN_IFACE name $LAN_IFACE.$STAG type vlan id $STAG
38 ifconfig $LAN_IFACE.$STAG up
39 docker exec $VEG ifconfig eth1 >> /dev/null || pipework $LAN_IFACE.$STAG -i eth1 $VEG 192.168.0.1/24 @$CTAG
40fi
41
42#HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
43#docker exec $VEG ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VEG {{ hpc_client_ip }}/24
44
45# Make sure VM's eth0 (hpc_client) has no IP address
46#ifconfig $HPC_IFACE 0.0.0.0
47
48# Attach to container
49docker start -a $VEG