blob: a99fa6981ba5cddbcc06dc4236711031418d5672 [file] [log] [blame]
Matteo Scandoloeb0d11c2017-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
Scott Baker31acc652016-06-23 15:47:56 -070019#!/bin/bash
20
21function mac_to_iface {
22 MAC=$1
23 ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
24}
25
26function generate_mac_from_ip {
27 IP=$1
28 printf "02:42:%02x:%02x:%02x:%02x\n" `echo $IP|awk -F '.' '{print $1, $2, $3, $4}'`
29}
30
31iptables -L > /dev/null
32ip6tables -L > /dev/null
33
34MONITORING_CHANNEL=monitoring-channel-{{ unique_id }}
35HEADNODEFLATLANIP={{ headnode_flat_lan_ip }}
36HOST_FORWARDING_PORT_FOR_CEILOMETER={{ ceilometer_host_port }}
37
38docker inspect $MONITORING_CHANNEL > /dev/null 2>&1
39if [ "$?" == 1 ]
40then
41 #sudo docker build -t monitoring-channel -f Dockerfile.monitoring_channel .
42 #sudo docker pull srikanthvavila/monitoring-channel
43if [ -z "$HEADNODEFLATLANIP" ] || [ "$HEADNODEFLATLANIP" == "None" ]
44then
45# docker run -d --name=$MONITORING_CHANNEL --privileged=true -p $HOST_FORWARDING_PORT_FOR_CEILOMETER:8000 -v /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config:/usr/local/share/ceilometer_proxy_config srikanthvavila/monitoring-channel
46 docker run -d --name=$MONITORING_CHANNEL --privileged=true -p $HOST_FORWARDING_PORT_FOR_CEILOMETER:8000 srikanthvavila/monitoring-channel
47else
48# docker run -d --name=$MONITORING_CHANNEL --add-host="ctl:$HEADNODEFLATLANIP" --privileged=true -p $HOST_FORWARDING_PORT_FOR_CEILOMETER:8000 -v /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config:/usr/local/share/ceilometer_proxy_config srikanthvavila/monitoring-channel
49 docker run -d --name=$MONITORING_CHANNEL --add-host="ctl:$HEADNODEFLATLANIP" --privileged=true -p $HOST_FORWARDING_PORT_FOR_CEILOMETER:8000 srikanthvavila/monitoring-channel
50fi
51else
52 docker start $MONITORING_CHANNEL
53fi
54
55# Set up networking via pipework
56#SHARED_LAN_IFACE=$( mac_to_iface {{ shared_lan_mac }} )
57#docker exec $MONITORING_CHANNEL ifconfig eth0 >> /dev/null || pipework $SHARED_LAN_IFACE -i eth0 $MONITORING_CHANNEL 192.168.0.1/24
58
59# Make sure VM's eth0 (hpc_client) has no IP address
60#ifconfig $HPC_IFACE 0.0.0.0
61
62# Now copy ceilometer proxy configuration to container
63#cat /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config | sudo docker exec -i $MONITORING_CHANNEL bash -c 'cat > /usr/local/share/ceilometer_proxy_config'
64docker cp /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config $MONITORING_CHANNEL:/usr/local/share/ceilometer_proxy_config
65
66# Attach to container
67docker start -a $MONITORING_CHANNEL