From da9564a9b0b78bbe341de9b039aab3c378eb027f Mon Sep 17 00:00:00 2001 From: Bryan Sullivan Date: Mon, 22 Jan 2018 15:25:53 -0800 Subject: Implement component deployment via cloudify JIRA: VES-2 Change-Id: Ic696f13d2a32e10663f50cd4e26b9a060525ff92 Signed-off-by: Bryan Sullivan --- build/ves-collector/start.sh | 59 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'build/ves-collector/start.sh') diff --git a/build/ves-collector/start.sh b/build/ves-collector/start.sh index be30c9a..250af34 100644 --- a/build/ves-collector/start.sh +++ b/build/ves-collector/start.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2017 AT&T Intellectual Property, Inc +# Copyright 2017-2018 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. @@ -23,6 +23,8 @@ sed -i -- \ evel-test-collector/config/collector.conf sed -i -- "s/vel_domain = 127.0.0.1/vel_domain = $ves_host/g" \ evel-test-collector/config/collector.conf +sed -i -- "s/vel_port = 30000/vel_port = $ves_port/g" \ + evel-test-collector/config/collector.conf sed -i -- "s/vel_username =/vel_username = $ves_user/g" \ evel-test-collector/config/collector.conf sed -i -- "s/vel_password =/vel_password = $ves_pass/g" \ @@ -31,18 +33,65 @@ sed -i -- "s~vel_path = vendor_event_listener/~vel_path = $ves_path~g" \ evel-test-collector/config/collector.conf sed -i -- "s~vel_topic_name = example_vnf~vel_topic_name = $ves_topic~g" \ evel-test-collector/config/collector.conf -sed -i -- "/vel_topic_name = /a influxdb = $ves_influxdb_host" \ +sed -i -- "/vel_topic_name = /a influxdb = $ves_influxdb_host:$ves_influxdb_port" \ evel-test-collector/config/collector.conf +echo; echo "evel-test-collector/config/collector.conf" +cat evel-test-collector/config/collector.conf + +echo; echo "wait for InfluxDB API at $ves_influxdb_host:$ves_influxdb_port" +while ! curl http://$ves_influxdb_host:$ves_influxdb_port/ping ; do + echo "InfluxDB API is not yet responding... waiting 10 seconds" + sleep 10 +done + +echo; echo "setup veseventsdb in InfluxDB" +# TODO: check if pre-existing and skip +curl -X POST http://$ves_influxdb_host:$ves_influxdb_port/query \ + --data-urlencode "q=CREATE DATABASE veseventsdb" + +echo; echo "wait for Grafana API to be active" +while ! curl http://$ves_grafana_host:$ves_grafana_port ; do + echo "Grafana API is not yet responding... waiting 10 seconds" + sleep 10 +done + +echo; echo "add VESEvents datasource to Grafana" +# TODO: check if pre-existing and skip +cat </opt/ves/datasource.json +{ "name":"VESEvents", + "type":"influxdb", + "access":"direct", + "url":"http://$ves_influxdb_host:$ves_influxdb_port", + "password":"root", + "user":"root", + "database":"veseventsdb", + "basicAuth":false, + "basicAuthUser":"", + "basicAuthPassword":"", + "withCredentials":false, + "isDefault":false, + "jsonData":null +} +EOF + +curl -H "Accept: application/json" -H "Content-type: application/json" \ + -X POST -d @/opt/ves/datasource.json \ + http://$ves_grafana_auth@$ves_grafana_host:$ves_grafana_port/api/datasources + +echo; echo "add VES dashboard to Grafana" +curl -H "Accept: application/json" -H "Content-type: application/json" \ + -X POST -d @/opt/ves/Dashboard.json \ + http://$ves_grafana_auth@$ves_grafana_host:$ves_grafana_port/api/dashboards/db + if [[ "$ves_loglevel" != "" ]]; then python /opt/ves/evel-test-collector/code/collector/monitor.py \ --config /opt/ves/evel-test-collector/config/collector.conf \ - --influxdb $ves_influxdb_host \ + --influxdb $ves_influxdb_host:$ves_influxdb_port \ --section default > /opt/ves/monitor.log 2>&1 else python /opt/ves/evel-test-collector/code/collector/monitor.py \ --config /opt/ves/evel-test-collector/config/collector.conf \ - --influxdb $ves_influxdb_host \ + --influxdb $ves_influxdb_host:$ves_influxdb_port \ --section default fi - -- cgit 1.2.3-korg