diff options
author | Gary Wu <gary.wu@futurewei.com> | 2019-06-18 09:41:02 -0700 |
---|---|---|
committer | Yang Xu <yang.xu@futurewei.com> | 2019-06-19 06:05:23 +0000 |
commit | 9d32165d6ff03a85f55bf4ddbb295bdcf9546e60 (patch) | |
tree | afe2bb222118fb2ca9467dd5a0d2851110103713 | |
parent | 21b9508b6b7599999dc7adbaa032811e836e5814 (diff) |
Add script to set vfwcl loop name in consul
Issue-ID: INT-1104
Signed-off-by: Gary Wu <gary.wu@futurewei.com>
Change-Id: I719803b68cfff224ccf22f1b92613bf254a452b9
-rwxr-xr-x | deployment/heat/onap-rke/scripts/set-tca-vfwcl-name.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/deployment/heat/onap-rke/scripts/set-tca-vfwcl-name.sh b/deployment/heat/onap-rke/scripts/set-tca-vfwcl-name.sh new file mode 100755 index 000000000..45b11cdec --- /dev/null +++ b/deployment/heat/onap-rke/scripts/set-tca-vfwcl-name.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo This script updates the controll loop name for vFWCL in consul + echo "$0 <k8s_host_ip> <new_control_loop_name>" + echo + exit 1 +fi + + +set -v +set -x +set -e + +K8S_IP=$1 +CL_NAME=$2 + +CONSUL_ENDPOINT=http://$K8S_IP:30270/v1/kv +TMP_DIR=$(mktemp -d) +pushd $TMP_DIR + +curl -s $CONSUL_ENDPOINT/dcae-tca-analytics | jq -r '.[0].Value' | base64 --decode | jq '.' > dcae-tca-analytics.json +jq -r '.app_preferences.tca_policy' < dcae-tca-analytics.json | jq '.' > tca_policy.json +jq '.metricsPerEventName |= map( select(.eventName == "vFirewallBroadcastPackets").thresholds[].closedLoopControlName="'$CL_NAME'" )' < tca_policy.json > tca_policy_new.json +diff tca_policy.json tca_policy_new.json || true + +jq --argfile tca_policy_new tca_policy_new.json '.app_preferences.tca_policy |= ($tca_policy_new | tostring)' < dcae-tca-analytics.json > dcae-tca-analytics-new.json + +jq -c '.' < dcae-tca-analytics-new.json | curl -X PUT -d @- $CONSUL_ENDPOINT/dcae-tca-analytics + +popd |