X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=dbc-client%2Fmisc%2Fdbc-client;h=775f719b36a585b4260bda33cb60fac13eb7af31;hb=a4aeefb08d2ed5fb10a94fe3df63910db7827d33;hp=a8124600ec5ceb057cc56311176adca16a0bf4f0;hpb=80f10c41049ea22e914d4a17652abc1d3b502006;p=dmaap%2Fbuscontroller.git diff --git a/dbc-client/misc/dbc-client b/dbc-client/misc/dbc-client index a812460..775f719 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,15 @@ 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:-https} +PORT=${PORT:-8443} +WAIT_TO_EXIT=${WAIT_TO_EXIT:-N} +PEMDIR=${PEMDIR:-/opt/app/osaaf/local} +CAPEM=${CAPEM:-ca.pem} +CLIENTPEM=${CLIENTPEM:-client.pem} +KEYPEM=${KEYPEM:-key.pem} +CERTPWD=${CERTPWD:-"2U[iOZzMHI:.#tdCwlBqc;}S"} @@ -44,6 +53,18 @@ config() { echo "Expected app root directory $APP_ROOT does not exist" exit 1 fi + cd $PEMDIR + pwd + ls -l + if [ -f $CAPEM -a -f $CLIENTPEM -a -f $KEYPEM ] + then + echo "--key $PEMDIR/$KEYPEM --cacert $PEMDIR/$CAPEM --cert $PEMDIR/${CLIENTPEM}:${CERTPWD}" > $PEMDIR/curl.cred + CURLCRED="-K $PEMDIR/curl.cred" + else + echo "Warning: PEM files for authorization not found!" + CURLCRED="" + fi + echo "CURLCRED=$CURLCRED" cd $APP_ROOT find . -type f -exec ls -l {} \; find $CONFIGMAP_ROOT -type f -exec ls -l {} \; @@ -54,7 +75,7 @@ config() { source $CONTAINER_CONFIG fi - if [ "$DMAAPBC_WAIT_TO_EXIT" != "Y" ] + if [ "$WAIT_TO_EXIT" != "Y" ] then echo "Creating $APP_ROOT/ok_to_exit so no waiting..." > $APP_ROOT/ok_to_exit @@ -62,18 +83,12 @@ config() { echo "Not creating $APP_ROOT/ok_to_exit" fi - if [ ! -f $APP_ROOT/misc/cert-client-init.sh ] - then - echo "Did not find $APP_ROOT/misc/cert-client-init.sh to append to truststore" - exit 1 - fi - $APP_ROOT/misc/cert-client-init.sh - set +x } init() { + set -x echo "ENTER init" if [ ! -d $CONFIGMAP_ROOT ] then @@ -82,16 +97,41 @@ 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 $CURLCRED -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 + set +x +} +dopost() { + set -x + RETRY_TIME=60 + + loop=true + + while [ $loop = true ] + do + rc=`curl $CURLCRED -s -X POST -w "%{http_code}" -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" -d @${1} ${PROTO}://${DBC}:${PORT}/webapi/${2} -o /dev/null` + 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 + set +x + } doprov() { + set -x cd $CONFIGMAP_ROOT pwd # order is important in this next list @@ -102,11 +142,11 @@ 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 + set +x } delay() { echo "DELAY=$DELAY" @@ -116,7 +156,6 @@ delay() { fi } -set -x delay config init