From: Lusheng Ji Date: Thu, 5 Apr 2018 16:02:52 +0000 (-0400) Subject: Fix poll policy error X-Git-Tag: v2.0.0~40 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=ac864ceb9f1eeef6057d105e7a670ad064701750;p=dcaegen2%2Fdeployments.git Fix poll policy error Issue-ID: DCAEGEN2-206 Change-Id: I728d00bd74a6cdc5b1aca520efe77f686ef9aae0 Signed-off-by: Lusheng Ji --- diff --git a/tca-cdap-container/restart.sh b/tca-cdap-container/restart.sh index bc15cac..95a41d2 100755 --- a/tca-cdap-container/restart.sh +++ b/tca-cdap-container/restart.sh @@ -147,9 +147,24 @@ function tca_poll_policy { URL2="$URL1:preferences" 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}" + HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL1") + HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') + HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') + if [ "$HTTP_STATUS" != "200" ]; then + echo "receiving $HTTP_RESPONSE from CBS" + return + fi + echo $HTTP_BODY | jq . --sort-keys > "${TCA_CONF_TEMP}" + + echo "tca_poll_policy: Retrieving preferences file at ${URL1}" + HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL2") + HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') + HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') + if [ "$HTTP_STATUS" != "200" ]; then + echo "receiving $HTTP_RESPONSE from CBS" + return + fi + echo $HTTP_BODY | jq . --sort-keys > "${TCA_PREF_TEMP}" if [ ! -e "${TCA_CONF_TEMP}" ] || [ "$(ls -sh ${TCA_CONF_TEMP} |cut -f1 -d' ' |sed -e 's/[^0-9]//g')" -lt "1" ]; then echo "Fail to receive configuration"