blob: 2b922bd3b29f55f1e74895b61d816068423e46d4 [file] [log] [blame]
#!/bin/bash
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function mac_to_iface {
MAC=$1
ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
}
iptables -L > /dev/null
ip6tables -L > /dev/null
STAG={{ s_tags[0] }}
CTAG={{ c_tags[0] }}
VEG=veg-$STAG-$CTAG
docker inspect $VEG > /dev/null 2>&1
if [ "$?" == 1 ]
then
docker pull {{ docker_remote_image_name }}
docker run -d --name=$VEG --privileged=true --net=none \
-v /var/container_volumes/$VEG/mount:/mount:ro \
-v /var/container_volumes/$VEG/etc/dnsmasq.d:/etc/dnsmasq.d:ro \
-v /var/container_volumes/$VEG/etc/service/message:/etc/service/message \
-v /var/container_volumes/$VEG/usr/local/sbin:/usr/local/sbin:ro \
{{ docker_local_image_name }}
else
docker start $VEG
fi
# Set up networking via pipework
WAN_IFACE=br-wan
docker 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 }}
LAN_IFACE=eth0
ifconfig $LAN_IFACE >> /dev/null
if [ "$?" == 0 ]
then
ifconfig $LAN_IFACE.$STAG >> /dev/null || ip link add link $LAN_IFACE name $LAN_IFACE.$STAG type vlan id $STAG
ifconfig $LAN_IFACE.$STAG up
docker exec $VEG ifconfig eth1 >> /dev/null || pipework $LAN_IFACE.$STAG -i eth1 $VEG 192.168.0.1/24 @$CTAG
fi
#HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
#docker exec $VEG ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VEG {{ hpc_client_ip }}/24
# Make sure VM's eth0 (hpc_client) has no IP address
#ifconfig $HPC_IFACE 0.0.0.0
# Attach to container
docker start -a $VEG