blob: 47c0f92174397baf642e29388dc1cd6247eb974a [file] [log] [blame]
Matteo Scandolo6288d5a2017-08-08 13:05:26 -07001
2{#
3Copyright 2017-present Open Networking Foundation
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16#}
17
18
Andrea Campanellaedfdbca2017-02-01 17:33:47 -080019#!/bin/bash
20
21function mac_to_iface {
22 MAC=$1
23 ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
24}
25
26iptables -L > /dev/null
27ip6tables -L > /dev/null
28
29STAG={{ s_tags[0] }}
30CTAG={{ c_tags[0] }}
31VEG=veg-$STAG-$CTAG
32
33docker inspect $VEG > /dev/null 2>&1
34if [ "$?" == 1 ]
35then
36 docker pull {{ docker_remote_image_name }}
37 docker run -d --name=$VEG --privileged=true --net=none \
38 -v /var/container_volumes/$VEG/mount:/mount:ro \
39 -v /var/container_volumes/$VEG/etc/dnsmasq.d:/etc/dnsmasq.d:ro \
40 -v /var/container_volumes/$VEG/etc/service/message:/etc/service/message \
41 -v /var/container_volumes/$VEG/usr/local/sbin:/usr/local/sbin:ro \
42 {{ docker_local_image_name }}
43else
44 docker start $VEG
45fi
46
47# Set up networking via pipework
48WAN_IFACE=br-wan
49docker 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 }}
50
51LAN_IFACE=eth0
52ifconfig $LAN_IFACE >> /dev/null
53if [ "$?" == 0 ]
54then
55 ifconfig $LAN_IFACE.$STAG >> /dev/null || ip link add link $LAN_IFACE name $LAN_IFACE.$STAG type vlan id $STAG
56 ifconfig $LAN_IFACE.$STAG up
57 docker exec $VEG ifconfig eth1 >> /dev/null || pipework $LAN_IFACE.$STAG -i eth1 $VEG 192.168.0.1/24 @$CTAG
58fi
59
60#HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
61#docker exec $VEG ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VEG {{ hpc_client_ip }}/24
62
63# Make sure VM's eth0 (hpc_client) has no IP address
64#ifconfig $HPC_IFACE 0.0.0.0
65
66# Attach to container
67docker start -a $VEG