diff options
Diffstat (limited to 'dbc-client/misc')
-rw-r--r-- | dbc-client/misc/dbc-client | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/dbc-client/misc/dbc-client b/dbc-client/misc/dbc-client index a812460..cf6c230 100644 --- a/dbc-client/misc/dbc-client +++ b/dbc-client/misc/dbc-client @@ -24,7 +24,7 @@ umask 0022 TZ=GMT0 COMPONENT=dbc-client -APP_ROOT=/opt/app/$COMPONENT +APP_ROOT=${APP_ROOT:-/opt/app/$COMPONENT} USER=root export TZ PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin @@ -32,6 +32,9 @@ export PATH CONFIGMAP_ROOT=${CONFIGMAP_ROOT:-/opt/app/config} CONTAINER_CONFIG=$CONFIGMAP_ROOT/conf/dbc-client.env REQUESTID=${REQUESTID:-dbc-client} +DBC=${DBC:-dmaap-bc} +PROTO=${PROTO:-http} +PORT=${PORT:-8080} @@ -82,14 +85,35 @@ init() { fi #loop on get /dmaap until we get a good response to indicate other provisioning can continue - rc=999 + rc=${RESP:-999} while [ $rc != "200" ] do sleep 10 - rc=`curl -s -o /dev/null -I -w "%{http_code}" -X GET -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" http://dmaap-bc:8080/webapi/dmaap` + rc=`curl -s -o /dev/null -I -w "%{http_code}" -X GET -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" ${PROTO}://${DBC}:${PORT}/webapi/dmaap` echo "get dmaap response=${rc}" done } +dopost() { + RETRY_TIME=60 + + loop=true + + while [ $loop ] + do + rc=`curl -v -X POST -w "%{http_code}" -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" -d @${1} ${PROTO}://${DBC}:${PORT}/webapi/${2}` + case $rc in + 200 | 201 | 409 ) + echo "response=$rc" + loop=false + ;; + * ) + echo "`date`: http response=$rc. Will retry after $RETRY_TIME seconds" + sleep $RETRY_TIME + ;; + esac + done + +} doprov() { cd $CONFIGMAP_ROOT @@ -102,8 +126,7 @@ doprov() { for j in `ls ${uri}/*.json` do echo "POST $j to $uri" - rc=`curl -v -X POST -w "%{http_code}" -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" -d @${j} http://dmaap-bc:8080/webapi/${uri}` - echo "response=$rc" + dopost $j $uri done fi done |