Fix agent startup, add monitor.py and favicon 79/23179/1
authorBryan Sullivan <bryan.sullivan@att.com>
Sat, 15 Oct 2016 15:39:52 +0000 (08:39 -0700)
committerBryan Sullivan <bryan.sullivan@att.com>
Sat, 15 Oct 2016 15:41:36 +0000 (08:41 -0700)
JIRA: VES-1
Report intended traffic measurement at agent

Change-Id: I587150f80eebfdd4b1efaafc48b78db30dd33468
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
tests/blueprints/tosca-vnfd-hello-ves/evel_demo.c
tests/blueprints/tosca-vnfd-hello-ves/favicon.ico [new file with mode: 0644]
tests/blueprints/tosca-vnfd-hello-ves/logo.png [new file with mode: 0644]
tests/blueprints/tosca-vnfd-hello-ves/monitor.py [new file with mode: 0644]
tests/blueprints/tosca-vnfd-hello-ves/start.sh
tests/vHello_VES.sh

index 50f45ec..39cd528 100644 (file)
@@ -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 (file)
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 (file)
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 (file)
index 0000000..9f3b7ff
--- /dev/null
@@ -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,
+
index b8f6e14..1aa01e8 100755 (executable)
@@ -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!<br>
 </body></html>
 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
index 206eec5..95d3f4f 100644 (file)
@@ -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
 }