diff options
author | 2017-05-23 17:59:45 -0500 | |
---|---|---|
committer | 2017-06-11 18:03:27 -0700 | |
commit | 8a54006e88440215666ec7f26858605bd7d679b8 (patch) | |
tree | 490d50c958bc11f2dbb9ea6de94b40a6442360d0 | |
parent | 0a7e112bb543e73dadb1b78a2ad9d1850c9c9d2e (diff) |
WIP
Update to 5 VDUs
Update to use JSON schema 5.1 (separate update to Barometer plugin)
Update so container is correctly referenced as 'onap-demo'
Add output statement to facilitate debuggin; web servers working
Disable credential validation in monitor.py
Updated start.sh based on Bryan's changes
Start.sh: pull latest barometer collectd plugin patch
- various improvements in setup_agent()
- remove GuestRunning from collectd config
- add setup of InfluxDB and Grafana to monitor
- add setup of agents in vFW and vLB
ves_onap_demo.sh: fixed tacker not being configured (also Models patches)
- add security groups for monitor incoming traffic
evel_demo.c: update to latest schema, remove demo code
monitor.py: integrate InfluxDB and Grafana
Dashboard.json: file to import into Grafana
infsetup.py: setup script for the veseventsdb database
Refactoring to have junphost interact direct with VMs etc as needed.
Update dashboard.json with current dashboard design.
ves_onap_demo.sh:
- fix method of checking if vnf has been deleted
- reduce RAM size in onap.demo flavor to save headroom in virtual deploy
- fix copy of public key to /opt/tacker
JIRA: VES-11
Change-Id: I210d566f52e2ef7a504b78033d822cf7430631b6
Signed-off-by: Aimee Ukasick <aimeeu.opensource@gmail.com>
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
12 files changed, 3832 insertions, 1108 deletions
diff --git a/tests/blueprints/tosca-vnfd-hello-ves/blueprint.yaml b/tests/blueprints/tosca-vnfd-hello-ves/blueprint.yaml index a998dad..f9055a3 100755 --- a/tests/blueprints/tosca-vnfd-hello-ves/blueprint.yaml +++ b/tests/blueprints/tosca-vnfd-hello-ves/blueprint.yaml @@ -268,6 +268,7 @@ topology_template: image: models-xenial-server availability_zone: nova mgmt_driver: noop + config_drive: true user_data_format: RAW user_data: | #!/bin/bash diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/Dashboard.json b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/Dashboard.json new file mode 100644 index 0000000..00b9d6b --- /dev/null +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/Dashboard.json @@ -0,0 +1,2354 @@ +{ +"dashboard": { + "id": null, + "title": "VES Demo", + "originalTitle": "VES Demo", + "tags": [], + "style": "dark", + "timezone": "browser", + "editable": true, + "hideControls": false, + "sharedCrosshair": false, + "rows": [ + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 3, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "CpuUser", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpuuser\") FROM \"cpu\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuuser" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "CpuSystem", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpusystem" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "CpuIdle", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpuidle\") FROM \"cpu\" WHERE $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuidle" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "VES computehost CPU Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Percent", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 5, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "CpuUser", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpuuser\") FROM \"cpu\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuuser" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "CpuSystem", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpusystem" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "CpuIdle", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpuidle\") FROM \"cpu\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuidle" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "VES vFW CPU Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Percent", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 6, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "CpuUser", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpuuser\") FROM \"cpu\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuuser" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "CpuSystem", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpusystem\") FROM \"cpu\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpusystem" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "CpuIdle", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "cpu", + "policy": "default", + "query": "SELECT mean(\"cpuidle\") FROM \"cpu\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cpuidle" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "VES vLB CPU Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Percent", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + }, + { + "collapse": false, + "editable": true, + "height": 250, + "panels": [ + { + "alert": { + "conditions": [ + { + "evaluator": { + "params": [ + 15000000 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "1s", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "frequency": "1s", + "handler": 1, + "message": "Transmitted Traffic Exceeded limits\nClosed Loop Action:Apply Firewall Rules", + "name": "VES webserver_1 Network Usage alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 2, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Rx-tap07d69530-f4", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "policy": "default", + "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Tx-tap07d69530-f4", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "policy": "default", + "query": "SELECT derivative(mean(\"txoctets\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Rx-tap6e8ff422-16", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "vnic", + "policy": "default", + "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Tx-tap6e8ff422-16", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "vnic", + "policy": "default", + "query": "SELECT derivative(mean(\"txoctets\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Rx-tapff224e80-4e", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": false, + "measurement": "vnic", + "policy": "default", + "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Tx-tapff224e80-4e", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "query": "SELECT derivative(mean(\"txoctets\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "F", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Rx-tapaea4af02-61", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time($interval) fill(null)", + "refId": "G", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Tx-tapaea4af02-61", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "query": "SELECT derivative(mean(\"txoctets\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time($interval) fill(null)", + "refId": "H", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Rx-tapa44215ed-f5", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "query": "SELECT derivative(mean(\"rxoctetsacc\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time($interval) fill(null)", + "refId": "I", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + }, + { + "alias": "Tx-tapa44215ed-f5", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "query": "SELECT derivative(mean(\"txoctets\"), 10s) FROM \"vnic\" WHERE \"system\" = 'computehost' AND $timeFilter GROUP BY time($interval) fill(null)", + "refId": "J", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + }, + { + "params": [ + "10s" + ], + "type": "derivative" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "computehost" + } + ] + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 15000000 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "VES compputehost Network Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Octets/Packets", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "alert": { + "conditions": [ + { + "evaluator": { + "params": [ + 15000000 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "1s", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "frequency": "1s", + "handler": 1, + "message": "Transmitted Traffic Exceeded limits\nClosed Loop Action:Apply Firewall Rules", + "name": "VES webserver_1 Network Usage alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 7, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "TxOctetsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"txoctets\") FROM \"vnic\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "RxOctetsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"rxoctetsacc\") FROM \"vnic\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "TxPacketsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"txpacketacc\") FROM \"vnic\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txpacketacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "RxPacketsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"rxpacketsacc\") FROM \"vnic\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxpacketsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "HttpTraffic", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"vnic\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 15000000 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "VES vFW Network Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Octets/Packets", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "alert": { + "conditions": [ + { + "evaluator": { + "params": [ + 15000000 + ], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "1s", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "frequency": "1s", + "handler": 1, + "message": "Transmitted Traffic Exceeded limits\nClosed Loop Action:Apply Firewall Rules", + "name": "VES webserver_1 Network Usage alert", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 8, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "TxOctetsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"txoctets\") FROM \"vnic\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txoctets" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "RxOctetsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"rxoctetsacc\") FROM \"vnic\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxoctetsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "TxPacketsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"txpacketacc\") FROM \"vnic\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "txpacketacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "RxPacketsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"rxpacketsacc\") FROM \"vnic\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "rxpacketsacc" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "HttpTraffic", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "vnic", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"vnic\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 15000000 + } + ], + "timeFrom": null, + "timeShift": null, + "title": "VES vLB Network Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Octets/Packets", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + }, + { + "collapse": false, + "editable": true, + "height": 250, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "datasource": "VESEvents", + "fill": 1, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null, + "threshold1": null, + "threshold1Color": "rgba(216, 200, 27, 0.27)", + "threshold2": null, + "threshold2Color": "rgba(234, 112, 112, 0.22)" + }, + "id": 4, + "interval": "30s", + "legend": { + "alignAsTable": false, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "webserver_1", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "http", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"http\" WHERE \"system\" = 'webserver_1' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "webserver_1" + } + ] + }, + { + "alias": "webserver_2", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "http", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"http\" WHERE \"system\" = 'webserver_2' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "webserver_2" + } + ] + }, + { + "alias": "TxPacketsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "http", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"http\" WHERE \"system\" = 'loadbalancer' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "loadbalancer" + } + ] + }, + { + "alias": "RxPacketsAcc", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "http", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"http\" WHERE \"system\" = 'firewall' AND $timeFilter GROUP BY time(1m) fill(null)", + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [ + { + "key": "system", + "operator": "=", + "value": "firewall" + } + ] + }, + { + "alias": "HttpTraffic", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "1m" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "hide": true, + "measurement": "webbserver_2", + "policy": "default", + "query": "SELECT mean(\"httptxrx\") FROM \"webbserver_2\" WHERE $timeFilter GROUP BY time(1m) fill(null)", + "refId": "E", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "httptxrx" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "VES Web Server Traffic", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "short", + "short" + ], + "yaxes": [ + { + "format": "short", + "label": "Octets/Packets", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": false, + "title": "Dashboard Row", + "titleSize": "h6" + } + ], + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "now": true, + "refresh_intervals": [ + "10s", + "20s", + "30s", + "1m" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "templating": { + "list": [] + }, + "annotations": { + "list": [] + }, + "refresh": "10s", + "schemaVersion": 8, + "version": 7, + "links": [] +} +} diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/blueprint.yaml b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/blueprint.yaml index 6d9abf9..5c69191 100644 --- a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/blueprint.yaml +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/blueprint.yaml @@ -66,8 +66,8 @@ topology_template: sudo apt-get update sudo apt-get install -y docker-engine sudo docker pull nginx - sudo docker build -t vhello . - sudo docker run --name vHello -d -p 80:80 vhello + sudo docker build -t onap-demo-img . + sudo docker run --name onap-demo -d -p 80:80 onap-demo-img config: | param0: key1 param1: key2 @@ -152,8 +152,8 @@ topology_template: sudo apt-get update sudo apt-get install -y docker-engine sudo docker pull nginx - sudo docker build -t vhello . - sudo docker run --name vHello -d -p 80:80 vhello + sudo docker build -t onap-demo-img . + sudo docker run --name onap-demo -d -p 80:80 onap-demo-img config: | param0: key1 param1: key2 @@ -244,6 +244,7 @@ topology_template: image: models-xenial-server flavor: onap.demo availability_zone: nova + config_drive: true user_data_format: RAW user_data: | #!/bin/bash @@ -254,6 +255,20 @@ topology_template: cat << EOM >/home/ubuntu/.ssh/authorized_keys <pubkey> EOM + sudo mount /dev/sr0 /mnt/ + cat << EOF >/tmp/setup.sh + echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward + sudo sysctl net.ipv4.ip_forward=1 + sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -m state \\ + --state NEW -m statistic --mode nth --every 1 --packet 0 \\ + -j DNAT --to-destination <vdu3_ip>:80 + sudo iptables -t nat -A POSTROUTING -j MASQUERADE + EOF + bash /tmp/setup.sh + config: | + param0: key1 + param1: key2 + config: | param0: key1 param1: key2 @@ -279,6 +294,47 @@ topology_template: - virtualBinding: node: VDU4 + VDU5: + type: tosca.nodes.nfv.VDU.Tacker + properties: + image: models-xenial-server + flavor: onap.demo + availability_zone: nova + user_data_format: RAW + user_data: | + #!/bin/bash + set -x + mkdir /home/ubuntu + chown -R ubuntu /home/ubuntu + mkdir /home/ubuntu/.ssh + cat << EOM >/home/ubuntu/.ssh/authorized_keys + <pubkey> + EOM + config: | + param0: key1 + param1: key2 + + CP43: + type: tosca.nodes.nfv.CP.Tacker + properties: + management: true + anti_spoofing_protection: false + requirements: + - virtualLink: + node: VL1 + - virtualBinding: + node: VDU5 + + CP44: + type: tosca.nodes.nfv.CP.Tacker + properties: + anti_spoofing_protection: false + requirements: + - virtualLink: + node: VL2 + - virtualBinding: + node: VDU5 + VL1: type: tosca.nodes.nfv.VL properties: diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/evel_demo.c b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/evel_demo.c index fc244d8..a3774fa 100644 --- a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/evel_demo.c +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/evel_demo.c @@ -1,21 +1,21 @@ /**************************************************************************//** * @file - * Agent for the OPNFV VNF Event Stream (VES) vHello_VES test + * Agent for the OPNFV VNF Event Stream (VES) ves_onap_demo test * * Copyright 2016-2017 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. - * + * *****************************************************************************/ #include <stdio.h> @@ -127,16 +127,6 @@ typedef enum { /*****************************************************************************/ /* Local prototypes. */ /*****************************************************************************/ -static void demo_heartbeat(void); -static void demo_fault(void); -static void demo_measurement(const int interval); -static void demo_mobile_flow(void); -static void demo_service(void); -static void demo_service_event(const SERVICE_EVENT service_event); -static void demo_signaling(void); -static void demo_state_change(void); -static void demo_syslog(void); -static void demo_other(void); /**************************************************************************//** * Global flags related the applicaton. @@ -147,20 +137,27 @@ char *app_prevstate = "Stopped"; /**************************************************************************//** * Report app state change fault. * - * Reports the change in app state. + * Reports the change in app state. * * param[in] char *change The type of change ("Started", "Stopped") *****************************************************************************/ -void report_app_statechange(char *change) +void report_app_statechange(char *change) { printf("report_app_statechange(%s)\n", change); EVENT_FAULT * fault = NULL; EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + int status = EVEL_VF_STATUS_ACTIVE; + + if (change == "Stopped") { + status = EVEL_VF_STATUS_IDLE; + } fault = evel_new_fault("App state change", change, EVEL_PRIORITY_HIGH, - EVEL_SEVERITY_MAJOR); + EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION, + status); if (fault != NULL) { evel_fault_type_set(fault, "App state change"); @@ -178,7 +175,7 @@ void report_app_statechange(char *change) /**************************************************************************//** * Check status of the app container. * - * Checks and reports any change in app state. + * Checks and reports any change in app state. * * param[in] none *****************************************************************************/ @@ -188,7 +185,7 @@ void check_app_container_state() { int status; char state[100]; - fp = popen("sudo docker inspect vHello | grep Status | sed -- 's/,//g' | sed -- 's/\"//g' | sed -- 's/ Status: //g'", "r"); + fp = popen("sudo docker inspect onap-demo | grep Status | sed -- 's/,//g' | sed -- 's/\"//g' | sed -- 's/ Status: //g'", "r"); if (fp == NULL) { EVEL_ERROR("popen failed to execute command"); } @@ -275,7 +272,7 @@ void measure_traffic() { strncat(period, secs, 21); // ....x....1....x....2. // 15/Oct/2016:17:51:19 - strcpy(cmd, "sudo docker logs vHello | grep -c "); + strcpy(cmd, "sudo docker logs onap-demo | grep -c "); strncat(cmd, period, 100); fp = popen(cmd, "r"); @@ -501,7 +498,7 @@ int main(int argc, char ** argv) api_username, api_password, EVEL_SOURCE_VIRTUAL_MACHINE, - "EVEL demo client", + "webserver", verbose_mode)) { fprintf(stderr, "Failed to initialize the EVEL library!!!"); @@ -666,18 +663,6 @@ int main(int argc, char ** argv) check_app_container_state(); measure_traffic(); -// demo_heartbeat(); -// demo_fault(); -// demo_measurement((measurement_interval == -// EVEL_MEASUREMENT_INTERVAL_UKNOWN) ? -// DEFAULT_SLEEP_SECONDS : measurement_interval); -// demo_mobile_flow(); -// demo_service(); -// demo_signaling(); -// demo_state_change(); -// demo_syslog(); -// demo_other(); - /*************************************************************************/ /* MAIN RETRY LOOP. Check and implement the measurement interval. */ /*************************************************************************/ @@ -767,750 +752,3 @@ void *signal_watcher(void *void_sig_set) return(NULL); } -/**************************************************************************//** - * Create and send a heartbeat event. - *****************************************************************************/ -void demo_heartbeat(void) -{ - EVENT_HEADER * heartbeat = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* Heartbeat */ - /***************************************************************************/ - heartbeat = evel_new_heartbeat(); - if (heartbeat != NULL) - { - evel_rc = evel_post_event(heartbeat); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Heartbeat failed"); - } - printf(" Processed Heartbeat\n"); -} - -/**************************************************************************//** - * Create and send three fault events. - *****************************************************************************/ -void demo_fault(void) -{ - EVENT_FAULT * fault = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* Fault */ - /***************************************************************************/ - fault = evel_new_fault("An alarm condition", - "Things are broken", - EVEL_PRIORITY_NORMAL, - EVEL_SEVERITY_MAJOR); - if (fault != NULL) - { - evel_rc = evel_post_event((EVENT_HEADER *)fault); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Fault failed"); - } - printf(" Processed empty Fault\n"); - - fault = evel_new_fault("Another alarm condition", - "It broke badly", - EVEL_PRIORITY_NORMAL, - EVEL_SEVERITY_MAJOR); - if (fault != NULL) - { - evel_fault_type_set(fault, "Bad things happening"); - evel_fault_interface_set(fault, "An Interface Card"); - evel_rc = evel_post_event((EVENT_HEADER *)fault); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Fault failed"); - } - printf(" Processed partial Fault\n"); - - fault = evel_new_fault("My alarm condition", - "It broke very badly", - EVEL_PRIORITY_NORMAL, - EVEL_SEVERITY_MAJOR); - if (fault != NULL) - { - evel_fault_type_set(fault, "Bad things happen..."); - evel_fault_interface_set(fault, "My Interface Card"); - evel_fault_addl_info_add(fault, "name1", "value1"); - evel_fault_addl_info_add(fault, "name2", "value2"); - evel_rc = evel_post_event((EVENT_HEADER *)fault); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Fault failed"); - } - printf(" Processed full Fault\n"); -} - -/**************************************************************************//** - * Create and send a measurement event. - *****************************************************************************/ -void demo_measurement(const int interval) -{ - EVENT_MEASUREMENT * measurement = NULL; - MEASUREMENT_LATENCY_BUCKET * bucket = NULL; - MEASUREMENT_VNIC_USE * vnic_use = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* Measurement */ - /***************************************************************************/ - measurement = evel_new_measurement(interval); - if (measurement != NULL) - { - evel_measurement_type_set(measurement, "Perf management..."); - evel_measurement_conc_sess_set(measurement, 1); - evel_measurement_cfg_ents_set(measurement, 2); - evel_measurement_mean_req_lat_set(measurement, 4.4); - evel_measurement_mem_cfg_set(measurement, 6.6); - evel_measurement_mem_used_set(measurement, 3.3); - evel_measurement_request_rate_set(measurement, 6); - evel_measurement_agg_cpu_use_set(measurement, 8.8); - evel_measurement_cpu_use_add(measurement, "cpu1", 11.11); - evel_measurement_cpu_use_add(measurement, "cpu2", 22.22); - evel_measurement_fsys_use_add(measurement,"00-11-22",100.11, 100.22, 33, - 200.11, 200.22, 44); - evel_measurement_fsys_use_add(measurement,"33-44-55",300.11, 300.22, 55, - 400.11, 400.22, 66); - - bucket = evel_new_meas_latency_bucket(20); - evel_meas_latency_bucket_low_end_set(bucket, 0.0); - evel_meas_latency_bucket_high_end_set(bucket, 10.0); - evel_meas_latency_bucket_add(measurement, bucket); - - bucket = evel_new_meas_latency_bucket(30); - evel_meas_latency_bucket_low_end_set(bucket, 10.0); - evel_meas_latency_bucket_high_end_set(bucket, 20.0); - evel_meas_latency_bucket_add(measurement, bucket); - - vnic_use = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4); - evel_vnic_use_bcast_pkt_in_set(vnic_use, 1); - evel_vnic_use_bcast_pkt_out_set(vnic_use, 2); - evel_vnic_use_mcast_pkt_in_set(vnic_use, 5); - evel_vnic_use_mcast_pkt_out_set(vnic_use, 6); - evel_vnic_use_ucast_pkt_in_set(vnic_use, 7); - evel_vnic_use_ucast_pkt_out_set(vnic_use, 8); - evel_meas_vnic_use_add(measurement, vnic_use); - - vnic_use = evel_new_measurement_vnic_use("eth1", 110, 240, 13, 14); - evel_vnic_use_bcast_pkt_in_set(vnic_use, 11); - evel_vnic_use_bcast_pkt_out_set(vnic_use, 12); - evel_vnic_use_mcast_pkt_in_set(vnic_use, 15); - evel_vnic_use_mcast_pkt_out_set(vnic_use, 16); - evel_vnic_use_ucast_pkt_in_set(vnic_use, 17); - evel_vnic_use_ucast_pkt_out_set(vnic_use, 18); - evel_meas_vnic_use_add(measurement, vnic_use); - - evel_measurement_errors_set(measurement, 1, 0, 2, 1); - - evel_measurement_feature_use_add(measurement, "FeatureA", 123); - evel_measurement_feature_use_add(measurement, "FeatureB", 567); - - evel_measurement_codec_use_add(measurement, "G711a", 91); - evel_measurement_codec_use_add(measurement, "G729ab", 92); - - evel_measurement_media_port_use_set(measurement, 1234); - - evel_measurement_vnfc_scaling_metric_set(measurement, 1234.5678); - - evel_measurement_custom_measurement_add(measurement, - "Group1", "Name1", "Value1"); - evel_measurement_custom_measurement_add(measurement, - "Group2", "Name1", "Value1"); - evel_measurement_custom_measurement_add(measurement, - "Group2", "Name2", "Value2"); - - /*************************************************************************/ - /* Work out the time, to use as end of measurement period. */ - /*************************************************************************/ - struct timeval tv_now; - gettimeofday(&tv_now, NULL); - unsigned long long epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec; - evel_start_epoch_set(&measurement->header, epoch_start); - evel_last_epoch_set(&measurement->header, epoch_now); - epoch_start = epoch_now; - evel_reporting_entity_name_set(&measurement->header, "measurer"); - evel_reporting_entity_id_set(&measurement->header, "measurer_id"); - - evel_rc = evel_post_event((EVENT_HEADER *)measurement); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post Measurement failed %d (%s)", - evel_rc, - evel_error_string()); - } - } - else - { - EVEL_ERROR("New Measurement failed"); - } - printf(" Processed Measurement\n"); -} - -/**************************************************************************//** - * Create and send three mobile flow events. - *****************************************************************************/ -void demo_mobile_flow(void) -{ - MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL; - EVENT_MOBILE_FLOW * mobile_flow = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* Mobile Flow */ - /***************************************************************************/ - metrics = evel_new_mobile_gtp_flow_metrics(12.3, - 3.12, - 100, - 2100, - 500, - 1470409421, - 987, - 1470409431, - 11, - (time_t)1470409431, - "Working", - 87, - 3, - 17, - 123654, - 4561, - 0, - 12, - 10, - 1, - 3, - 7, - 899, - 901, - 302, - 6, - 2, - 0, - 110, - 225); - if (metrics != NULL) - { - mobile_flow = evel_new_mobile_flow("Outbound", - metrics, - "TCP", - "IPv4", - "2.3.4.1", - 2341, - "4.2.3.1", - 4321); - if (mobile_flow != NULL) - { - evel_rc = evel_post_event((EVENT_HEADER *)mobile_flow); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post Mobile Flow failed %d (%s)", - evel_rc, - evel_error_string()); - } - } - else - { - EVEL_ERROR("New Mobile Flow failed"); - } - printf(" Processed empty Mobile Flow\n"); - } - else - { - EVEL_ERROR("New GTP Per Flow Metrics failed - skipping Mobile Flow"); - printf(" Skipped empty Mobile Flow\n"); - } - - metrics = evel_new_mobile_gtp_flow_metrics(132.0001, - 31.2, - 101, - 2101, - 501, - 1470409422, - 988, - 1470409432, - 12, - (time_t)1470409432, - "Inactive", - 88, - 4, - 18, - 123655, - 4562, - 1, - 13, - 11, - 2, - 4, - 8, - 900, - 902, - 303, - 7, - 3, - 1, - 111, - 226); - if (metrics != NULL) - { - mobile_flow = evel_new_mobile_flow("Inbound", - metrics, - "UDP", - "IPv6", - "2.3.4.2", - 2342, - "4.2.3.2", - 4322); - if (mobile_flow != NULL) - { - evel_mobile_flow_app_type_set(mobile_flow, "Demo application"); - evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM"); - evel_mobile_flow_app_prot_ver_set(mobile_flow, "1"); - evel_mobile_flow_cid_set(mobile_flow, "65535"); - evel_mobile_flow_con_type_set(mobile_flow, "S1-U"); - evel_mobile_flow_ecgi_set(mobile_flow, "e65535"); - evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U"); - evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1"); - evel_mobile_flow_http_header_set(mobile_flow, - "http://www.something.com"); - evel_mobile_flow_imei_set(mobile_flow, "209917614823"); - evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8"); - evel_mobile_flow_lac_set(mobile_flow, "1"); - evel_mobile_flow_mcc_set(mobile_flow, "410"); - evel_mobile_flow_mnc_set(mobile_flow, "04"); - evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789"); - evel_mobile_flow_other_func_role_set(mobile_flow, "MME"); - evel_mobile_flow_rac_set(mobile_flow, "514"); - evel_mobile_flow_radio_acc_tech_set(mobile_flow, "LTE"); - evel_mobile_flow_sac_set(mobile_flow, "1"); - evel_mobile_flow_samp_alg_set(mobile_flow, 1); - evel_mobile_flow_tac_set(mobile_flow, "2099"); - evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 1"); - evel_mobile_flow_vlan_id_set(mobile_flow, "15"); - - evel_rc = evel_post_event((EVENT_HEADER *)mobile_flow); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post Mobile Flow failed %d (%s)", - evel_rc, - evel_error_string()); - } - } - else - { - EVEL_ERROR("New Mobile Flow failed"); - } - printf(" Processed partial Mobile Flow\n"); - } - else - { - EVEL_ERROR("New GTP Per Flow Metrics failed - skipping Mobile Flow"); - printf(" Skipped partial Mobile Flow\n"); - } - - metrics = evel_new_mobile_gtp_flow_metrics(12.32, - 3.122, - 1002, - 21002, - 5002, - 1470409423, - 9872, - 1470409433, - 112, - (time_t)1470409433, - "Failed", - 872, - 32, - 172, - 1236542, - 45612, - 2, - 122, - 102, - 12, - 32, - 72, - 8992, - 9012, - 3022, - 62, - 22, - 2, - 1102, - 2252); - if (metrics != NULL) - { - evel_mobile_gtp_metrics_dur_con_fail_set(metrics, 12); - evel_mobile_gtp_metrics_dur_tun_fail_set(metrics, 13); - evel_mobile_gtp_metrics_act_by_set(metrics, "Remote"); - evel_mobile_gtp_metrics_act_time_set(metrics, (time_t)1470409423); - evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote"); - evel_mobile_gtp_metrics_con_status_set(metrics, "Connected"); - evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling"); - evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13); - evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1); - evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99); - evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80); - evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0); - evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680); - evel_mobile_gtp_metrics_max_trx_bit_rate_set(metrics, 235711); - evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1); - evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4); - evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2); - evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10); - evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121); - evel_mobile_gtp_metrics_qci_cos_count_add( - metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11); - evel_mobile_gtp_metrics_qci_cos_count_add( - metrics, EVEL_QCI_COS_LTE_65, 122); - - mobile_flow = evel_new_mobile_flow("Outbound", - metrics, - "RTP", - "IPv8", - "2.3.4.3", - 2343, - "4.2.3.3", - 4323); - if (mobile_flow != NULL) - { - evel_mobile_flow_app_type_set(mobile_flow, "Demo application 2"); - evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM"); - evel_mobile_flow_app_prot_ver_set(mobile_flow, "2"); - evel_mobile_flow_cid_set(mobile_flow, "1"); - evel_mobile_flow_con_type_set(mobile_flow, "S1-U"); - evel_mobile_flow_ecgi_set(mobile_flow, "e1"); - evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U"); - evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1"); - evel_mobile_flow_http_header_set(mobile_flow, "http://www.google.com"); - evel_mobile_flow_imei_set(mobile_flow, "209917614823"); - evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8"); - evel_mobile_flow_lac_set(mobile_flow, "1"); - evel_mobile_flow_mcc_set(mobile_flow, "410"); - evel_mobile_flow_mnc_set(mobile_flow, "04"); - evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789"); - evel_mobile_flow_other_func_role_set(mobile_flow, "MMF"); - evel_mobile_flow_rac_set(mobile_flow, "514"); - evel_mobile_flow_radio_acc_tech_set(mobile_flow, "3G"); - evel_mobile_flow_sac_set(mobile_flow, "1"); - evel_mobile_flow_samp_alg_set(mobile_flow, 2); - evel_mobile_flow_tac_set(mobile_flow, "2099"); - evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 2"); - evel_mobile_flow_vlan_id_set(mobile_flow, "4096"); - - evel_rc = evel_post_event((EVENT_HEADER *)mobile_flow); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post Mobile Flow failed %d (%s)", - evel_rc, - evel_error_string()); - } - } - else - { - EVEL_ERROR("New Mobile Flow failed"); - } - printf(" Processed full Mobile Flow\n"); - } - else - { - EVEL_ERROR("New GTP Per Flow Metrics failed - skipping Mobile Flow"); - printf(" Skipped full Mobile Flow\n"); - } -} - -/**************************************************************************//** - * Create and send a Service event. - *****************************************************************************/ -void demo_service() -{ - demo_service_event(SERVICE_CODEC); - demo_service_event(SERVICE_TRANSCODING); - demo_service_event(SERVICE_RTCP); - demo_service_event(SERVICE_EOC_VQM); - demo_service_event(SERVICE_MARKER); -} - -void demo_service_event(const SERVICE_EVENT service_event) -{ - EVENT_SERVICE * event = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - event = evel_new_service("vendor_x_id", "vendor_x_event_id"); - if (event != NULL) - { - evel_service_type_set(event, "Service Event"); - evel_service_product_id_set(event, "vendor_x_product_id"); - evel_service_subsystem_id_set(event, "vendor_x_subsystem_id"); - evel_service_friendly_name_set(event, "vendor_x_frieldly_name"); - evel_service_correlator_set(event, "vendor_x_correlator"); - evel_service_addl_field_add(event, "Name1", "Value1"); - evel_service_addl_field_add(event, "Name2", "Value2"); - - switch (service_event) - { - case SERVICE_CODEC: - evel_service_codec_set(event, "PCMA"); - break; - case SERVICE_TRANSCODING: - evel_service_callee_codec_set(event, "PCMA"); - evel_service_caller_codec_set(event, "G729A"); - break; - case SERVICE_RTCP: - evel_service_rtcp_data_set(event, "some_rtcp_data"); - break; - case SERVICE_EOC_VQM: - evel_service_adjacency_name_set(event, "vendor_x_adjacency"); - evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER); - evel_service_endpoint_jitter_set(event, 66); - evel_service_endpoint_rtp_oct_disc_set(event, 100); - evel_service_endpoint_rtp_oct_recv_set(event, 200); - evel_service_endpoint_rtp_oct_sent_set(event, 300); - evel_service_endpoint_rtp_pkt_disc_set(event, 400); - evel_service_endpoint_rtp_pkt_recv_set(event, 500); - evel_service_endpoint_rtp_pkt_sent_set(event, 600); - evel_service_local_jitter_set(event, 99); - evel_service_local_rtp_oct_disc_set(event, 150); - evel_service_local_rtp_oct_recv_set(event, 250); - evel_service_local_rtp_oct_sent_set(event, 350); - evel_service_local_rtp_pkt_disc_set(event, 450); - evel_service_local_rtp_pkt_recv_set(event, 550); - evel_service_local_rtp_pkt_sent_set(event, 650); - evel_service_mos_cqe_set(event, 12.255); - evel_service_packets_lost_set(event, 157); - evel_service_packet_loss_percent_set(event, 0.232); - evel_service_r_factor_set(event, 11); - evel_service_round_trip_delay_set(event, 15); - break; - case SERVICE_MARKER: - evel_service_phone_number_set(event, "0888888888"); - break; - } - - evel_rc = evel_post_event((EVENT_HEADER *) event); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Service failed"); - } - printf(" Processed Service Events\n"); -} - -/**************************************************************************//** - * Create and send a Signaling event. - *****************************************************************************/ -void demo_signaling(void) -{ - EVENT_SIGNALING * event = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - event = evel_new_signaling("vendor_x_id", "vendor_x_event_id"); - if (event != NULL) - { - evel_signaling_type_set(event, "Signaling"); - evel_signaling_product_id_set(event, "vendor_x_product_id"); - evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id"); - evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name"); - evel_signaling_correlator_set(event, "vendor_x_correlator"); - evel_signaling_local_ip_address_set(event, "1.0.3.1"); - evel_signaling_local_port_set(event, "1031"); - evel_signaling_remote_ip_address_set(event, "5.3.3.0"); - evel_signaling_remote_port_set(event, "5330"); - evel_signaling_compressed_sip_set(event, "compressed_sip"); - evel_signaling_summary_sip_set(event, "summary_sip"); - evel_rc = evel_post_event((EVENT_HEADER *) event); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Signaling failed"); - } - printf(" Processed Signaling\n"); -} - -/**************************************************************************//** - * Create and send a state change event. - *****************************************************************************/ -void demo_state_change(void) -{ - EVENT_STATE_CHANGE * state_change = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* State Change */ - /***************************************************************************/ - state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE, - EVEL_ENTITY_STATE_OUT_OF_SERVICE, - "Interface"); - if (state_change != NULL) - { - evel_state_change_type_set(state_change, "State Change"); - evel_state_change_addl_field_add(state_change, "Name1", "Value1"); - evel_state_change_addl_field_add(state_change, "Name2", "Value2"); - evel_rc = evel_post_event((EVENT_HEADER *)state_change); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New State Change failed"); - } - printf(" Processed State Change\n"); -} - -/**************************************************************************//** - * Create and send two syslog events. - *****************************************************************************/ -void demo_syslog(void) -{ - EVENT_SYSLOG * syslog = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* Syslog */ - /***************************************************************************/ - syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION, - "EVEL library message", - "EVEL"); - if (syslog != NULL) - { - evel_rc = evel_post_event((EVENT_HEADER *)syslog); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Syslog failed"); - } - printf(" Processed empty Syslog\n"); - - syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_MACHINE, - "EVEL library message", - "EVEL"); - if (syslog != NULL) - { - evel_syslog_event_source_host_set(syslog, "Virtual host"); - evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LOCAL0); - evel_syslog_proc_set(syslog, "vnf_process"); - evel_syslog_proc_id_set(syslog, 1423); - evel_syslog_version_set(syslog, 1); - evel_syslog_addl_field_add(syslog, "Name1", "Value1"); - evel_syslog_addl_field_add(syslog, "Name2", "Value2"); - evel_syslog_addl_field_add(syslog, "Name3", "Value3"); - evel_syslog_addl_field_add(syslog, "Name4", "Value4"); - evel_rc = evel_post_event((EVENT_HEADER *)syslog); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Syslog failed"); - } - printf(" Processed full Syslog\n"); -} - -/**************************************************************************//** - * Create and send two other events. - *****************************************************************************/ -void demo_other(void) -{ - EVENT_OTHER * other = NULL; - EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; - - /***************************************************************************/ - /* Other */ - /***************************************************************************/ - other = evel_new_other(); - if (other != NULL) - { - evel_rc = evel_post_event((EVENT_HEADER *)other); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Other failed"); - } - printf(" Processed empty Other\n"); - - other = evel_new_other(); - if (other != NULL) - { - evel_other_field_add(other, - "Other field 1", - "Other value 1"); - evel_rc = evel_post_event((EVENT_HEADER *)other); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Other failed"); - } - printf(" Processed small Other\n"); - - other = evel_new_other(); - if (other != NULL) - { - evel_other_field_add(other, - "Other field A", - "Other value A"); - evel_other_field_add(other, - "Other field B", - "Other value B"); - evel_other_field_add(other, - "Other field C", - "Other value C"); - evel_rc = evel_post_event((EVENT_HEADER *)other); - if (evel_rc != EVEL_SUCCESS) - { - EVEL_ERROR("Post failed %d (%s)", evel_rc, evel_error_string()); - } - } - else - { - EVEL_ERROR("New Other failed"); - } - printf(" Processed large Other\n"); -} diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/infsetup.py b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/infsetup.py new file mode 100644 index 0000000..fb8cbdc --- /dev/null +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/infsetup.py @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +import argparse +import json + +from influxdb import InfluxDBClient + + +def main(host='localhost', port=8086): + user = 'root' + password = 'root' + dbname = 'veseventsdb' + dbuser = 'root' + dbuser_password = 'my_secret_password' + query = 'select value from cpu_load_short;' + json_body = [ + { + "measurement": "cpu_load_short", + "tags": { + "host": "server01", + "region": "us-west" + }, + "time": "2009-11-10T23:00:00Z", + "fields": { + "Float_value": 0.64, + "Int_value": 3, + "String_value": "Text", + "Bool_value": True + } + } + ] + + client = InfluxDBClient(host, port, user, password, dbname) + + print("Create database: " + dbname) + client.create_database(dbname) + + print("Create a retention policy") + client.create_retention_policy('awesome_policy', '6h', 3, default=True) + +# print("Switch user: " + dbuser) +# client.switch_user(dbuser, dbuser_password) +# +# print("Write points: {0}".format(json_body)) +# client.write_points(json_body) +# +# print("Queying data: " + query) +# result = client.query(query) +# +# print("Result: {0}".format(result)) +# +# print("Switch user: " + user) +# client.switch_user(user, password) +# +# print("Drop database: " + dbname) +# client.drop_database(dbname) +# + +def parse_args(): + parser = argparse.ArgumentParser( + description='example code to play with InfluxDB') + parser.add_argument('--host', type=str, required=False, default='localhost', + help='hostname of InfluxDB http API') + parser.add_argument('--port', type=int, required=False, default=8086, + help='port of InfluxDB http API') + return parser.parse_args() + + +if __name__ == '__main__': + args = parse_args() + main(host=args.host, port=args.port) diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/monitor.py b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/monitor.py index 9b16af3..8784ca4 100644 --- a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/monitor.py +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/monitor.py @@ -14,8 +14,8 @@ # 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. +# What this is: Monitor and closed-loop policy agent as part of the OPNFV VES +# ves_onap_demo. # # Status: this is a work in progress, under test. @@ -34,9 +34,10 @@ import string import json import jsonschema from functools import partial +import requests monitor_mode = "f" -vdu_id = ['','','',''] +vdu_id = ['','','','','',''] summary_e = ['***** Summary of key stats *****','','',''] summary_c = ['Collectd agents:'] status = ['','Started','Started','Started'] @@ -49,27 +50,6 @@ class JSONObject: def __init__(self, d): self.__dict__ = d -_hello_resp = '''\ -<html> - <head> - <title>Hello {name}</title> - </head> - <body> - <h1>Hello {name}!</h1> - </body> -</html>''' - -_localtime_resp = '''\ -<?xml version="1.0"?> -<time> - <year>{t.tm_year}</year> - <month>{t.tm_mon}</month> - <day>{t.tm_mday}</day> - <hour>{t.tm_hour}</hour> - <minute>{t.tm_min}</minute> - <second>{t.tm_sec}</second> -</time>''' - __all__ = [] __version__ = 0.1 __date__ = '2015-12-04' @@ -197,7 +177,7 @@ def listener(environ, start_response, schema): #-------------------------------------------------------------------------- if (credentials == (vel_username + ':' + vel_password)): logger.debug('Authenticated OK') - print('Authenticated OK') +# print('Authenticated OK') #---------------------------------------------------------------------- # Respond to the caller. If we have a pending commandList from the @@ -222,8 +202,9 @@ def listener(environ, start_response, schema): start_response('202 Accepted', []) yield '' else: - logger.warn('Failed to authenticate OK') - print('Failed to authenticate agent credentials: ', credentials) + logger.warn('Failed to authenticate OK; creds: ' + credentials) + print('Failed to authenticate agent credentials: ', credentials, + 'against expected ', vel_username, ':', vel_password) #---------------------------------------------------------------------- # Respond to the caller. @@ -239,9 +220,90 @@ def listener(environ, start_response, schema): } yield json.dumps(req_error) + save_event(body) process_event(body) #-------------------------------------------------------------------------- +# Send event to influxdb +#-------------------------------------------------------------------------- +def save_event(body): + jobj = json.loads(body) + e = json.loads(body, object_hook=JSONObject) + + domain = jobj['event']['commonEventHeader']['domain'] + timestamp = jobj['event']['commonEventHeader']['lastEpochMicrosec'] + agent = jobj['event']['commonEventHeader']['reportingEntityName'].upper( ) + if "VIRT" in agent: + agent = "computehost" + if "VDU1" in agent: + agent = "webserver_1" + if "VDU2" in agent: + agent = "webserver_2" + if "VDU3" in agent: + agent = "loadbalancer" + if "VDU4" in agent: + agent = "firewall" + + if e.event.commonEventHeader.domain == "heartbeat": + print('Found Heartbeat') + pdata = 'heartbeat,system={} sequence={}'.format(agent,e.event.commonEventHeader.sequence) + print(pdata) + r = requests.post("http://localhost:8086/write?db=veseventsdb", data=pdata, headers={'Content-Type': 'text/plain'}) + if r.status_code != 204: + print('*** Failed to add cpu event to influxdb ***') + + if 'measurementsForVfScalingFields' in jobj['event']: + print('Found measurementsForVfScalingFields') + if 'cpuUsageArray' in jobj['event']['measurementsForVfScalingFields']: + if 'additionalFields' in jobj['event']['measurementsForVfScalingFields']: + for f in e.event.measurementsForVfScalingFields.additionalFields: + if f.name == "cpu-aggregation-cpu-average-user-percent-value": + aggregateCpuUsageUser = f.value + if f.name == "cpu-aggregation-cpu-average-system-percent-value": + aggregateCpuUsageSystem = f.value + if f.name == "cpu-aggregation-cpu-average-idle-percent-value": + aggregateCpuIdle = f.value + else: + a = e.event.measurementsForVfScalingFields.cpuUsageArray[0] + aggregateCpuUsageUser = a.cpuUsageUser + aggregateCpuUsageSystem = a.cpuUsageSystem + aggregateCpuIdle = a.cpuIdle + + pdata = 'cpu,system={},cpuid={} cpuuser={},cpusystem={},cpuidle={}'.format(agent,jobj['event']['measurementsForVfScalingFields']['cpuUsageArray'][0]['cpuIdentifier'], aggregateCpuUsageUser,aggregateCpuUsageSystem,aggregateCpuIdle) + print(pdata) + r = requests.post("http://localhost:8086/write?db=veseventsdb", data=pdata, headers={'Content-Type': 'text/plain'}) + if r.status_code != 204: + print('*** Failed to add cpu event to influxdb ***') + + if 'vNicPerformanceArray' in jobj['event']['measurementsForVfScalingFields']: + print('Found vNicPerformanceArray') + vnicn = 1 + for vnic in e.event.measurementsForVfScalingFields.vNicPerformanceArray: + pdata = 'vnic,system={},vnicn={},vnicid={} txoctets={},rxpacketsacc={},rxoctetsacc={},txpacketacc={}'.format(agent,vnicn,vnic.vNicIdentifier,vnic.transmittedOctetsAccumulated,vnic.receivedTotalPacketsAccumulated,vnic.receivedOctetsAccumulated,vnic.transmittedTotalPacketsAccumulated) + print(pdata) + r = requests.post("http://localhost:8086/write?db=veseventsdb", data=pdata, headers={'Content-Type': 'text/plain'}) + if r.status_code != 204: + print('*** Failed to add vnic event to influxdb ***') + vnicn = vnicn + 1 + + if 'vNicUsageArray' in jobj['event']['measurementsForVfScalingFields']: + print('Found vNicUsageArray') + vnic = e.event.measurementsForVfScalingFields.vNicUsageArray[0] + pdata = 'vnic,system={},vnicid={} txoctets={},rxpacketsacc={},rxoctetsacc={},txpacketacc={}'.format(agent,vnic.vNicIdentifier,vnic.transmittedOctetsAccumulated,vnic.receivedTotalPacketsAccumulated,vnic.receivedOctetsAccumulated,vnic.transmittedTotalPacketsAccumulated) + print(pdata) + r = requests.post("http://localhost:8086/write?db=veseventsdb", data=pdata, headers={'Content-Type': 'text/plain'}) + if r.status_code != 204: + print('*** Failed to add vnic event to influxdb ***') + + if 'requestRate' in jobj['event']['measurementsForVfScalingFields']: + print('Found requestRate') + pdata = 'http,system={} httptxrx={}'.format(agent,e.event.measurementsForVfScalingFields.requestRate) + print(pdata) + r = requests.post("http://localhost:8086/write?db=veseventsdb", data=pdata, headers={'Content-Type': 'text/plain'}) + if r.status_code != 204: + print('*** Failed to add http event to influxdb ***') + +#-------------------------------------------------------------------------- # Event processing #-------------------------------------------------------------------------- def process_event(body): @@ -256,42 +318,44 @@ def process_event(body): epoch = e.event.commonEventHeader.lastEpochMicrosec sourceId = e.event.commonEventHeader.sourceId - report_time = time.strftime('%Y-%m-%d %H:%M:%S', + report_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(epoch)/1000000)) - host = e.event.commonEventHeader.reportingEntityName + host = e.event.commonEventHeader.sourceName 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 - + if 'VDU4' in host or 'vdu4' in host: vdu = 4 + domain = e.event.commonEventHeader.domain if domain == 'measurementsForVfScaling': - if vdu >= 1: + if vdu <= 2: requestRate = e.event.measurementsForVfScalingFields.requestRate summary_e[vdu] = host + ": state=" + status[vdu] + ", tps=" + str(requestRate) - else: - aggregateCpuUsage = e.event.measurementsForVfScalingFields.aggregateCpuUsage - vNicUsageArray = e.event.measurementsForVfScalingFields.vNicUsageArray - s = "" - for i in range(1,len(vdu_id)): - if sourceId.upper() in vdu_id[i].upper(): - s = "(VDU"+ str(i) + ") " - if s: - s += host + ": cpu=" + str(aggregateCpuUsage) - found = False - for i in range(1,len(summary_c)): - if host in summary_c[i]: - summary_c[i] = s - found = True - break - if not found: - summary_c.extend([s]) +# else: +# for f in e.event.measurementsForVfScalingFields.additionalFields: +# if f.name == "cpu-aggregation-cpu-average-idle-percent-value": +# aggregateCpuUsage = 100 - float(f.value) +# break +# s = "" +# for i in range(1,len(vdu_id)): +# if sourceName.upper() in vdu_id[i].upper(): +# s = " (VDU"+ str(i) + ") " +# s = host + ": cpu=" + aggregateCpuUsage +# found = False +# for c in summary_c: +# if host in c: +# c = s +# found = True +# break +# if not found: +# summary_c.append(s) for s in summary_e: print '{0}'.format(s) - for s in summary_c: - print '{0}'.format(s) +# for s in summary_c: +# print '{0}'.format(s) if domain == 'fault' and vdu >= 1: alarmCondition = e.event.faultFields.alarmCondition @@ -448,7 +512,7 @@ USAGE help='Display version information') parser.add_argument('-a', '--api-version', dest='api_version', - default='3', + default='5', help='set API version') parser.add_argument('-c', '--config', dest='config', @@ -518,7 +582,7 @@ USAGE #---------------------------------------------------------------------- global logger print('Logfile: {0}'.format(log_file)) - logger = logging.getLogger('collector') + logger = logging.getLogger('monitor') if verbose > 0: print('Verbose mode on') logger.setLevel(logging.DEBUG) diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/start.sh b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/start.sh index 0f27dd3..ad5bf11 100644 --- a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/start.sh +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/start.sh @@ -21,7 +21,8 @@ # How to use: # Intended to be invoked from ves_onap_demo.sh # $ bash start.sh type params -# type: type of VNF component [monitor|collectd] +# type: type of VNF component [webserver|vfw|vlb|monitor|collectd] +# webserver|vfw|vlb| params: ID CollectorIP username password # collector params: ID CollectorIP username password # monitor params: VDU1_ID VDU1_ID VDU1_ID username password # ID: VM ID @@ -51,8 +52,11 @@ setup_collectd () { cd ~ echo "$0: Install VES collectd plugin" - git clone https://git.opnfv.org/barometer - sudo sed -i -- "s/v1/v3/" barometer/3rd_party/collectd-ves-plugin/ves_plugin/ves_plugin.py + # this is a clone of barometer patch https://gerrit.opnfv.org/gerrit/#/c/35489 + git clone https://gerrit.opnfv.org/gerrit/barometer + cd barometer + git pull https://gerrit.opnfv.org/gerrit/barometer refs/changes/89/35489/2 + cd .. sudo sed -i -- "s/FQDNLookup true/FQDNLookup false/" $conf sudo sed -i -- "s/#LoadPlugin cpu/LoadPlugin cpu/" $conf @@ -60,47 +64,8 @@ setup_collectd () { sudo sed -i -- "s/#LoadPlugin interface/LoadPlugin interface/" $conf sudo sed -i -- "s/#LoadPlugin memory/LoadPlugin memory/" $conf - if [[ "$guest" == true ]]; then - cat <<EOF | sudo tee -a $conf -<LoadPlugin python> - Globals true -</LoadPlugin> -<Plugin python> - ModulePath "/home/$USER/barometer/3rd_party/collectd-ves-plugin/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" - GuestRunning true -</Module> -</Plugin> -<Plugin cpu> - ReportByCpu false - ValuesPercentage true -</Plugin> -LoadPlugin aggregation -<Plugin aggregation> - <Aggregation> - Plugin "cpu" - Type "percent" - GroupBy "Host" - GroupBy "TypeInstance" - SetPlugin "cpu-aggregation" - CalculateAverage true - </Aggregation> -</Plugin> -LoadPlugin uuid -EOF - else - cat <<EOF | sudo tee -a $conf + + cat <<EOF | sudo tee -a $conf <LoadPlugin python> Globals true </LoadPlugin> @@ -118,14 +83,13 @@ EOF Username "hello" Password "world" FunctionalRole "Collectd VES Agent" - GuestRunning false </Module> </Plugin> LoadPlugin virt <Plugin virt> Connection "qemu:///system" RefreshInterval 60 - HostnameFormat uuid + HostnameFormat name uuid </Plugin> <Plugin cpu> ReportByCpu false @@ -144,12 +108,12 @@ LoadPlugin aggregation </Plugin> LoadPlugin uuid EOF - fi sudo service collectd restart } -setup_agent () { +vnfc_common() { echo "$0: Install prerequisites" + sudo apt-get update sudo apt-get install -y gcc # NOTE: force is required as some packages can't be authenticated... sudo apt-get install -y --force-yes libcurl4-openssl-dev @@ -157,25 +121,68 @@ setup_agent () { echo "$0: Clone agent library" cd /home/ubuntu + rm -rf evel-library git clone https://github.com/att/evel-library.git - echo "$0: Clone VES repo" - git clone https://gerrit.opnfv.org/gerrit/ves + echo "$0: Update EVEL_API version (workaround until the library is updated)" + sed -i -- "s/#define EVEL_API_MAJOR_VERSION 3/#define EVEL_API_MAJOR_VERSION 5/" evel-library/code/evel_library/evel.h + sed -i -- "s/#define EVEL_API_MINOR_VERSION 0/#define EVEL_API_MINOR_VERSION 0/" evel-library/code/evel_library/evel.h +} - echo "$0: Use ves_onap_demo blueprint version of agent_demo.c" - cp ves/tests/blueprints/tosca-vnfd-onap-demo/evel_demo.c evel-library/code/evel_demo/evel_demo.c +setup_vFW () { + vnfc_common - echo "$0: Build evel_demo agent" - cd evel-library/bldjobs + echo "$0: Build evel_library agent" + cd ~/evel-library/bldjobs make export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ubuntu/evel-library/libs/x86_64 - echo "$0: Start evel_demo agent" + echo "$0: Build agent" + cd ~/tosca-vnfd-onap-demo/vFW + make + + echo "$0: Start agent" + vnic=$(route | grep '^default' | grep -o '[^ ]*$') id=$(cut -d ',' -f 3 /mnt/openstack/latest/meta_data.json | cut -d '"' -f 4) - nohup ../output/x86_64/evel_demo --id $id --fqdn $collector_ip --port 30000 --username $username --password $password -x > /dev/null 2>&1 & + echo "$0: Starting vpp_measurement_reporter $id $collector_ip 30000 $username $password $vnic vLB" + nohup ~/tosca-vnfd-onap-demo/vFW/vpp_measurement_reporter $id $collector_ip 30000 $username $password $vnic vFW -x > /dev/null 2>&1 & +} + +setup_vLB () { + vnfc_common - echo "$0: Start collectd agent running in the VM" - setup_collectd true + echo "$0: Build evel_library agent" + cd ~/evel-library/bldjobs + make + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ubuntu/evel-library/libs/x86_64 + + # TODO: Currently using a single agent for both vFW and vLB as it's all common + # except for DNS-related aspects not yet implemented. + echo "$0: Build agent" + cd ~/tosca-vnfd-onap-demo/vFW + make + + echo "$0: Start agent" + vnic=$(route | grep '^default' | grep -o '[^ ]*$') + id=$(cut -d ',' -f 3 /mnt/openstack/latest/meta_data.json | cut -d '"' -f 4) + echo "$0: Starting vpp_measurement_reporter $id $collector_ip 30000 $username $password $vnic vLB" + nohup ~/tosca-vnfd-onap-demo/vFW/vpp_measurement_reporter $id $collector_ip 30000 $username $password $vnic vLB -x > /dev/null 2>&1 & +} + +setup_webserver () { + vnfc_common + + echo "$0: Use ves_onap_demo blueprint version of agent_demo.c" + cp ~/tosca-vnfd-onap-demo/evel_demo.c ~/evel-library/code/evel_demo/evel_demo.c + + echo "$0: Build agent" + cd ~/evel-library/bldjobs + make + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ubuntu/evel-library/libs/x86_64 + + echo "$0: Start agent" + id=$(cut -d ',' -f 3 /mnt/openstack/latest/meta_data.json | cut -d '"' -f 4) + nohup ../output/x86_64/evel_demo --id $id --fqdn $collector_ip --port 30000 --username $username --password $password -x > ~/evel_demo.log 2>&1 & } setup_monitor () { @@ -189,20 +196,42 @@ setup_monitor () { echo "$0: setup VES Monitor config" sudo mkdir /var/log/att sudo chown ubuntu /var/log/att - touch /var/log/att/collector.log + touch /var/log/att/monitor.log sudo chown ubuntu /home/ubuntu/ cd /home/ubuntu/ git clone https://github.com/att/evel-test-collector.git - sed -i -- "s/vel_username = /vel_username = $username/" evel-test-collector/config/collector.conf - sed -i -- "s/vel_password = /vel_password = $password/" evel-test-collector/config/collector.conf - sed -i -- "s~vel_path = vendor_event_listener/~vel_path = ~" evel-test-collector/config/collector.conf - sed -i -- "s/vel_topic_name = example_vnf/vel_topic_name = /" evel-test-collector/config/collector.conf + sed -i -- "s/vel_username =/vel_username = $username/g" evel-test-collector/config/collector.conf + sed -i -- "s/vel_password =/vel_password = $password/g" evel-test-collector/config/collector.conf + sed -i -- "s~vel_path = vendor_event_listener/~vel_path = ~g" evel-test-collector/config/collector.conf + sed -i -- "s/vel_topic_name = example_vnf/vel_topic_name = /g" evel-test-collector/config/collector.conf + sed -i -- "/vel_topic_name = /a vdu4_id = $vdu4_id" evel-test-collector/config/collector.conf sed -i -- "/vel_topic_name = /a vdu3_id = $vdu3_id" evel-test-collector/config/collector.conf sed -i -- "/vel_topic_name = /a vdu2_id = $vdu2_id" evel-test-collector/config/collector.conf sed -i -- "/vel_topic_name = /a vdu1_id = $vdu1_id" evel-test-collector/config/collector.conf - cp monitor.py evel-test-collector/code/collector/monitor.py - nohup python evel-test-collector/code/collector/monitor.py --config evel-test-collector/config/collector.conf --section default > /home/ubuntu/monitor.log + echo "$0: install influxdb and python influxdb library" + sudo apt-get install -y influxdb + sudo service influxdb start + sudo apt-get install -y python-influxdb + + echo "$0: install grafana" + sudo apt-get install -y grafana + sudo service grafana-server start + sudo update-rc.d grafana-server defaults + + echo "$0: Setup InfluxDB datatabase" + python tosca-vnfd-onap-demo/infsetup.py + + echo "$0: Add datasource to grafana" + curl http://admin:admin@localhost:3000/api/datasources + curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"VESEvents","type":"influxdb","access":"direct","url":"http://localhost:8086","password":"root","user":"root","database":"veseventsdb","basicAuth":false,"basicAuthUser":"","basicAuthPassword":"","withCredentials":false,"isDefault":false,"jsonData":null}' \ + http://admin:admin@localhost:3000/api/datasources + + echo "$0: Import Dashboard.json into grafana" + curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d @tosca-vnfd-onap-demo/Dashboard.json http://admin:admin@localhost:3000/api/dashboards/db + + cp tosca-vnfd-onap-demo/monitor.py evel-test-collector/code/collector/monitor.py + nohup python evel-test-collector/code/collector/monitor.py --config evel-test-collector/config/collector.conf --section default > ~/monitor.log 2>&1 & } type=$1 @@ -211,13 +240,13 @@ if [[ "$type" == "monitor" ]]; then vdu1_id=$2 vdu2_id=$3 vdu3_id=$4 - username=$5 - password=$6 + vdu4_id=$5 + username=$6 + password=$7 else - vm_id=$2 - collector_ip=$3 - username=$4 - password=$5 + collector_ip=$2 + username=$3 + password=$4 fi setup_$type $1 diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vFW/Makefile b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vFW/Makefile new file mode 100644 index 0000000..ebe8050 --- /dev/null +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vFW/Makefile @@ -0,0 +1,44 @@ +############################################################################# +# +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# +# 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. +# +############################################################################# + +CC=gcc +ARCH=$(shell getconf LONG_BIT) +CODE_ROOT=/home/ubuntu/evel-library +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: vpp_measurement_reporter + +clean: + rm -f vpp_measurement_reporter + +vpp_measurement_reporter: vpp_measurement_reporter.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o vpp_measurement_reporter \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + vpp_measurement_reporter.c \ + -lpthread \ + -level \ + -lcurl + + diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vFW/vpp_measurement_reporter.c b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vFW/vpp_measurement_reporter.c new file mode 100644 index 0000000..f41b50a --- /dev/null +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vFW/vpp_measurement_reporter.c @@ -0,0 +1,357 @@ + +/*************************************************************************//** + * + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + * + ****************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/time.h> + +#include "evel.h" + +#define BUFSIZE 128 +#define READ_INTERVAL 10 + +typedef struct dummy_vpp_metrics_struct { + int bytes_in; + int bytes_out; + int packets_in; + int packets_out; +} vpp_metrics_struct; + +void read_vpp_metrics(vpp_metrics_struct *, char *); + +unsigned long long epoch_start = 0; + +#ifdef DOCKER +int measure_traffic() +{ + + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + FILE *fp; + int status; + char count[10]; + time_t rawtime; + struct tm * timeinfo; + char period [21]; + char cmd [100]; + int concurrent_sessions = 0; + int configured_entities = 0; + double mean_request_latency = 0; + double measurement_interval = 1; + double memory_configured = 0; + double memory_used = 0; + int request_rate=0; + char secs [3]; + int sec; + double loadavg; + + printf("Checking app traffic\n"); + time (&rawtime); + timeinfo = localtime (&rawtime); + strftime(period,21,"%d/%b/%Y:%H:%M:",timeinfo); + strftime(secs,3,"%S",timeinfo); + sec = atoi(secs); + if (sec == 0) sec = 59; + sprintf(secs, "%02d", sec); + strncat(period, secs, 21); + // ....x....1....x....2. + // 15/Oct/2016:17:51:19 + strcpy(cmd, "sudo docker logs vHello | grep -c "); + strncat(cmd, period, 100); + + fp = popen(cmd, "r"); + if (fp == NULL) { + EVEL_ERROR("popen failed to execute command"); + } + + if (fgets(count, 10, fp) != NULL) { + request_rate = atoi(count); + printf("Reporting request rate for second: %s as %d\n", period, request_rate); + + } + else { + EVEL_ERROR("New Measurement failed"); + } + printf("Processed measurement\n"); + + status = pclose(fp); + if (status == -1) { + EVEL_ERROR("pclose returned an error"); + } + return request_rate; +} + +#endif + + + +/**************************************************************************//** + * tap live cpu stats + *****************************************************************************/ +void evel_get_cpu_stats(EVENT_MEASUREMENT * measurement) +{ + FILE *fp; + char path[1024]; + double usage=0.0; + double idle; + double intrpt; + double nice; + double softirq; + double steal; + double sys; + double user; + double wait; + MEASUREMENT_CPU_USE *cpu_use = NULL; + + /* Open the command for reading. */ + //fp = popen("/bin/ls /etc/", "r"); + fp = popen("/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 ", "r"); + if (fp == NULL) { + printf("Failed to run command\n" ); + exit(1); + } + + /* Read the output a line at a time - output it. */ + while (fgets(path, sizeof(path)-1, fp) != NULL) { + printf("%s", path+10); + sscanf(path+10," %lf us, %lf sy, %lf ni, %lf id, %lf wa, %lf hi, %lf si, %lf st", + &user,&sys,&nice,&idle,&wait,&intrpt,&softirq,&steal); + } + + /* close */ + pclose(fp); + + cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", usage); + if( cpu_use != NULL ){ + evel_measurement_cpu_use_idle_set(cpu_use,idle); + //evel_measurement_cpu_use_interrupt_set(cpu_use,intrpt); + //evel_measurement_cpu_use_nice_set(cpu_use,nice); + //evel_measurement_cpu_use_softirq_set(cpu_use,softirq); + //evel_measurement_cpu_use_steal_set(cpu_use,steal); + evel_measurement_cpu_use_system_set(cpu_use,sys); + evel_measurement_cpu_use_usageuser_set(cpu_use,user); + //evel_measurement_cpu_use_wait_set(cpu_use,wait); + //evel_measurement_cpu_use_add(measurement, "cpu2", usage,idle,intrpt,nice,softirq,steal,sys,user,wait); + } +} + +int main(int argc, char** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_MEASUREMENT* vpp_m = NULL; + EVENT_HEADER* vpp_m_header = NULL; + int bytes_in_this_round; + int bytes_out_this_round; + int packets_in_this_round; + int packets_out_this_round; + vpp_metrics_struct* last_vpp_metrics = malloc(sizeof(vpp_metrics_struct)); + vpp_metrics_struct* curr_vpp_metrics = malloc(sizeof(vpp_metrics_struct)); + struct timeval time_val; + //time_t start_epoch; + //time_t last_epoch; + char hostname[BUFSIZE]; + char* api_vmid = argv[1]; + char* api_fqdn = argv[2]; + int api_port = atoi(argv[3]); + char* api_username = argv[4]; + char* api_password = argv[5]; + char* vnic = argv[6]; + char* api_role = argv[7]; + MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL; + //struct timeval tv_start; + + printf("\nVector Packet Processing (VPP) measurement collection\n"); + fflush(stdout); + + fprintf(stderr, "%i parameters: %s %s %i %s %s %s %s\n", argc, api_vmid, api_fqdn, api_port, api_username, api_password, vnic, api_role); + + /**************************************************************************/ + /* Initialize */ + /**************************************************************************/ + if(evel_initialize(api_fqdn, /* fqdn */ + api_port, /* port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + api_username, /* Username */ + api_password, /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + api_role, /* Role */ + 1)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + gethostname(hostname, BUFSIZE); + memset(last_vpp_metrics, 0, sizeof(vpp_metrics_struct)); + read_vpp_metrics(last_vpp_metrics, vnic); + gettimeofday(&time_val, NULL); + epoch_start = time_val.tv_sec * 1000000 + time_val.tv_usec; + sleep(READ_INTERVAL); + + /***************************************************************************/ + /* Collect metrics from the VNIC */ + /***************************************************************************/ + while(1) { + memset(curr_vpp_metrics, 0, sizeof(vpp_metrics_struct)); + read_vpp_metrics(curr_vpp_metrics, vnic); + + if(curr_vpp_metrics->bytes_in - last_vpp_metrics->bytes_in > 0) { + bytes_in_this_round = curr_vpp_metrics->bytes_in - last_vpp_metrics->bytes_in; + } + else { + bytes_in_this_round = 0; + } + if(curr_vpp_metrics->bytes_out - last_vpp_metrics->bytes_out > 0) { + bytes_out_this_round = curr_vpp_metrics->bytes_out - last_vpp_metrics->bytes_out; + } + else { + bytes_out_this_round = 0; + } + if(curr_vpp_metrics->packets_in - last_vpp_metrics->packets_in > 0) { + packets_in_this_round = curr_vpp_metrics->packets_in - last_vpp_metrics->packets_in; + } + else { + packets_in_this_round = 0; + } + if(curr_vpp_metrics->packets_out - last_vpp_metrics->packets_out > 0) { + packets_out_this_round = curr_vpp_metrics->packets_out - last_vpp_metrics->packets_out; + } + else { + packets_out_this_round = 0; + } + + vpp_m = evel_new_measurement(READ_INTERVAL); + vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance(vnic, "true"); + evel_meas_vnic_performance_add(vpp_m, vnic_performance); + + if(vpp_m != NULL) { + printf("New measurement report created...\n"); + + evel_measurement_type_set(vpp_m, "HTTP request rate"); + evel_measurement_request_rate_set(vpp_m, rand()%10000); + + evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, packets_in_this_round); + evel_vnic_performance_tx_total_pkt_acc_set(vnic_performance, packets_out_this_round); + + evel_vnic_performance_rx_octets_acc_set(vnic_performance, bytes_in_this_round); + evel_vnic_performance_tx_octets_acc_set(vnic_performance, bytes_out_this_round); + evel_get_cpu_stats(vpp_m); + + /***************************************************************************/ + /* Set parameters in the MEASUREMENT header packet */ + /***************************************************************************/ + struct timeval tv_now; + gettimeofday(&tv_now, NULL); + unsigned long long epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec; + + //last_epoch = start_epoch + READ_INTERVAL * 1000000; + vpp_m_header = (EVENT_HEADER *)vpp_m; + //vpp_m_header->start_epoch_microsec = start_epoch; + //vpp_m_header->last_epoch_microsec = last_epoch; + evel_start_epoch_set(&vpp_m->header, epoch_start); + evel_last_epoch_set(&vpp_m->header, epoch_now); + epoch_start = epoch_now; + + evel_reporting_entity_id_set(&vpp_m->header, api_vmid); + evel_reporting_entity_name_set(&vpp_m->header, hostname); + evel_rc = evel_post_event(vpp_m_header); + + if(evel_rc == EVEL_SUCCESS) { + printf("Measurement report correctly sent to the collector!\n"); + } + else { + printf("Post failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else { + printf("New measurement report failed (%s)\n", evel_error_string()); + } + + last_vpp_metrics->bytes_in = curr_vpp_metrics->bytes_in; + last_vpp_metrics->bytes_out = curr_vpp_metrics->bytes_out; + last_vpp_metrics->packets_in = curr_vpp_metrics->packets_in; + last_vpp_metrics->packets_out = curr_vpp_metrics->packets_out; + //gettimeofday(&time_val, NULL); + //start_epoch = time_val.tv_sec * 1000000 + time_val.tv_usec; + + sleep(READ_INTERVAL); + } + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + free(last_vpp_metrics); + free(curr_vpp_metrics); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +void read_vpp_metrics(vpp_metrics_struct *vpp_metrics, char *vnic) { + // Define an array of char that contains the parameters of the unix 'cut' command + char* params[] = {"-f3", "-f11", "-f4", "-f12"}; + // Define the unix command to execute in order to read metrics from the vNIC + char* cmd_prefix = "sudo cat /proc/net/dev | grep \""; + char* cmd_mid = "\" | tr -s \' \' | cut -d\' \' "; + char cmd[BUFSIZE]; + // Define other variables + char buf[BUFSIZE]; /* buffer used to store VPP metrics */ + int temp[] = {0, 0, 0, 0}; /* temp array that contains VPP values */ + FILE *fp; /* file descriptor to pipe cmd to shell */ + int i; + + for(i = 0; i < 4; i++) { + // Clear buffers + memset(buf, 0, BUFSIZE); + memset(cmd, 0, BUFSIZE); + // Build shell command to read metrics from the vNIC + strcat(cmd, cmd_prefix); + strcat(cmd, vnic); + strcat(cmd, cmd_mid); + strcat(cmd, params[i]); + + // Open a pipe and read VPP values + if ((fp = popen(cmd, "r")) == NULL) { + printf("Error opening pipe!\n"); + return; + } + + while (fgets(buf, BUFSIZE, fp) != NULL); + temp[i] = atoi(buf); + + if(pclose(fp)) { + printf("Command not found or exited with error status\n"); + return; + } + } + + // Store metrics read from the vNIC in the struct passed from the main function + vpp_metrics->bytes_in = temp[0]; + vpp_metrics->bytes_out = temp[1]; + vpp_metrics->packets_in = temp[2]; + vpp_metrics->packets_out = temp[3]; +} diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vLB/Makefile b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vLB/Makefile new file mode 100644 index 0000000..8ecbffd --- /dev/null +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vLB/Makefile @@ -0,0 +1,41 @@ + +############################################################################# +# +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# +# 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. +# +############################################################################# + +CC=gcc +ARCH=$(shell getconf LONG_BIT) +#CODE_ROOT=$(CURDIR)/../../.. +CODE_ROOT=../VES/evel/evel-library +LIBS_DIR=$(CODE_ROOT)/libs/x86_$(ARCH) +INCLUDE_DIR=$(CODE_ROOT)/code/evel_library + +#****************************************************************************** +# Standard compiler flags. * +#****************************************************************************** +CPPFLAGS= +CFLAGS=-Wall -g -fPIC + +all: vpp_measurement_reporter + +clean: + rm -f vpp_measurement_reporter + +vpp_measurement_reporter: vpp_measurement_reporter.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o vpp_measurement_reporter \ + -L $(LIBS_DIR) \ + -I $(INCLUDE_DIR) \ + vpp_measurement_reporter.c -lm -lpthread -level -lcurl diff --git a/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vLB/vDNS_vpp_measurement_reporter.c b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vLB/vDNS_vpp_measurement_reporter.c new file mode 100644 index 0000000..ca6a7cd --- /dev/null +++ b/tests/onap-demo/blueprints/tosca-vnfd-onap-demo/vLB/vDNS_vpp_measurement_reporter.c @@ -0,0 +1,376 @@ + +/*************************************************************************//** + * + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + * + ****************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/time.h> +#include <math.h> + +#include "evel.h" + +#define BUFSIZE 128 +#define READ_INTERVAL 10 + +typedef struct dummy_vpp_metrics_struct { + int bytes_in; + int bytes_out; + int packets_in; + int packets_out; +} vpp_metrics_struct; + +void read_vpp_metrics(vpp_metrics_struct *, char *); + +unsigned long long epoch_start = 0; + + +#ifdef DOCKER +int measure_traffic() +{ + + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + FILE *fp; + int status; + char count[10]; + time_t rawtime; + struct tm * timeinfo; + char period [21]; + char cmd [100]; + int concurrent_sessions = 0; + int configured_entities = 0; + double mean_request_latency = 0; + double measurement_interval = 1; + double memory_configured = 0; + double memory_used = 0; + int request_rate=0; + char secs [3]; + int sec; + double loadavg; + + printf("Checking app traffic\n"); + time (&rawtime); + timeinfo = localtime (&rawtime); + strftime(period,21,"%d/%b/%Y:%H:%M:",timeinfo); + strftime(secs,3,"%S",timeinfo); + sec = atoi(secs); + if (sec == 0) sec = 59; + sprintf(secs, "%02d", sec); + strncat(period, secs, 21); + // ....x....1....x....2. + // 15/Oct/2016:17:51:19 + strcpy(cmd, "sudo docker logs vHello | grep -c "); + strncat(cmd, period, 100); + + fp = popen(cmd, "r"); + if (fp == NULL) { + EVEL_ERROR("popen failed to execute command"); + } + + if (fgets(count, 10, fp) != NULL) { + request_rate = atoi(count); + printf("Reporting request rate for second: %s as %d\n", period, request_rate); + + } + else { + EVEL_ERROR("New Measurement failed"); + } + printf("Processed measurement\n"); + + status = pclose(fp); + if (status == -1) { + EVEL_ERROR("pclose returned an error"); + } + return request_rate; +} + +#endif + + + +/**************************************************************************//** + * tap live cpu stats + *****************************************************************************/ +void evel_get_cpu_stats(EVENT_MEASUREMENT * measurement) +{ + FILE *fp; + char path[1024]; + double usage=0.0; + double idle; + double intrpt; + double nice; + double softirq; + double steal; + double sys; + double user; + double wait; + MEASUREMENT_CPU_USE *cpu_use = NULL; + + /* Open the command for reading. */ + //fp = popen("/bin/ls /etc/", "r"); + fp = popen("/usr/bin/top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 ", "r"); + if (fp == NULL) { + printf("Failed to run command\n" ); + exit(1); + } + + /* Read the output a line at a time - output it. */ + while (fgets(path, sizeof(path)-1, fp) != NULL) { + printf("%s", path+10); + sscanf(path+10," %lf us, %lf sy, %lf ni, %lf id, %lf wa, %lf hi, %lf si, %lf st", + &user,&sys,&nice,&idle,&wait,&intrpt,&softirq,&steal); + } + + /* close */ + pclose(fp); + + cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", usage); + if( cpu_use != NULL ){ + evel_measurement_cpu_use_idle_set(cpu_use,idle); + //evel_measurement_cpu_use_interrupt_set(cpu_use,intrpt); + //evel_measurement_cpu_use_nice_set(cpu_use,nice); + //evel_measurement_cpu_use_softirq_set(cpu_use,softirq); + //evel_measurement_cpu_use_steal_set(cpu_use,steal); + evel_measurement_cpu_use_system_set(cpu_use,sys); + evel_measurement_cpu_use_usageuser_set(cpu_use,user); + //evel_measurement_cpu_use_wait_set(cpu_use,wait); + //evel_measurement_cpu_use_add(measurement, "cpu2", usage,idle,intrpt,nice,softirq,steal,sys,user,wait); + } +} + +int main(int argc, char** argv) +{ + EVEL_ERR_CODES evel_rc = EVEL_SUCCESS; + EVENT_MEASUREMENT* vpp_m = NULL; + EVENT_HEADER* vpp_m_header = NULL; + int bytes_in_this_round; + int bytes_out_this_round; + int packets_in_this_round; + int packets_out_this_round; + vpp_metrics_struct* last_vpp_metrics = malloc(sizeof(vpp_metrics_struct)); + vpp_metrics_struct* curr_vpp_metrics = malloc(sizeof(vpp_metrics_struct)); + struct timeval time_val; + //time_t start_epoch; + //time_t last_epoch; + char hostname[BUFSIZE]; + char* api_vmid = argv[1]; + char* api_fqdn = argv[2]; + int api_port = atoi(argv[3]); + char* api_username = argv[4]; + char* api_password = argv[5]; + char* vnic = argv[6]; + MEASUREMENT_VNIC_PERFORMANCE * vnic_performance = NULL; + //struct timeval tv_start; + + printf("\nVector Packet Processing (VPP) measurement collection\n"); + fflush(stdout); + + if (argc != 4) + { + fprintf(stderr, "Usage: %s <vmid> <fqdn>|<IP address> <port> <interface> <username> <password> <vnic>\n", argv[0]); + exit(-1); + } + srand(time(NULL)); + + /**************************************************************************/ + /* Initialize */ + /**************************************************************************/ + if(evel_initialize(api_fqdn, /* fqdn */ + api_port, /* port */ + NULL, /* optional path */ + NULL, /* optional topic */ + 0, /* HTTPS? */ + api_username, /* Username */ + api_password, /* Password */ + EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */ + "vFirewall", /* Role */ + 1)) /* Verbosity */ + { + fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n"); + exit(-1); + } + else + { + printf("\nInitialization completed\n"); + } + + gethostname(hostname, BUFSIZE); + memset(last_vpp_metrics, 0, sizeof(vpp_metrics_struct)); + read_vpp_metrics(last_vpp_metrics, vnic); + gettimeofday(&time_val, NULL); + epoch_start = time_val.tv_sec * 1000000 + time_val.tv_usec; + sleep(READ_INTERVAL); + + /***************************************************************************/ + /* Collect metrics from the VNIC */ + /***************************************************************************/ + while(1) { + // Read the number of vDNSs currently active + int active_dns = 0; + FILE* fd = fopen("active_dns.txt", "r"); + while(!feof(fd)) { + if(fscanf(fd, "%d", &active_dns) != 1) /* Avoid infinite loops if the file doesn't contain exactly one number */ + break; + } + + if(fclose(fd)) { + printf("Error when closing file\n"); + return 1; + } + + memset(curr_vpp_metrics, 0, sizeof(vpp_metrics_struct)); + read_vpp_metrics(curr_vpp_metrics, vnic); + + if(active_dns > 0 && (curr_vpp_metrics->bytes_in - last_vpp_metrics->bytes_in > 0)) { + bytes_in_this_round = (int) round((curr_vpp_metrics->bytes_in - last_vpp_metrics->bytes_in) / active_dns); + } + else { + bytes_in_this_round = 0; + } + if(active_dns > 0 && (curr_vpp_metrics->bytes_out - last_vpp_metrics->bytes_out > 0)) { + bytes_out_this_round = (int) round((curr_vpp_metrics->bytes_out - last_vpp_metrics->bytes_out) / active_dns); + } + else { + bytes_out_this_round = 0; + } + if(active_dns > 0 && (curr_vpp_metrics->packets_in - last_vpp_metrics->packets_in > 0)) { + packets_in_this_round = (int) round((curr_vpp_metrics->packets_in - last_vpp_metrics->packets_in) / active_dns); + } + else { + packets_in_this_round = 0; + } + if(active_dns > 0 && (curr_vpp_metrics->packets_out - last_vpp_metrics->packets_out > 0)) { + packets_out_this_round = (int) round((curr_vpp_metrics->packets_out - last_vpp_metrics->packets_out) / active_dns); + } + else { + packets_out_this_round = 0; + } + + vpp_m = evel_new_measurement(READ_INTERVAL); + vnic_performance = (MEASUREMENT_VNIC_PERFORMANCE *)evel_measurement_new_vnic_performance(vnic, "true"); + evel_meas_vnic_performance_add(vpp_m, vnic_performance); + + if(vpp_m != NULL) { + printf("New measurement report created...\n"); + + evel_measurement_type_set(vpp_m, "HTTP request rate"); + evel_measurement_request_rate_set(vpp_m, rand()%10000); + + evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, packets_in_this_round); + evel_vnic_performance_tx_total_pkt_acc_set(vnic_performance, packets_out_this_round); + + evel_vnic_performance_rx_octets_acc_set(vnic_performance, bytes_in_this_round); + evel_vnic_performance_tx_octets_acc_set(vnic_performance, bytes_out_this_round); + + /***************************************************************************/ + /* Set parameters in the MEASUREMENT header packet */ + /***************************************************************************/ + struct timeval tv_now; + gettimeofday(&tv_now, NULL); + unsigned long long epoch_now = tv_now.tv_usec + 1000000 * tv_now.tv_sec; + + //last_epoch = start_epoch + READ_INTERVAL * 1000000; + vpp_m_header = (EVENT_HEADER *)vpp_m; + //vpp_m_header->start_epoch_microsec = start_epoch; + //vpp_m_header->last_epoch_microsec = last_epoch; + evel_start_epoch_set(&vpp_m->header, epoch_start); + evel_last_epoch_set(&vpp_m->header, epoch_now); + epoch_start = epoch_now; + + evel_reporting_entity_id_set(&vpp_m->header, api_vmid); + evel_reporting_entity_name_set(&vpp_m->header, hostname); + evel_rc = evel_post_event(vpp_m_header); + + if(evel_rc == EVEL_SUCCESS) { + printf("Measurement report correctly sent to the collector!\n"); + } + else { + printf("Post failed %d (%s)\n", evel_rc, evel_error_string()); + } + } + else { + printf("New measurement report failed (%s)\n", evel_error_string()); + } + + last_vpp_metrics->bytes_in = curr_vpp_metrics->bytes_in; + last_vpp_metrics->bytes_out = curr_vpp_metrics->bytes_out; + last_vpp_metrics->packets_in = curr_vpp_metrics->packets_in; + last_vpp_metrics->packets_out = curr_vpp_metrics->packets_out; + //gettimeofday(&time_val, NULL); + //start_epoch = time_val.tv_sec * 1000000 + time_val.tv_usec; + + sleep(READ_INTERVAL); + } + + /***************************************************************************/ + /* Terminate */ + /***************************************************************************/ + sleep(1); + evel_free_measurement(vpp_m); + free(last_vpp_metrics); + free(curr_vpp_metrics); + evel_terminate(); + printf("Terminated\n"); + + return 0; +} + +void read_vpp_metrics(vpp_metrics_struct *vpp_metrics, char *vnic) { + // Define an array of char that contains the parameters of the unix 'cut' command + char* params[] = {"-f3", "-f11", "-f4", "-f12"}; + // Define the unix command to execute in order to read metrics from the vNIC + char* cmd_prefix = "sudo cat /proc/net/dev | grep \""; + char* cmd_mid = "\" | tr -s \' \' | cut -d\' \' "; + char cmd[BUFSIZE]; + // Define other variables + char buf[BUFSIZE]; /* buffer used to store VPP metrics */ + int temp[] = {0, 0, 0, 0}; /* temp array that contains VPP values */ + FILE *fp; /* file descriptor to pipe cmd to shell */ + int i; + + for(i = 0; i < 4; i++) { + // Clear buffers + memset(buf, 0, BUFSIZE); + memset(cmd, 0, BUFSIZE); + // Build shell command to read metrics from the vNIC + strcat(cmd, cmd_prefix); + strcat(cmd, vnic); + strcat(cmd, cmd_mid); + strcat(cmd, params[i]); + + // Open a pipe and read VPP values + if ((fp = popen(cmd, "r")) == NULL) { + printf("Error opening pipe!\n"); + return; + } + + while (fgets(buf, BUFSIZE, fp) != NULL); + temp[i] = atoi(buf); + + if(pclose(fp)) { + printf("Command not found or exited with error status\n"); + return; + } + } + + // Store metrics read from the vNIC in the struct passed from the main function + vpp_metrics->bytes_in = temp[0]; + vpp_metrics->bytes_out = temp[1]; + vpp_metrics->packets_in = temp[2]; + vpp_metrics->packets_out = temp[3]; +} diff --git a/tests/onap-demo/ves_onap_demo.sh b/tests/onap-demo/ves_onap_demo.sh index c4ee2e4..67e8daa 100644 --- a/tests/onap-demo/ves_onap_demo.sh +++ b/tests/onap-demo/ves_onap_demo.sh @@ -40,37 +40,95 @@ # # Status: this is a work in progress, under test. # -# How to use: -# $ git clone https://gerrit.opnfv.org/gerrit/ves -# $ cd ves/tests/onap-demo -# $ bash ves_onap_demo.sh setup <openrc> [branch] -# setup: setup test environment -# <openrc>: location of OpenStack openrc file -# branch: OpenStack branch of Tacker to install (default: master) -# $ bash ves_onap_demo.sh start -# start: install blueprint and run test -# $ bash ves_onap_demo.sh start_collectd|stop_collectd <hpv_ip> <user> <mon_ip> -# start_collectd: install and start collectd daemon on hypervisor -# stop_collectd: stop and uninstall collectd daemon on hypervisor -# <hpv_ip>: hypervisor ip -# <user>: username on hypervisor hosts, for ssh (user must be setup for -# key-based auth on the hosts) -# <mon_ip>: IP address of VES monitor -# $ bash ves_onap_demo.sh monitor <mon_ip> -# monitor: attach to the collector VM and run the VES Monitor -# <mon_ip>: IP address of VDU4 (monitor VM) -# $ bash ves_onap_demo.sh traffic <ip> -# traffic: generate some traffic -# <ip>: address of server -# $ bash ves_onap_demo.sh pause <ip> -# pause: pause the VNF (web server) for a minute to generate a state change -# <ip>: address of server -# $ bash ves_onap_demo.sh stop -# stop: stop test and uninstall blueprint -# $ bash ves_onap_demo.sh clean <hpvuser> <hpvpw> -# clean: cleanup after test -# <hpvuser>: username on hypervisor -# <hpvpw>: password on hypervisor +# Prerequisites: +# OPNFV install per JOID or Apex installers. +# OpenStack client installed and authorized on the jumphost (needed for +# client commands executed on the jumphost). +# For actions on the baremetal compute hosts +# User must be setup for key auth. Copy your public key to the host and +# save in /home/<user>/.ssh/authorized_keys in advance. +# For Apex, user is heat-admin +# For JOID, user is ubuntu +# +# Starting from the OPNFV system deployed and OSC clients installed in a +# virtualenv, an example set of prerequisite actions prior to running the +# test on the jumphost: +# source ~/venv/bin/activate; # activate virtualenv where OSC are installed +# source ~/admin-openrc.sh; # setup OpenStack client env +# cd ves/tests/onap-demo/; # go to the test folder +# eval `ssh-agent` # prepare to add compute host ssh key +# ssh-add ~/.ssh/heat-admin # add compute host ssh key (example for Apex, +# # previously copied from the undercloud) +# +#. How to use: +#. SSH to the jumphost with no SSH forwarding active. +#. $ git clone https://gerrit.opnfv.org/gerrit/ves +#. $ cd ves/tests/onap-demo +#. As a typical sequence, enter the commands (adapted to your environment) per +#. the detailed options below: +#. $ bash ves_onap_demo.sh setup ~/admin-openrc.sh stable/newton +#. $ bash ves_onap_demo.sh start +#. In a new terminal window, setup SSH port forwarding for the monitor VM as +#. described below and SSH to the jumphost. +#. $ cd ves/tests/onap-demo/; +#. $ bash ves_onap_demo.sh start agent all 192.168.37.17 heat-admin +#. When done with testing: +#. $ bash ves_onap_demo.sh stop +#. $ bash ves_onap_demo.sh clean +#. +#. Detailed command options: +#. +#. $ bash ves_onap_demo.sh setup <openrc> [branch] +#. setup: setup test environment +#. <openrc>: location of OpenStack openrc file +#. branch: OpenStack branch of Tacker to install (default: master) +#. $ bash ves_onap_demo.sh start [agent] [all|n] [ip] [user] +#. start: install blueprint +#. agent: only start the indicated agent(s) +#. all: all agents +#. n: agent number (1,2,3,4,5) +#. ip: for agent 5 actions, ip of the host +#. user: for compute host actions, ssh user on hosts +#. $ bash ves_onap_demo.sh monitor +#. monitor: attach to the collector VM and run the VES Monitor +#. $ bash ves_onap_demo.sh traffic <n> +#. traffic: generate some traffic +#. n: VDU number (1,2,3,4) +#. $ bash ves_onap_demo.sh pause <1|2> +#. pause: pause the VNF (web server) for a minute to generate a state change +#. 1|2: pause webserver_1 or webserver_2 +#. $ bash ves_onap_demo.sh stop [agent] [all|n] [ip] [user] +#. stop: stop test and uninstall blueprint +#. agent: only stop the indicated agent(s) +#. all: all agents +#. n: agent number (1,2,3,4,5) +#. ip: for agent 5 actions, ip of the host +#. user: for compute host actions, ssh user on hosts +#. $ bash ves_onap_demo.sh clean +#. clean: cleanup after tests +#. $ bash ves_onap_demo.sh ssh [n] +#. n: VDU number (1,2,3,4,5) +# +# If you access the deployment jumphost via SSH, to access the InfluxDB and +# Grafana dashboards, when blueprint deploymement is complete you will need to +# first add forwarding rules to your ~/.ssh/config file before ssh'ing to the +# jumphost. +# +# Host * +# AddressFamily inet +# +# Host (name of your jumphost) +# Hostname (host IP) +# User (your username) +# LocalForward 8086 (monitor VM IP):8086 +# LocalForward 8080 (monitor VM IP):8080 +# LocalForward 8083 (monitor VM IP):8083 +# LocalForward 3000 (monitor VM IP):3000 +# +# Then SSH to the jumphost: ssh (name of your jumphost from the config file) +# To access Grafana: http://localhost:3000 (admin/admin) +# To access InfluxDB: http://localhost:8083/# +# trap 'fail' ERR @@ -142,8 +200,11 @@ setup () { source /opt/tacker/admin-openrc.sh chmod 755 /opt/tacker/*.sh - echo "$0: $(date) tacker-setup part 1 fetching script from Models" + echo "$0: $(date) tacker-setup part 1 fetching tacker-setup script and tacker.conf.sample from Models" + if [ -a /tmp/tacker-setup.sh ]; then sudo rm /tmp/tacker-setup.sh; fi + if [ -a /tmp/tacker.conf.sample ]; then sudo rm /tmp/tacker.conf.sample; fi wget https://git.opnfv.org/models/plain/tests/utils/tacker-setup.sh -O /tmp/tacker-setup.sh + wget https://git.opnfv.org/models/plain/tests/utils/tacker/tacker.conf.sample -O /tmp/tacker.conf.sample bash /tmp/tacker-setup.sh init if [ $? -eq 1 ]; then fail; fi @@ -160,6 +221,16 @@ setup () { fi assert "ves-onap-demo-tacker-001 (Tacker installation in a Docker container on the jumphost)" true + + echo "$0: $(date) Create Nova key pair" + if [[ -f ~/onap-demo ]]; then rm ~/onap-demo; fi + ssh-keygen -t rsa -N "" -f ~/onap-demo -C ubuntu@onap-demo + chmod 600 ~/onap-demo + openstack keypair create --public-key ~/onap-demo.pub onap-demo + assert "onap-demo-nova-001 (Keypair creation)" true + + cp ~/onap-demo /opt/tacker/onap-demo + cp ~/onap-demo.pub /opt/tacker/onap-demo.pub } say_hello() { @@ -168,7 +239,7 @@ say_hello() { count=10 while [[ $count -gt 0 && $pass != true ]] do - sleep 30 + sleep 60 let count=$count-1 if [[ $(curl $1 | grep -c "Hello World") -gt 0 ]]; then echo "$0: $(date) Hello World found at $1" @@ -189,55 +260,133 @@ copy_blueprint() { echo "$0: $(date) copy tosca-vnfd-onap-demo to blueprints folder" if [[ ! -d /opt/tacker/blueprints ]]; then mkdir /opt/tacker/blueprints; fi - cp -r blueprints/tosca-vnfd-onap-demo /opt/tacker/blueprints/tosca-vnfd-onap-demo + cp -r blueprints/tosca-vnfd-onap-demo /opt/tacker/blueprints +} + +ssh_to_vdu() { + get_vdu_ip $1 + ssh -t -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip +} + +start_agent() { + get_vdu_ip 5 + mon_ip=$ip + if [[ $1 == 5 ]]; then + # NOTE: ensure hypervisor hostname is resolvable e.g. thru /etc/hosts + echo "$0: $(date) start collectd agent on bare metal hypervisor host" + scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + blueprints/tosca-vnfd-onap-demo/start.sh $3@$2:/home/$3/start.sh + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $3@$2 \ + "nohup bash start.sh collectd $mon_ip hello world > /dev/null 2>&1 &" + else + get_vdu_ip $1 + scp -r -i ~/onap-demo -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no blueprints/tosca-vnfd-onap-demo ubuntu@$ip:/home/ubuntu + ssh -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + ubuntu@$ip "bash ~/tosca-vnfd-onap-demo/start.sh ${vnfc_type[$1]} $mon_ip hello world" + fi +} + +start_agents() { + echo "$0: $(date) Execute agent startup script in the VNF VMs" + if [[ "$1" == "all" ]]; then + echo "$0: $(date) Start agents in the VNF VMs" + for i in $vnf_vdui; do + start_agent $i + done + start_agent 5 $2 $3 + else + start_agent $1 $2 $3 + fi +} + +stop_agent() { + if [[ $1 == 5 ]]; then + echo "$0: $(date) remove collectd agent on bare metal hypervisor host, user $3 at $2" + ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $3@$2 <<'EOF' +dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` +if [ "$dist" == "Ubuntu" ]; then + sudo systemctl stop collectd + sudo apt-get remove -y collectd +else + sudo systemctl stop collectd + sudo yum remove -y collectd collectd-virt +fi +rm -rf $HOME/barometer +EOF + else + get_vdu_ip $1 + if [[ ${vnfc_type[$1]} == "webserver" ]]; then + echo "$0: $(date) stopping webserver $1 agent at $ip" + ssh -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip << 'EOF' +sudo kill $(ps -ef | grep evel_demo | awk '{print $2}') +rm -rf evel-library +rm -rf tosca-vnfd-onap-demo +EOF + else + echo "$0: $(date) stopping VDU$1 agent at $ip" + ssh -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip << 'EOF' +sudo kill $(ps -ef | grep vpp_measurement_reporter | awk '{print $2}') +rm -rf evel-library +rm -rf tosca-vnfd-onap-demo +EOF + fi + fi +} + +stop_agents() { + if [[ $1 == "all" ]]; then + echo "$0: $(date) Stop agents in the VNF VMs" + for i in $vnf_vdui; do + stop_agent $i + done + stop_agent 5 $2 $3 + else + stop_agent $1 $2 $3 + fi +} + +start_monitor() { + for i in $vdui; do + vdu_id[$i]=$(openstack server list | awk "/VDU$i/ { print \$2 }") + done + get_vdu_ip 5 + mon_ip=$ip + echo "$0: $(date) start Monitor in VDU5 at $mon_ip" + scp -i ~/onap-demo -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no blueprints/tosca-vnfd-onap-demo ubuntu@$mon_ip:/home/ubuntu/ + ssh -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$mon_ip "bash /home/ubuntu/tosca-vnfd-onap-demo/start.sh monitor ${vdu_id[1]} ${vdu_id[2]} ${vdu_id[3]} ${vdu_id[4]} hello world" } start() { # Disable trap for now, need to test to ensure premature fail does not occur # trap 'fail' ERR + if [[ "$1" == "agent" ]]; then + start_agent $2 $3 $4 + pass + fi + echo "$0: $(date) setup OpenStack CLI environment" source /opt/tacker/admin-openrc.sh echo "$0: $(date) create flavor to use in blueprint" - openstack flavor create onap.demo --id auto --ram 1024 --disk 3 --vcpus 1 - - echo "$0: $(date) Create Nova key pair" - if [[ -f /opt/tacker/onap-demo ]]; then rm /opt/tacker/onap-demo; fi - ssh-keygen -t rsa -N "" -f /opt/tacker/onap-demo -C ubuntu@onap-demo - chmod 600 /opt/tacker/onap-demo - openstack keypair create --public-key /opt/tacker/onap-demo.pub onap-demo - assert "onap-demo-nova-001 (Keypair creation)" true - - echo "$0: $(date) Inject public key into blueprint" - pubkey=$(cat /opt/tacker/onap-demo.pub) - sed -i -- "s~<pubkey>~$pubkey~" /opt/tacker/blueprints/tosca-vnfd-onap-demo/blueprint.yaml - - vdus="VDU1 VDU2 VDU3 VDU4" - vdui="1 2 3 4" - vnf_vdui="1 2 3" - declare -a vdu_id=() - declare -a vdu_ip=() - declare -a vdu_url=() + openstack flavor create onap.demo --id auto --ram 1024 --disk 4 --vcpus 1 # Setup for workarounds - echo "$0: $(date) allocate floating IPs no loop no array assignment" + echo "$0: $(date) allocate floating IPs" get_floating_net - - # stack@us16-newton:~$ (openstack floating ip create public | awk "NR==7 { print \$4 }") - # 172.24.4.11 - # stack@us16-newton:~$ (openstack floating ip create public | awk "/floating_ip_address/ { print \$4 }") - # 172.24.4.7 - for i in $vdui; do vdu_ip[$i]=$(nova floating-ip-create $FLOATING_NETWORK_NAME | awk "/$FLOATING_NETWORK_NAME/ { print \$4 }") echo "$0: $(date) Pre-allocated ${vdu_ip[$i]} to VDU$i" done + echo "$0: $(date) Inject public key into blueprint" + pubkey=$(cat /opt/tacker/onap-demo.pub) + sed -i -- "s~<pubkey>~$pubkey~" /opt/tacker/blueprints/tosca-vnfd-onap-demo/blueprint.yaml echo "$0: $(date) Inject web server floating IPs into LB code in blueprint" sed -i -- "s/<vdu1_ip>/${vdu_ip[1]}/" /opt/tacker/blueprints/tosca-vnfd-onap-demo/blueprint.yaml - sed -i -- "s/<vdu2_ip>/${vdu_ip[1]}/" /opt/tacker/blueprints/tosca-vnfd-onap-demo/blueprint.yaml + sed -i -- "s/<vdu2_ip>/${vdu_ip[2]}/" /opt/tacker/blueprints/tosca-vnfd-onap-demo/blueprint.yaml + sed -i -- "s/<vdu3_ip>/${vdu_ip[3]}/" /opt/tacker/blueprints/tosca-vnfd-onap-demo/blueprint.yaml # End setup for workarounds echo "$0: $(date) create VNFD named onap-demo-vnfd" @@ -266,7 +415,8 @@ start() { assert "onap-demo-tacker-002 (onap-demo-vnf creation)" false fi let count=$count-1 - sleep 30 + #sleep for 60 seconds + sleep 60 echo "$0: $(date) wait for onap-demo-vnf to go ACTIVE" done if [[ $count == 0 ]]; then @@ -275,9 +425,9 @@ start() { fi # Setup for workarounds - echo "$0: $(date) directly set port security on ports (unsupported in Mitaka Tacker)" + echo "$0: $(date) directly set port security on ports (unsupported in Newton Tacker)" # Alternate method - # HEAT_ID=$(tacker vnf-show onap-demo-vnfd | awk "/instance_id/ { print \$4 }") + # HEAT_ID=$(tacker vnf-show onap-demo-vnf | awk "/instance_id/ { print \$4 }") # SERVER_ID=$(openstack stack resource list $HEAT_ID | awk "/VDU1 / { print \$4 }") for vdu in $vdus; do echo "$0: $(date) Setting port security on $vdu" @@ -288,12 +438,23 @@ start() { done done - echo "$0: $(date) directly assign security group (unsupported in Mitaka Tacker)" + echo "$0: $(date) directly assign security group to VDUs (unsupported in Newton Tacker)" if [[ $(neutron security-group-list | awk "/ onap-demo / { print \$2 }") ]]; then neutron security-group-delete onap-demo; fi neutron security-group-create onap-demo + echo "$0: $(date) Add SSH traffic ingress rule to onap-demo" neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 22 --port-range-max 22 onap-demo + echo "$0: $(date) Add HTTP traffic ingress rule to onap-demo" neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 80 --port-range-max 80 onap-demo + # TODO: Split out the rest of the rules below into a security group specific to the role of the monitor + echo "$0: $(date) Add VES monitor traffic ingress rule to onap-demo" neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 30000 --port-range-max 30000 onap-demo + echo "$0: $(date) Add Grafana dahboard ingress rule to onap-demo" + neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 3000 --port-range-max 3000 onap-demo + echo "$0: $(date) Add InfluxDB API traffic ingress rule to onap-demo" + neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 8086 --port-range-max 8086 onap-demo + echo "$0: $(date) Add InfluxDB dashboard ingress rule to onap-demo" + neutron security-group-rule-create --direction ingress --protocol TCP --port-range-min 8083 --port-range-max 8083 onap-demo + for i in $vdui; do vdu_id[$i]=$(openstack server list | awk "/VDU$i/ { print \$2 }") echo "$0: $(date) Assigning security groups to VDU$i (${vdu_id[$i]})" @@ -301,7 +462,7 @@ start() { openstack server add security group ${vdu_id[$i]} default done - echo "$0: $(date) associate floating IPs" + echo "$0: $(date) associate floating IPs with VDUs" # openstack server add floating ip INSTANCE_NAME_OR_ID FLOATING_IP_ADDRESS for i in $vdui; do openstack server add floating ip ${vdu_id[$i]} ${vdu_ip[$i]} @@ -311,7 +472,8 @@ start() { vdu_url[1]="http://${vdu_ip[1]}" vdu_url[2]="http://${vdu_ip[2]}" vdu_url[3]="http://${vdu_ip[3]}" - vdu_url[4]="http://${vdu_ip[4]}:30000/eventListener/v3" + vdu_url[4]="http://${vdu_ip[4]}" + vdu_url[5]="http://${vdu_ip[5]}:30000/eventListener/v5" apt-get install -y curl @@ -320,41 +482,27 @@ start() { resp=$(curl http://${vdu_ip[1]}) echo $resp while [[ $count -gt 10 && "$resp" == "" ]]; do - echo "$0: $(date) waiting for HTTP response from LB" - sleep 60 + echo "$0: $(date) waiting for HTTP response from FW" + sleep 90 let count=$count+1 - resp=$(curl http://${vdu_ip[3]}) + resp=$(curl http://${vdu_ip[4]}) echo $resp done - echo "$0: $(date) verify onap-demo server is running at each web server and via the LB" + echo "$0: $(date) verify onap-demo server is running at each web server and via the LB and via the FW" + echo "$0: $(date) say_hello VDU1" say_hello http://${vdu_ip[1]} + echo "$0: $(date) say_hello VDU2" say_hello http://${vdu_ip[2]} + echo "$0: $(date) say_hello VDU3" say_hello http://${vdu_ip[3]} + echo "$0: $(date) say_hello VDU4" + say_hello http://${vdu_ip[4]} assert "onap-demo-onap-demo-vnf-001 (onap-demo VNF creation)" true assert "onap-demo-tacker-003 (VNF creation)" true assert "onap-demo-tacker-vnfd-002 (artifacts creation)" true assert "onap-demo-tacker-vnfd-003 (user_data creation)" true - - echo "$0: $(date) setup Monitor in VDU4 at ${vdu_ip[4]}" - scp -i /opt/tacker/onap-demo -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /opt/tacker/blueprints/tosca-vnfd-onap-demo/start.sh ubuntu@${vdu_ip[4]}:/home/ubuntu/start.sh - scp -i /opt/tacker/onap-demo -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /opt/tacker/blueprints/tosca-vnfd-onap-demo/monitor.py ubuntu@${vdu_ip[4]}:/home/ubuntu/monitor.py - ssh -i /opt/tacker/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[4]} "nohup bash /home/ubuntu/start.sh monitor ${vdu_id[1]} ${vdu_id[2]} ${vdu_id[3]} hello world > /dev/null 2>&1 &" - - echo "$0: $(date) Execute agent startup script in the VNF VMs" - for i in $vnf_vdui; do - ssh -i /opt/tacker/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${vdu_ip[$i]} "sudo chown ubuntu /home/ubuntu" - scp -i /opt/tacker/onap-demo -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /opt/tacker/blueprints/tosca-vnfd-onap-demo/start.sh ubuntu@${vdu_ip[$i]}:/home/ubuntu/start.sh - ssh -i /opt/tacker/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ - ubuntu@${vdu_ip[$i]} "nohup bash /home/ubuntu/start.sh agent ${vdu_id[$i]} ${vdu_ip[4]} hello world > /dev/null 2>&1 &" - done - - echo "$0: $(date) Startup complete. VDU addresses:" - echo "web server 1: ${vdu_ip[1]}" - echo "web server 2: ${vdu_ip[2]}" - echo "load balancer: ${vdu_ip[3]}" - echo "monitor : ${vdu_ip[4]}" } stop() { @@ -363,17 +511,17 @@ stop() { echo "$0: $(date) setup OpenStack CLI environment" source /opt/tacker/admin-openrc.sh - if [[ "$(tacker vnf-list | grep onap-demo-vnf | awk '{print $2}')" != '' ]]; then + if [[ $(tacker vnf-list | grep -c onap-demo-vnf) > 0 ]]; then echo "$0: $(date) uninstall onap-demo-vnf blueprint via CLI" try 12 10 "tacker vnf-delete onap-demo-vnf" # It can take some time to delete a VNF - thus wait 2 minutes count=12 - while [[ $count -gt 0 && "$(tacker vnf-list | grep onap-demo-vnfd | awk '{print $2}')" != '' ]]; do + while [[ $count -gt 0 && $(tacker vnf-list | grep -c onap-demo-vnf) > 0 ]]; do echo "$0: $(date) waiting for onap-demo-vnf VNF delete to complete" sleep 10 let count=$count-1 done - if [[ "$(tacker vnf-list | grep onap-demo-vnf | awk '{print $2}')" == '' ]]; then + if [[ $(tacker vnf-list | grep -c onap-demo-vnf) == 0 ]]; then assert "onap-demo-tacker-004 (VNF onap-demo-vnf deletion)" true else assert "onap-demo-tacker-004 (VNF onap-demo-vnf deletion)" false @@ -408,70 +556,46 @@ stop() { openstack flavor delete onap.demo } -start_collectd() { - # NOTE: ensure hypervisor hostname is resolvable e.g. thru /etc/hosts - echo "$0: $(date) update start.sh script in case it changed" - cp -r blueprints/tosca-vnfd-onap-demo/start.sh /opt/tacker/blueprints/tosca-vnfd-onap-demo - echo "$0: $(date) start collectd agent on bare metal hypervisor host" - scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /opt/tacker/blueprints/tosca-vnfd-onap-demo/start.sh $2@$1:/home/$2/start.sh - ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $2@$1 \ - "nohup bash /home/$2/start.sh collectd $1 $3 hello world > /dev/null 2>&1 &" -} - -stop_collectd() { - echo "$0: $(date) remove collectd agent on bare metal hypervisor hosts" - ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $2@$1 <<'EOF' -dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` -if [ "$dist" == "Ubuntu" ]; then - sudo service collectd stop - sudo apt-get remove -y collectd -else - sudo service collectd stop - sudo yum remove -y collectd collectd-virt -fi -rm -rf $HOME/barometer -EOF -} # # Test tools and scenarios -# +# get_vdu_ip () { source /opt/tacker/admin-openrc.sh - - echo "$0: $(date) find VM IP for $1" - ip=$(openstack server list | awk "/$1/ { print \$10 }") + ip=$(openstack server list | awk "/VDU$1/ { print \$10 }") } monitor () { - echo "$0: $(date) Start the VES Monitor in VDU4 - Stop first if running" - sudo ssh -t -t -i /opt/tacker/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$1 << 'EOF' + echo "$0: $(date) Start the VES Monitor in VDU5 - Stop first if running" + get_vdu_ip 5 + scp -i ~/onap-demo -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no blueprints/tosca-vnfd-onap-demo/monitor.py ubuntu@$ip:/home/ubuntu/evel-test-collector/code/collector/monitor.py + ssh -t -t -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip << 'EOF' sudo kill $(ps -ef | grep evel-test-collector | awk '{print $2}') -nohup python evel-test-collector/code/collector/monitor.py --config evel-test-collector/config/collector.conf --section default > /home/ubuntu/monitor.log & -tail -f monitor.log +python evel-test-collector/code/collector/monitor.py --config evel-test-collector/config/collector.conf --section default EOF } traffic () { echo "$0: $(date) Generate some traffic, somewhat randomly" + get_vdu_ip $1 ns="0 00 000" while true do for n in $ns; do sleep .$n$[ ( $RANDOM % 10 ) + 1 ]s - curl -s http://$1 > /dev/null + curl -s http://$ip > /dev/null done done } pause () { - echo "$0: $(date) Pause the VNF (web server) in $1 for 30 seconds to generate a state change fault report (Stopped)" - $1 - sudo ssh -t -t -i /opt/tacker/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$1 "sudo docker pause onap-demo" - sleep 20 + get_vdu_ip $1 + echo "$0: $(date) Pause the VNF (web server) in $1 for 60 seconds to generate a state change fault report (Stopped)" + ssh -t -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip "sudo docker pause onap-demo" + sleep 60 echo "$0: $(date) Unpausing the VNF to generate a state change fault report (Started)" - sudo ssh -t -t -i /opt/tacker/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$1 "sudo docker unpause onap-demo" + ssh -t -i ~/onap-demo -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ip "sudo docker unpause onap-demo" } forward_to_container () { @@ -480,6 +604,32 @@ forward_to_container () { if [ $? -eq 1 ]; then fail; fi } +print_vdu_ip () { + echo "$0: $(date) Startup complete. VDU addresses:" + get_vdu_ip 1 + echo "web server 1: $ip" + get_vdu_ip 2 + echo "web server 2: $ip" + get_vdu_ip 3 + echo "load balancer: $ip" + get_vdu_ip 4 + echo "firewall : $ip" + get_vdu_ip 5 + echo "monitor : $ip" +} + + +vdus="VDU1 VDU2 VDU3 VDU4 VDU5" +vdui="1 2 3 4 5" +vnf_vdui="1 2 3 4" +vnfc_type[1]="webserver" +vnfc_type[2]="webserver" +vnfc_type[3]="vLB" +vnfc_type[4]="vFW" +declare -a vdu_id=() +declare -a vdu_ip=() +declare -a vdu_url=() + dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` case "$1" in setup) @@ -487,31 +637,23 @@ case "$1" in if [ $? -eq 1 ]; then fail; fi pass ;; - run) - setup $2 $3 - copy_blueprint - forward_to_container start - if [ $? -eq 1 ]; then fail; fi - pass - ;; start) + if [[ "$2" == "agent" ]]; then + start_agents $3 $4 $5 + pass + fi if [[ -f /.dockerenv ]]; then start else copy_blueprint forward_to_container start + start_monitor + print_vdu_ip fi pass ;; - start_collectd) - start_collectd $2 $3 $4 - if [ $? -eq 1 ]; then fail; fi - pass - ;; - stop_collectd) - stop_collectd $2 $3 - if [ $? -eq 1 ]; then fail; fi - pass + ssh) + ssh_to_vdu $2 ;; monitor) monitor $2 @@ -526,6 +668,10 @@ case "$1" in pause $2 ;; stop) + if [[ $2 == "agent" ]]; then + stop_agents $3 $4 $5 + pass + fi if [[ -f /.dockerenv ]]; then stop else @@ -543,57 +689,5 @@ case "$1" in pass ;; *) - cat <<EOF - What this is: Deployment test for the VES agent and collector based - upon the Tacker Hello World blueprint, designed as a manual demo of the VES - concept and integration with the Barometer project collectd agent. Typical - demo procedure is to execute the following actions from the OPNFV jumphost - or some host wth access to the OpenStack controller (see below for details): - setup: install Tacker in a docker container. Note: only needs to be done - once per session, and can be reused across OPNFV VES and Models tests, - i.e. you can start another test at the "start" step below. - start: install blueprint and start the VNF, including the app (load-balanced - web server) and VES agents running on the VMs. Installs the VES - monitor code but does not start the monitor (see below). - start_collectd: start the collectd daemon on bare metal hypervisor hosts - monitor: start the VES monitor, typically run in a second shell session. - pause: pause the app at one of the web server VDUs (VDU1 or VDU2) - stop: stop the VNF and uninstall the blueprint - start_collectd: start the collectd daemon on bare metal hypervisor hosts - clean: remove the tacker container and service (if desired, when done) - - How to use: - $ git clone https://gerrit.opnfv.org/gerrit/ves - $ cd ves/tests - $ bash ves_onap_demo.sh <setup> <openrc> [branch] - setup: setup test environment - <openrc>: location of OpenStack openrc file - branch: OpenStack branch to install (default: master) - $ bash ves_onap_demo.sh start - start: install blueprint and run test - <user>: username on hypervisor hosts, for ssh (user must be setup for - key-based auth on the hosts) - $ bash ves_onap_demo.sh start_collectd|stop_collectd <hpv_ip> <user> <mon_ip> - start_collectd: install and start collectd daemon on hypervisor - stop_collectd: stop and uninstall collectd daemon on hypervisor - <hpv_ip>: hypervisor ip - <user>: username on hypervisor hosts, for ssh (user must be setup for - key-based auth on the hosts) - <mon_ip>: IP address of VES monitor - $ bash ves_onap_demo.sh monitor <mon_ip> - monitor: attach to the collector VM and run the VES Monitor - <mon_ip>: IP address of VDU4 (monitor VM) - $ bash ves_onap_demo.sh traffic <ip> - traffic: generate some traffic - <ip>: address of server - $ bash ves_onap_demo.sh pause <ip> - pause: pause the VNF (web server) for a minute to generate a state change - <ip>: address of server - $ bash ves_onap_demo.sh stop - stop: stop test and uninstall blueprint - $ bash ves_onap_demo.sh clean <user> - clean: cleanup after test - <user>: username on hypervisor hosts, for ssh (user must be setup for - key-based auth on the hosts) -EOF + grep '# ' $0 esac |