From a939d3cda9fef3a935dc6176ab88241619eb344c Mon Sep 17 00:00:00 2001 From: Bryan Sullivan Date: Sat, 15 Oct 2016 08:39:52 -0700 Subject: Fix agent startup, add monitor.py and favicon JIRA: VES-1 Report intended traffic measurement at agent Change-Id: I587150f80eebfdd4b1efaafc48b78db30dd33468 Signed-off-by: Bryan Sullivan --- tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c | 3 +- tests/blueprints/tosca-vnfd-hello-ves/favicon.ico | Bin 0 -> 1150 bytes tests/blueprints/tosca-vnfd-hello-ves/logo.png | Bin 0 -> 4212 bytes tests/blueprints/tosca-vnfd-hello-ves/monitor.py | 33 ++++++++++++++++++++++ tests/blueprints/tosca-vnfd-hello-ves/start.sh | 12 ++++++-- tests/vHello_VES.sh | 4 +-- 6 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 tests/blueprints/tosca-vnfd-hello-ves/favicon.ico create mode 100644 tests/blueprints/tosca-vnfd-hello-ves/logo.png create mode 100644 tests/blueprints/tosca-vnfd-hello-ves/monitor.py diff --git a/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c b/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c index 50f45ec..39cd528 100644 --- a/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c +++ b/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c @@ -211,7 +211,7 @@ void measure_traffic() { time (&rawtime); timeinfo = localtime (&rawtime); strftime(period,7,"%H:%M:",timeinfo); - strftime(secs,2,"%S",timeinfo); + strftime(secs,3,"%S",timeinfo); sec = atoi(secs); if (sec == 0) sec = 59; sprintf(secs, "%02d", sec); @@ -228,6 +228,7 @@ void measure_traffic() { if (fgets(count, 10, fp) != NULL) { request_rate = atoi(count); + printf("Reporting request rate for second: %s as %d\n", period, request_rate); measurement = evel_new_measurement(concurrent_sessions, configured_entities, mean_request_latency, measurement_interval, memory_configured, memory_used, request_rate); diff --git a/tests/blueprints/tosca-vnfd-hello-ves/favicon.ico b/tests/blueprints/tosca-vnfd-hello-ves/favicon.ico new file mode 100644 index 0000000..cd95189 Binary files /dev/null and b/tests/blueprints/tosca-vnfd-hello-ves/favicon.ico differ diff --git a/tests/blueprints/tosca-vnfd-hello-ves/logo.png b/tests/blueprints/tosca-vnfd-hello-ves/logo.png new file mode 100644 index 0000000..a4bf310 Binary files /dev/null and b/tests/blueprints/tosca-vnfd-hello-ves/logo.png differ diff --git a/tests/blueprints/tosca-vnfd-hello-ves/monitor.py b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py new file mode 100644 index 0000000..9f3b7ff --- /dev/null +++ b/tests/blueprints/tosca-vnfd-hello-ves/monitor.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# +# Copyright 2016 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# What this is: Monitor and closed-loop policy agent as part of the OPNFV VES +# vHello_VES demo. +# +# Status: this is a work in progress, under test. + +with open('/home/ubuntu/ves.log') as f: + while True: + line = f.readline() + if line: +# print line, + if "requestRate" in line: +# print line, + rate = line[27:-2] + print 'request rate: {0}'.format(rate) +#....5....1....5....2....5....3....5 +# "requestRate": 2264, + diff --git a/tests/blueprints/tosca-vnfd-hello-ves/start.sh b/tests/blueprints/tosca-vnfd-hello-ves/start.sh index b8f6e14..1aa01e8 100755 --- a/tests/blueprints/tosca-vnfd-hello-ves/start.sh +++ b/tests/blueprints/tosca-vnfd-hello-ves/start.sh @@ -36,7 +36,13 @@ setup_agent () { cd /home/ubuntu git clone https://github.com/att/evel-library.git - echo "$0: Build agent demo" + echo "$0: Clone VES repo" + git clone https://gerrit.opnfv.org/gerrit/ves + + echo "$0: Use vHello_VES blueprint version of agent_demo.c" + cp ves/tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c evel-library/code/evel_demo/evel_demo.c + + echo "$0: Update parameters and build agent demo" sed -i -- "/api_secure,/{n;s/.*/ \"$username\",/}" evel-library/code/evel_demo/evel_demo.c sed -i -- "/\"hello\",/{n;s/.*/ \"$password\",/}" evel-library/code/evel_demo/evel_demo.c @@ -45,7 +51,7 @@ setup_agent () { make export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ubuntu/evel-library/libs/x86_64 - nohup ..output/x86_64/evel_demo --id $agent_id --fqdn $collector_ip --port 30000 --username $username --password $password & + nohup ../output/x86_64/evel_demo --id $agent_id --fqdn $collector_ip --port 30000 --username $username --password $password & # echo "$0: Start agent demo, repeat every minute" # crontab -l > /tmp/cron @@ -80,6 +86,8 @@ Hello World!
EOM +cp ~/ves/tests/blueprints/tosca-vnfd-hello-ves/favicon.ico ~/www/html/favicon.ico + echo "$0: Install docker" # Per https://docs.docker.com/engine/installation/linux/ubuntulinux/ # Per https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04 diff --git a/tests/vHello_VES.sh b/tests/vHello_VES.sh index 206eec5..95d3f4f 100644 --- a/tests/vHello_VES.sh +++ b/tests/vHello_VES.sh @@ -254,10 +254,10 @@ collector () { ssh -i /tmp/vHello.pem -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$VDU2_IP << 'EOF' sudo kill $(ps -ef | grep evel-test-collector | awk '{print $2}') cd /home/ubuntu/ -python evel-test-collector/code/collector/collector.py \ +nohup python evel-test-collector/code/collector/collector.py \ --config evel-test-collector/config/collector.conf \ --section default \ - --verbose >~/ves.log + --verbose >~/ves.log & EOF } -- cgit 1.2.3-korg