From 3622f7a20e615d409dd5a8dea3ae592115df91ae Mon Sep 17 00:00:00 2001 From: Lusheng Ji Date: Wed, 4 Apr 2018 21:51:34 -0400 Subject: Fix TCA image Issue-ID: DCAEGEN2-206 Change-Id: I8fa5150bffc0e371ab09bd75f1df4e460bf85a72 Signed-off-by: Lusheng Ji --- tca-cdap-container/Dockerfile | 9 ++--- tca-cdap-container/README.txt | 5 +++ tca-cdap-container/get-tca.sh | 7 ++-- tca-cdap-container/host.aliases | 1 - tca-cdap-container/restart.sh | 63 ++++++++++++++++++----------- tca-cdap-container/tca_app_config.json | 2 +- tca-cdap-container/tca_app_preferences.json | 24 +++++------ 7 files changed, 66 insertions(+), 45 deletions(-) create mode 100644 tca-cdap-container/README.txt delete mode 100644 tca-cdap-container/host.aliases mode change 100644 => 100755 tca-cdap-container/restart.sh (limited to 'tca-cdap-container') diff --git a/tca-cdap-container/Dockerfile b/tca-cdap-container/Dockerfile index 2e4f8ca..158c95a 100644 --- a/tca-cdap-container/Dockerfile +++ b/tca-cdap-container/Dockerfile @@ -17,18 +17,17 @@ FROM caskdata/cdap-standalone:4.1.2 RUN apt-get update -RUN apt-get install -y netcat jq wget +RUN apt-get install -y netcat jq wget vim iputils-ping COPY get-tca.sh /opt/tca/get-tca.sh RUN /opt/tca/get-tca.sh COPY tca_app_config.json /opt/tca/tca_app_config.json COPY tca_app_preferences.json /opt/tca/tca_app_preferences.json COPY restart.sh /opt/tca/restart.sh -COPY host.aliases /etc/host.aliases - -RUN echo "export HOSTALIASES=/etc/host.aliases" >> /etc/profile RUN chmod 755 /opt/tca/restart.sh -ENV HOSTALIASES /etc/host.aliases +#COPY host.aliases /etc/host.aliases +#RUN echo "export HOSTALIASES=/etc/host.aliases" >> /etc/profile +#ENV HOSTALIASES /etc/host.aliases EXPOSE 11011 EXPOSE 11015 diff --git a/tca-cdap-container/README.txt b/tca-cdap-container/README.txt new file mode 100644 index 0000000..62a7a09 --- /dev/null +++ b/tca-cdap-container/README.txt @@ -0,0 +1,5 @@ +Note: + +Although typically Java jar artifacts have SNAPSHOT version as a.b.c-SNAPSHOT, internally CDAP +identifies the application as a.b.c.SNAPSHOT. Thus, in app_config JSON we must refer to the +application as a.b.c.SNAPSHOT. Otherwise we will have artifact not found error" diff --git a/tca-cdap-container/get-tca.sh b/tca-cdap-container/get-tca.sh index 2a9cf62..66038b1 100755 --- a/tca-cdap-container/get-tca.sh +++ b/tca-cdap-container/get-tca.sh @@ -1,16 +1,17 @@ #!/bin/bash +ARTIFACTPATH=${1:-/opt/tca/} PROTO='https' NEXUSREPO='nexus.onap.org' REPO='snapshots' GROUPID='org.onap.dcaegen2.analytics.tca' -ARTIFACTID='dcae-analytics-tca' +ARTIFACTID='dcae-analytics-cdap-tca' VERSION='2.2.0-SNAPSHOT' URL="${PROTO}://${NEXUSREPO}/service/local/repositories/${REPO}/content/${GROUPID//.//}/${ARTIFACTID}/${VERSION}/maven-metadata.xml" VT=$(wget --no-check-certificate -O- $URL | grep -m 1 \ | sed -e 's/\(.*\)<\/value>/\1/' | sed -e 's/ //g') URL="${PROTO}://${NEXUSREPO}/service/local/repositories/${REPO}/content/${GROUPID//.//}/${ARTIFACTID}/${VERSION}/${ARTIFACTID}-${VT}.jar" -#wget --no-check-certificate "${URL}" -O "/opt/tca/${ARTIFACTID}-${VERSION%-SNAPSHOT}.jar" -wget --no-check-certificate "${URL}" -O "${ARTIFACTID}-${VERSION%-SNAPSHOT}.jar" +#wget --no-check-certificate "${URL}" -O "${ARTIFACTPATH}${ARTIFACTID}-${VERSION%-SNAPSHOT}.jar" +wget --no-check-certificate "${URL}" -O "${ARTIFACTPATH}${ARTIFACTID}.${VERSION}.jar" diff --git a/tca-cdap-container/host.aliases b/tca-cdap-container/host.aliases deleted file mode 100644 index 6b0b785..0000000 --- a/tca-cdap-container/host.aliases +++ /dev/null @@ -1 +0,0 @@ -consul consul-server.onap-consul.svc.cluster.local diff --git a/tca-cdap-container/restart.sh b/tca-cdap-container/restart.sh old mode 100644 new mode 100755 index c9c1d56..bc15cac --- a/tca-cdap-container/restart.sh +++ b/tca-cdap-container/restart.sh @@ -23,9 +23,9 @@ TCA_NAMESPACE='cdap_tca_hi_lo' TCA_APPNAME='dcae-tca' TCA_ARTIFACT='dcae-analytics-cdap-tca' -TCA_ARTIFACT_VERSION='2.2.0' +TCA_ARTIFACT_VERSION='2.2.0-SNAPSHOT' TCA_FILE_PATH='/opt/tca' -TCA_JAR="${TCA_FILE_PATH}/${TCA_ARTIFACT}-${TCA_ARTIFACT_VERSION}.jar" +TCA_JAR="${TCA_FILE_PATH}/${TCA_ARTIFACT}.${TCA_ARTIFACT_VERSION}.jar" TCA_APP_CONF="${TCA_FILE_PATH}/tca_app_config.json" TCA_CONF="${TCA_FILE_PATH}/tca_config.json" TCA_PREF="${TCA_FILE_PATH}/tca_app_preferences.json" @@ -36,10 +36,39 @@ TCA_PREF_TEMP='/tmp/tca_preferences.json' TCA_PATH_APP="${CDAP_HOST}:${CDAP_PORT}/v3/namespaces/${TCA_NAMESPACE}/apps/${TCA_APPNAME}" TCA_PATH_ARTIFACT="${CDAP_HOST}:${CDAP_PORT}/v3/namespaces/${TCA_NAMESPACE}/artifacts" -if [ -z "$CONSUL_HOST" ]; then CONSUL_HOST='consul'; fi -if [ -z "$CONSUL_PORT" ]; then CONSUL_PORT='8500'; fi -if [ -z "$CONFIG_BINDING_SERVICE" ]; then CONFIG_BINDING_SERVICE='config_binding_service'; fi +CONSUL_HOST=${CONSU_HOST:-consul} +CONSUL_PORT=${CONSU_PORT:-8500} +CONFIG_BINDING_SERVICE=${CONFIG_BINDING_SERVICE:-config_binding_service} + +CBS_SERVICE_NAME=${CONFIG_BINDING_SERVICE} + +CBS_HOST=$(curl -s "${CONSUL_HOST}:${CONSUL_PORT}/v1/catalog/service/${CBS_SERVICE_NAME}" |jq .[0].ServiceAddress |sed -e 's/\"//g') +CBS_PORT=$(curl -s "${CONSUL_HOST}:${CONSUL_PORT}/v1/catalog/service/${CBS_SERVICE_NAME}" |jq .[0].ServicePort |sed -e 's/\"//g') +CBS_HOST=${CBS_HOST:-config_binding_service} +CBS_PORT=${CBS_PORT:-10000} + +MY_NAME=${SERVICE_NAME:-tca} + +echo "TCA environment: I am ${MY_NAME}, consul at ${CONSUL_HOST}:${CONSUL_PORT}, CBS at ${CBS_HOST}:${CBS_PORT}, service name ${CBS_SERVICE_NAME}" + + +echo "Generting preference file" +sed -i 's/{{DMAAPHOST}}/'"${DMAAPHOST}"'/g' ${TCA_PREF} +sed -i 's/{{DMAAPPORT}}/'"${DMAAPPORT}"'/g' ${TCA_PREF} +sed -i 's/{{DMAAPPUBTOPIC}}/'"${DMAAPPUBTOPIC}"'/g' ${TCA_PREF} +sed -i 's/{{DMAAPSUBTOPIC}}/'"${DMAAPSUBTOPIC}"'/g' ${TCA_PREF} +sed -i 's/{{DMAAPSUBGROUP}}/OpenDCAEc12/g' ${TCA_PREF} +sed -i 's/{{DMAAPSUBID}}/c12/g' ${TCA_PREF} +sed -i 's/{{AAIHOST}}/'"${AAIHOST}"'/g' ${TCA_PREF} +sed -i 's/{{AAIPORT}}/'"${AAIPORT}"'/g' ${TCA_PREF} +if [ -z $REDISHOSTPORT ]; then + sed -i 's/{{REDISHOSTPORT}}/NONE/g' ${TCA_PREF} + sed -i 's/{{REDISCACHING}}/false/g' ${TCA_PREF} +else + sed -i 's/{{REDISHOSTPORT}}/'"${REDISHOSTPORT}"'/g' ${TCA_PREF} + sed -i 's/{{REDISCACHING}}/true/g' ${TCA_PREF} +fi function tca_stop { # stop programs @@ -55,20 +84,20 @@ function tca_stop { function tca_load_artifact { echo - echo "Loading artifact ..." + echo "Loading artifact ${TCA_JAR} to http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}..." curl -s -X POST --data-binary @"${TCA_JAR}" "http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}" echo } function tca_load_conf { echo - echo "Loading configuration ..." + echo "Loading configuration ${TCA_APP_CONF} to http://${TCA_PATH_APP}" curl -s -X PUT -d @${TCA_APP_CONF} http://${TCA_PATH_APP} echo # load preferences echo - echo "Loading preferences ..." + echo "Loading preferences ${TCA_PREF} to http://${TCA_PATH_APP}/preferences" curl -s -X PUT -d @${TCA_PREF} http://${TCA_PATH_APP}/preferences echo } @@ -76,13 +105,13 @@ function tca_load_conf { function tca_delete { echo - echo "Deleting application dcae-tca ..." + echo "Deleting application dcae-tca http://${TCA_PATH_APP}" curl -s -X DELETE http://${TCA_PATH_APP} echo # delete artifact echo - echo "Deleting artifact dcae-analytics-cdap-tca version ${TCA_ARTIFACT_VERSION} ..." + echo "Deleting artifact http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}/versions/${TCA_ARTIFACT_VERSION} ..." curl -s -X DELETE "http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}/versions/${TCA_ARTIFACT_VERSION}" echo } @@ -112,24 +141,12 @@ function tca_status { function tca_poll_policy { - #CBS_HOST=$(curl -s "${CONSUL_HOST}:${CONSUL_PORT}/v1/catalog/service/${CBS_SERVICE_NAME}" |jq .[0].ServiceAddress |sed -e 's/\"//g') - #CBS_PORT=$(curl -s "${CONSUL_HOST}:${CONSUL_PORT}/v1/catalog/service/${CBS_SERVICE_NAME}" |jq .[0].ServicePort |sed -e 's/\"//g') - - CBS_HOST='bd-service-dcaegen2-platform-cbs.default' - CBS_PORT='10000' - if [ -z "${CBS_HOST}" ] || [ -z "${CBS_PORT}" ]; then - echo 'CBS HOST or PORT not defined' - return - fi - - MY_NAME=${SERVICE_NAME:-tca} - #MY_NAME=$(hostname |rev |cut -f 3- -d '-' |rev) URL1="${CBS_HOST}:${CBS_PORT}/service_component/${MY_NAME}" URL2="$URL1:preferences" - echo "Retrieving configuration file at ${URL1}" + echo "tca_poll_policy: Retrieving configuration file at ${URL1}" curl -s "$URL1" | jq . --sort-keys > "${TCA_CONF_TEMP}" echo "Retrieving preferences file at ${URL1}" curl -s "$URL2" | jq . --sort-keys > "${TCA_PREF_TEMP}" diff --git a/tca-cdap-container/tca_app_config.json b/tca-cdap-container/tca_app_config.json index b3a66cc..d6adcb7 100644 --- a/tca-cdap-container/tca_app_config.json +++ b/tca-cdap-container/tca_app_config.json @@ -2,7 +2,7 @@ "artifact": { "name": "dcae-analytics-cdap-tca", "scope": "user", - "version": "2.2.0" + "version": "2.2.0.SNAPSHOT" }, "config": { "appDescription": "DCAE Analytics Threshold Crossing Alert Application", diff --git a/tca-cdap-container/tca_app_preferences.json b/tca-cdap-container/tca_app_preferences.json index 4ca1a44..76fa8c2 100644 --- a/tca-cdap-container/tca_app_preferences.json +++ b/tca-cdap-container/tca_app_preferences.json @@ -1,7 +1,7 @@ { - "aaiEnrichmentHost": "10.0.1.1", + "aaiEnrichmentHost": "{{AAIHOST}}", "aaiEnrichmentIgnoreSSLCertificateErrors": "true", - "aaiEnrichmentPortNumber": "8443", + "aaiEnrichmentPortNumber": "{{AAIPORT}}", "aaiEnrichmentProtocol": "https", "aaiEnrichmentUserName": "DCAE", "aaiEnrichmentUserPassword": "DCAE", @@ -9,25 +9,25 @@ "aaiVNFEnrichmentAPIPath": "/aai/v11/network/generic-vnfs/generic-vnf", "enableAAIEnrichment": "false", "enableAlertCEFFormat": "false", - "enableRedisCaching": "false", - "redisHosts": "redis-cluster:6379", + "enableRedisCaching": "{{REDISCACHING}}", + "redisHosts": "{{REDISHOSTPORT}}", "publisherContentType": "application/json", - "publisherHostName": "dmaap.onap-message-router", - "publisherHostPort": "3904", + "publisherHostName": "{{DMAAPHOST}}", + "publisherHostPort": "{{DMAAPPORT}}", "publisherMaxBatchSize": "1", "publisherMaxRecoveryQueueSize": "100000", "publisherPollingInterval": "20000", "publisherProtocol": "http", - "publisherTopicName": "unauthenticated.TCA_EVENT_OUTPUT", - "subscriberConsumerGroup": "OpenDCAE-c12", - "subscriberConsumerId": "c12", + "publisherTopicName": "{{DMAAPPUBTOPIC}}", + "subscriberConsumerGroup": "{{DMAAPSUBGROUP}}", + "subscriberConsumerId": "{{DMAAPSUBID}}", "subscriberContentType": "application/json", - "subscriberHostName": "dmaap.onap-message-router", - "subscriberHostPort": "3904", + "subscriberHostName": "{{DMAAPHOST}}", + "subscriberHostPort": "{{DMAAPPORT}}", "subscriberMessageLimit": "-1", "subscriberPollingInterval": "30000", "subscriberProtocol": "http", "subscriberTimeoutMS": "-1", - "subscriberTopicName": "unauthenticated.SEC_MEASUREMENT_OUTPUT", + "subscriberTopicName": "{{DMAAPSUBTOPIC}}", "tca_policy": "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ONSET\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}" } -- cgit 1.2.3-korg