Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | function mac_to_iface { |
| 4 | MAC=$1 |
| 5 | ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.' |
| 6 | } |
| 7 | |
| 8 | function 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 | |
| 13 | iptables -L > /dev/null |
| 14 | ip6tables -L > /dev/null |
| 15 | |
| 16 | MONITORING_CHANNEL=monitoring-channel-{{ unique_id }} |
| 17 | HEADNODEFLATLANIP={{ headnode_flat_lan_ip }} |
| 18 | HOST_FORWARDING_PORT_FOR_CEILOMETER={{ ceilometer_host_port }} |
| 19 | |
| 20 | docker inspect $MONITORING_CHANNEL > /dev/null 2>&1 |
| 21 | if [ "$?" == 1 ] |
| 22 | then |
| 23 | #sudo docker build -t monitoring-channel -f Dockerfile.monitoring_channel . |
| 24 | #sudo docker pull srikanthvavila/monitoring-channel |
| 25 | if [ -z "$HEADNODEFLATLANIP" ] || [ "$HEADNODEFLATLANIP" == "None" ] |
| 26 | then |
| 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 |
| 29 | else |
| 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 |
| 32 | fi |
| 33 | else |
| 34 | docker start $MONITORING_CHANNEL |
| 35 | fi |
| 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' |
| 46 | docker cp /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config $MONITORING_CHANNEL:/usr/local/share/ceilometer_proxy_config |
| 47 | |
| 48 | # Attach to container |
| 49 | docker start -a $MONITORING_CHANNEL |