diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/blueprints/tosca-vnfd-hello-ves/monitor.py | 41 | ||||
-rwxr-xr-x | tests/blueprints/tosca-vnfd-hello-ves/start.sh | 82 | ||||
-rw-r--r-- | tests/vHello_VES.sh | 16 |
3 files changed, 78 insertions, 61 deletions
diff --git a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py index 5cc9a09..a9e1b65 100644 --- a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py +++ b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py @@ -37,9 +37,8 @@ import select report_time = '' requestRate = '' monitor_mode = "f" -summary = ['***** Summary of key stats *****','','',''] -status = ['','unknown','unknown','unknown'] -vdu = 0 +summary = ['***** Summary of key stats *****','','','',''] +status = ['','unknown','unknown','unknown','unknown'] base_url = '' template_404 = b'''POST {0}''' columns = 0 @@ -53,10 +52,6 @@ class NoLoggingWSGIRequestHandler(WSGIRequestHandler): def log_message(self, format, *args): pass -def print_there(x, y, text): - sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text)) - sys.stdout.flush() - base_url = '' template_404 = b'''POST {0}''' @@ -96,6 +91,7 @@ class PathDispatcher: def process_event(e): global status global summary + vdu = 0 epoch = e.event.commonEventHeader.lastEpochMicrosec @@ -106,29 +102,26 @@ def process_event(e): if 'VDU1' in host or 'vdu1' in host: vdu = 1 if 'VDU2' in host or 'vdu2' in host: vdu = 2 if 'VDU3' in host or 'vdu3' in host: vdu = 3 - + domain = e.event.commonEventHeader.domain - if e.event.commonEventHeader.functionalRole == 'vHello_VES agent': - if domain == 'measurementsForVfScaling': + if domain == 'measurementsForVfScaling': + if vdu >= 1: aggregateCpuUsage = e.event.measurementsForVfScaling.aggregateCpuUsage requestRate = e.event.measurementsForVfScaling.requestRate - summary[vdu] = "VDU" + str(vdu) + " state=" + status[vdu] + ", tps=" + str(requestRate) + ", cpu=" + str(aggregateCpuUsage) - if monitor_mode == "c": print '{0} *** VDU{1} state={2}, tps={3}'.format( - report_time, vdu, status[vdu], str(requestRate)) + summary[vdu] = host + ": state=" + status[vdu] + ", tps=" + str(requestRate) + ", cpu=" + str(aggregateCpuUsage) + else: + aggregateCpuUsage = e.event.measurementsForVfScalingFields.aggregateCpuUsage + summary[4] = host + ": cpu=" + str(aggregateCpuUsage) + + for s in summary: + print '{0}'.format(s) - if domain == 'fault': - alarmCondition = e.event.faultFields.alarmCondition - specificProblem = e.event.faultFields.specificProblem + if domain == 'fault': + alarmCondition = e.event.faultFields.alarmCondition + specificProblem = e.event.faultFields.specificProblem # status[vdu] = e.event.faultFields.vfStatus - status[vdu] = e.event.faultFields.specificProblem - if monitor_mode == "c": print '{0} *** VDU{1} state: {2}'.format( - report_time, vdu, status[vdu]) - -# print_there only works if SSH'd to the VM manually - need to investigate -# print_there(1,columns-56,summary) - for s in summary: - print '{0}'.format(s) + status[vdu] = e.event.faultFields.specificProblem #-------------------------------------------------------------------------- # Main monitoring and logging procedure diff --git a/tests/blueprints/tosca-vnfd-hello-ves/start.sh b/tests/blueprints/tosca-vnfd-hello-ves/start.sh index 23f6080..4f53a6a 100755 --- a/tests/blueprints/tosca-vnfd-hello-ves/start.sh +++ b/tests/blueprints/tosca-vnfd-hello-ves/start.sh @@ -21,16 +21,64 @@ # How to use: # Intended to be invoked from vHello_VES.sh # $ bash start.sh type params -# type: type of VNF component [webserver|lb|monitor] +# type: type of VNF component [webserver|lb|monitor|collectd] # webserver params: ID CollectorIP username password # lb params: ID CollectorIP username password app1_ip app2_ip # collector params: ID CollectorIP username password +# collector params: ID CollectorIP username password # ID: VM ID # CollectorIP: IP address of the collector # username: Username for Collector RESTful API authentication # password: Password for Collector RESTful API authentication # app1_ip app2_ip: address of the web servers +setup_collectd () { + echo "$0: Install prerequisites" + sudo apt-get update + echo "$0: Install collectd plugin" + cd ~ + git clone https://github.com/maryamtahhan/OpenStackBarcelonaDemo.git + + sudo apt-get install -y collectd + sudo sed -i -- "s/FQDNLookup true/FQDNLookup false/" /etc/collectd/collectd.conf + sudo sed -i -- "s/#LoadPlugin cpu/LoadPlugin cpu/" /etc/collectd/collectd.conf + sudo sed -i -- "s/#LoadPlugin disk/LoadPlugin disk/" /etc/collectd/collectd.conf + sudo sed -i -- "s/#LoadPlugin interface/LoadPlugin interface/" /etc/collectd/collectd.conf + sudo sed -i -- "s/#LoadPlugin memory/LoadPlugin memory/" /etc/collectd/collectd.conf + cat <<EOF | sudo tee -a /etc/collectd/collectd.conf +<LoadPlugin python> + Globals true +</LoadPlugin> +<Plugin python> + ModulePath "/home/ubuntu/OpenStackBarcelonaDemo/ves_plugin/" + LogTraces true + Interactive false + Import "ves_plugin" +<Module ves_plugin> + Domain "$collector_ip" + Port 30000 + Path "" + Topic "" + UseHttps false + Username "hello" + Password "world" + FunctionalRole "Collectd VES Agent" +</Module> +</Plugin> +LoadPlugin virt +<Plugin virt> + Connection "qemu:///system" + RefreshInterval 60 + HostnameFormat uuid +</Plugin> +<Plugin cpu> + ReportByCpu false + ValuesPercentage true +</Plugin> +EOF + sudo service collectd restart +} + setup_agent () { echo "$0: Install prerequisites" sudo apt-get install -y gcc @@ -59,38 +107,6 @@ setup_agent () { echo "$0: Start evel_demo agent" nohup ../output/x86_64/evel_demo --id $vm_id --fqdn $collector_ip --port 30000 --username $username --password $password > /dev/null 2>&1 & - - echo "$0: Install collectd plugin" - cd ~ - git clone https://github.com/maryamtahhan/OpenStackBarcelonaDemo.git - cd OpenStackBarcelonaDemo/ves_plugin - host=$(hostname) - sed -i -- "s/23380d70-2c71-4e35-99e2-f43f97e4ec65/$vm_id/g" ves_plugin.py - sed -i -- "s/cscf0001vm001abc001/$host/g" ves_plugin.py - sed -i -- "s/cscf0001vm001oam001/$host/g" ves_plugin.py - sed -i -- "s/SGW/$type/" ves_plugin.py - sed -i -- "s/reporting_entity_id = \"\"/reporting_entity_id = \"$vm_id\"/g" ves_plugin.py - sed -i -- "s/reporting_entity_name = \"cscf0001vm001oam001\"/reporting_entity_name = \"$host\"/g" ves_plugin.py - sed -i -- "s/self.__username = ''/self.__username = 'hello'/g" ves_plugin.py - sed -i -- "s/self.__password = ''/self.__password = 'world'/g" ves_plugin.py - sed -i -- "s/self.__domain = '127.0.0.1'/self.__domain = '$collector_ip'/g" ves_plugin.py - sed -i -- "s/measurementForVfScaling/measurementsForVfScaling/g" ves_plugin.py - - sudo apt-get install -y collectd - sudo sed -i -- "s/FQDNLookup true/FQDNLookup false/" /etc/collectd/collectd.conf - cat <<EOF | sudo tee -a /etc/collectd/collectd.conf -<LoadPlugin python> - Globals true -</LoadPlugin> - -<Plugin python> - ModulePath "/home/ubuntu/OpenStackBarcelonaDemo/ves_plugin/" - LogTraces true - Interactive false - Import "ves_plugin" -</Plugin> -EOF - sudo service collectd restart } setup_webserver () { diff --git a/tests/vHello_VES.sh b/tests/vHello_VES.sh index ea05d7f..9ac4aa2 100644 --- a/tests/vHello_VES.sh +++ b/tests/vHello_VES.sh @@ -223,6 +223,14 @@ EOF vdu_url[3]="http://${vdu_ip[3]}" vdu_url[4]="http://${vdu_ip[4]}:30000/eventListener/v1" + echo "$0: $(date) start collectd agent on bare metal hypervisor hosts" + hosts=($(openstack hypervisor list | grep -v Hostname | grep -v "+" | awk '{print $4}')) + for host in ${hosts[@]}; do + ip=$(openstack hypervisor show $host | grep host_ip | awk '{print $4}') + scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/tacker/blueprints/tosca-vnfd-hello-ves/start.sh ubuntu@$ip:/home/ubuntu/start.sh + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu:ubuntu@$ip "nohup bash /home/ubuntu/start.sh collectd $ip ${vdu_ip[4]} hello world &" + done + echo "$0: $(date) wait 30 seconds for server SSH to be available" sleep 30 @@ -233,18 +241,18 @@ EOF done echo "$0: $(date) start vHello webserver in VDU1 at ${vdu_ip[1]}" - ssh -i /tmp/tacker/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[1]} "bash /home/ubuntu/start.sh webserver ${vdu_id[1]} ${vdu_ip[4]} hello world; exit" + ssh -i /tmp/tacker/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[1]} "nohup bash /home/ubuntu/start.sh webserver ${vdu_id[1]} ${vdu_ip[4]} hello world &" echo "$0: $(date) start vHello webserver in VDU2 at ${vdu_ip[2]}" - ssh -i /tmp/tacker/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[2]} "bash /home/ubuntu/start.sh webserver ${vdu_id[2]} ${vdu_ip[4]} hello world; exit" + ssh -i /tmp/tacker/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[2]} "nohup bash /home/ubuntu/start.sh webserver ${vdu_id[2]} ${vdu_ip[4]} hello world &" echo "$0: $(date) start LB in VDU3 at ${vdu_ip[3]}" - ssh -i /tmp/tacker/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[3]} "bash /home/ubuntu/start.sh lb ${vdu_id[3]} ${vdu_ip[4]} hello world; exit" + ssh -i /tmp/tacker/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[3]} "nohup bash /home/ubuntu/start.sh lb ${vdu_id[3]} ${vdu_ip[4]} hello world ${vdu_ip[1]} ${vdu_ip[2]} &" echo "$0: $(date) start Monitor in VDU4 at ${vdu_ip[4]}" # Replacing the default collector with monitor.py which has processing logic as well scp -i /tmp/tacker/vHello.pem -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/tacker/blueprints/tosca-vnfd-hello-ves/monitor.py ubuntu@${vdu_ip[4]}:/home/ubuntu/monitor.py - ssh -i /tmp/tacker/vHello.pem -t -t -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[4]} "bash /home/ubuntu/start.sh monitor ${vdu_id[4]} ${vdu_ip[4]} hello world; exit" + ssh -i /tmp/tacker/vHello.pem -t -t -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[4]} "bash /home/ubuntu/start.sh monitor ${vdu_id[4]} ${vdu_ip[4]} hello world" # echo "$0: $(date) verify vHello server is running at http://${vdu_ip[3]}" # apt-get install -y curl |