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