Matteo Scandolo | eb0d11c | 2017-08-08 13:05:26 -0700 | [diff] [blame^] | 1 | |
| 2 | {# |
| 3 | Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | #} |
| 17 | |
| 18 | |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 19 | #!/bin/bash |
| 20 | |
| 21 | function mac_to_iface { |
| 22 | MAC=$1 |
| 23 | ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.' |
| 24 | } |
| 25 | |
| 26 | function 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 | |
| 31 | iptables -L > /dev/null |
| 32 | ip6tables -L > /dev/null |
| 33 | |
| 34 | MONITORING_CHANNEL=monitoring-channel-{{ unique_id }} |
| 35 | HEADNODEFLATLANIP={{ headnode_flat_lan_ip }} |
| 36 | HOST_FORWARDING_PORT_FOR_CEILOMETER={{ ceilometer_host_port }} |
| 37 | |
| 38 | docker inspect $MONITORING_CHANNEL > /dev/null 2>&1 |
| 39 | if [ "$?" == 1 ] |
| 40 | then |
| 41 | #sudo docker build -t monitoring-channel -f Dockerfile.monitoring_channel . |
| 42 | #sudo docker pull srikanthvavila/monitoring-channel |
| 43 | if [ -z "$HEADNODEFLATLANIP" ] || [ "$HEADNODEFLATLANIP" == "None" ] |
| 44 | then |
| 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 |
| 47 | else |
| 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 |
| 50 | fi |
| 51 | else |
| 52 | docker start $MONITORING_CHANNEL |
| 53 | fi |
| 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' |
| 64 | docker cp /usr/local/share/monitoring-channel-{{ unique_id }}_ceilometer_proxy_config $MONITORING_CHANNEL:/usr/local/share/ceilometer_proxy_config |
| 65 | |
| 66 | # Attach to container |
| 67 | docker start -a $MONITORING_CHANNEL |