diff options
-rw-r--r-- | INFO.yaml | 12 | ||||
-rw-r--r-- | dbc-client/misc/dbc-client | 225 | ||||
-rw-r--r-- | dbc-client/src/main/resources/Dockerfile | 2 | ||||
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | releases/2.0.7.yaml | 8 | ||||
-rw-r--r-- | version.properties | 2 |
6 files changed, 98 insertions, 153 deletions
@@ -36,11 +36,11 @@ committers: company: 'ericsson' id: 'efiacor' timezone: 'Europe/Dublin' - - name: 'Dominic Lunanuova' - email: 'dgl@research.att.com' - company: 'ATT' - id: 'dglFromAtt' - timezone: 'America/Dallas' + - name: 'David McWeeney' + email: 'david.mcweeney@est.tech' + company: 'Ericsson Software Technology' + id: 'david.mcweeney' + timezone: 'Europe/Dublin' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: @@ -62,3 +62,5 @@ tsc: name: 'Bhanu Ramesh' - type: 'Removal' name: 'Mandar Sawant' + - type: 'Removal' + name: 'Dominic Lunanuova' diff --git a/dbc-client/misc/dbc-client b/dbc-client/misc/dbc-client index 461a069..7247e01 100644 --- a/dbc-client/misc/dbc-client +++ b/dbc-client/misc/dbc-client @@ -1,10 +1,11 @@ #!/bin/sh # -# ============LICENSE_START========================================== +# ============LICENSE_START=============================================== # org.onap.dmaap -# =================================================================== +# ======================================================================== # Copyright © 2019 AT&T Intellectual Property. All rights reserved. -# =================================================================== +# Copyright (C) 2021 Nordix Foundation. +# ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -16,162 +17,96 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END============================================ +# ============LICENSE_END================================================= # ECOMP is a trademark and service mark of AT&T Intellectual Property. -# -# umask 0022 -TZ=GMT0 -COMPONENT=dbc-client -APP_ROOT=${APP_ROOT:-/opt/app/$COMPONENT} -export TZ -PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin -export PATH +set -uex -o pipefail +export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin + +# RESP_CACHE is (/opt/app/config/cache) empty-dir volume mount for K8s env +RESP_CACHE=${RESP_CACHE:-''} +RESP=${RESP:-'/dev/null'} +APP_ROOT=${APP_ROOT:-/opt/app/dbc-client} CONFIGMAP_ROOT=${CONFIGMAP_ROOT:-/opt/app/config} -CONTAINER_CONFIG=$CONFIGMAP_ROOT/conf/dbc-client.env -REQUESTID=${REQUESTID:-dbc-client} + +PORT=${PORT:-8443} 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'} -AUTH_METHOD=${AUTH_METHOD:-basicAuth} -BA_IDENTITY=${BA_IDENTITY:-dmaap-bc@dmaap-bc.onap.org} -BA_PWD=${BA_PWD:-'demo123456!'} - -config() { - echo "ENTER config" - set -x - if [ ! -d $APP_ROOT ] - then - echo "Expected app root directory $APP_ROOT does not exist" - exit 1 - fi - cd $PEMDIR - pwd - ls -l - echo "AUTH_METHOD=$AUTH_METHOD" - if [ "$AUTH_METHOD" = "basicAuth" ] - then - echo "-u ${BA_IDENTITY}:${BA_PWD}" > $PEMDIR/curl.cred - CURLCRED="-K $PEMDIR/curl.cred" - elif [ -f $CAPEM -a -f $CLIENTPEM -a -f $KEYPEM ] - then - printf "key \"$PEMDIR/$KEYPEM\"\ncacert \"$PEMDIR/$CAPEM\"\ncert \"$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 {} \; - if [ ! -f $CONTAINER_CONFIG ] - then - echo "WARNING: Expected env file $CONTAINER_CONFIG not found. Default behaviors in effect" - else - source $CONTAINER_CONFIG - fi - - if [ "$WAIT_TO_EXIT" != "Y" ] - then - echo "Creating $APP_ROOT/ok_to_exit so no waiting..." - > $APP_ROOT/ok_to_exit - else - echo "Not creating $APP_ROOT/ok_to_exit" - fi - - set +x -} +PARAM=${PARAM:-'useExisting=true'} +REQUESTID=${REQUESTID:-dbc-client} +URL=${URL:-"${PROTO}"://"${DBC}":"${PORT}"/webapi/} +CA_PEM=${CA_PEM:-ca.pem} +KEY_PEM=${KEY_PEM:-key.pem} +CLIENT_PEM=${CLIENT_PEM:-client.pem} +PEM_DIR=${PEM_DIR:-/opt/app/osaaf/local} +CERT_PWD=${CERT_PWD:-'2U[iOZzMHI:.#tdCwlBqc;}S'} -init() { - set -x - echo "ENTER init" - if [ ! -d $CONFIGMAP_ROOT ] - then - echo $CONFIGMAP_ROOT does not exist - return - fi +BA_PWD=${BA_PWD:-'demo123456!'} +AUTH_METHOD=${AUTH_METHOD:-basicAuth} +BA_IDENTITY=${BA_IDENTITY:-dmaap-bc@dmaap-bc.onap.org} - #loop on get /dmaap until we get a good response to indicate other provisioning can continue - rc=${RESP:-999} - while [ $rc != "200" ] - do - sleep 10 - 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 +function xcurl() { + curl -X POST \ + -s "$CURL_CRED" \ + -w "%{http_code}" \ + -H "X-ECOMP-RequestID: $REQUESTID" \ + -H "Content-Type: application/json" "$@" } -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 - +function init_config() { + if [ ! -d "$APP_ROOT" -a ! -d "$CONFIGMAP_ROOT" ]; then + echo "Expected either App root directory $APP_ROOT Or ConfigMap directory $CONFIGMAP_ROOT does not exist." + exit 1 + fi + cd "$PEM_DIR" + if [ "$AUTH_METHOD" = "basicAuth" ]; then + echo "-u ${BA_IDENTITY}:${BA_PWD}" >"$PEM_DIR"/curl.cred + CURL_CRED="-K $PEM_DIR/curl.cred" + elif [ -f "$CA_PEM" -a -f "$CLIENT_PEM" -a -f "$KEY_PEM" ]; then + printf "key \"$PEM_DIR/$KEY_PEM\"\n cacert \"$PEM_DIR/$CA_PEM\"\n cert \"$PEM_DIR/${CLIENT_PEM}:${CERT_PWD}\"" >$PEM_DIR/curl.cred + CURL_CRED="-K $PEM_DIR/curl.cred" + else + echo "PEM files for authorization not found..!" + fi } -doprov() { - - set -x - cd $CONFIGMAP_ROOT - pwd - # order is important in this next list - for uri in dmaap dcaeLocations mr_clusters topics mr_clients dr_nodes feeds dr_pubs dr_subs - do - if [ -d ${uri} ] - then - for j in `ls ${uri}/*.json` - do - echo "POST $j to $uri" - dopost $j $uri - done - fi - done - set +x +function init_dbc_provisioning() { + cd "$CONFIGMAP_ROOT" + for dir in dmaap dcaeLocations mr_clusters topics mr_clients dr_nodes feeds dr_pubs dr_subs; do + if [ -d ${dir} ]; then + for file in $(ls ${dir}/*.json); do + do_http_post "$file" "$dir" + done + fi + done } -delay() { - echo "DELAY=$DELAY" - if [ ! -z "$DELAY" ] - then - sleep $DELAY - fi +function do_http_post() { + RETRY_TIME=60 + if [ -n "$RESP_CACHE" ]; then + RESP="$RESP_CACHE"/"$(echo "${1##*/}" | cut -d "." -f1)"-resp.json + fi + while true; do + if [ "$2" != "feeds" -a "$2" != "topics" ]; then + req_body=$(cat "${1}" | envsubst) + rc=$(xcurl -o "$RESP" -d "$req_body" "${URL}${2}") + if [ "$rc" = "200" -o "$rc" = "201" -o "$rc" = "409" ]; then + echo "Http Post request is successful with response code=$rc" + break + fi + else + rc=$(xcurl -o "$RESP" -d @"${1}" "${URL}${2}"/?"${PARAM}") + if [ "$rc" = "200" -o "$rc" = "201" -o "$rc" = "409" ]; then + echo "Http Post request for feed creation is successful with response code=$rc" + break + fi + fi + echo "$(date): Http Response code=$rc. Will retry after $RETRY_TIME seconds.." + sleep "$RETRY_TIME" + done } -delay -config -init -doprov - -echo "Check $APP_ROOT/ok_to_exit" -while [ ! -f $APP_ROOT/ok_to_exit ] -do - echo "$APP_ROOT/ok_to_exit does not exist. Sticking around for debugging..." - sleep 10 -done -exit 0 +init_config +init_dbc_provisioning diff --git a/dbc-client/src/main/resources/Dockerfile b/dbc-client/src/main/resources/Dockerfile index 9263e80..831d4f2 100644 --- a/dbc-client/src/main/resources/Dockerfile +++ b/dbc-client/src/main/resources/Dockerfile @@ -34,7 +34,7 @@ RUN mkdir -p /usr/local/share/ca-certificates && \ RUN update-ca-certificates # Install curl & openssl -RUN apk add --no-cache curl openssl +RUN apk add --no-cache curl openssl gettext RUN mkdir -p /opt/app/osaaf/local && \ chmod +x /opt/app/dbc-client/bin/* && \ @@ -33,7 +33,7 @@ </parent> <properties> - <revision>2.0.6-SNAPSHOT</revision> + <revision>2.0.7-SNAPSHOT</revision> <multiproject.basedir>${basedir}</multiproject.basedir> <docker.maven.plugin.version>1.0.0</docker.maven.plugin.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> diff --git a/releases/2.0.7.yaml b/releases/2.0.7.yaml new file mode 100644 index 0000000..b0a454f --- /dev/null +++ b/releases/2.0.7.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '2.0.7' +project: 'dmaap-buscontroller' +log-dir: 'dmaap-buscontroller-maven-docker-stage-master/763' +ref: d48858a08b94b62392b1603ca53202e2b48b82d8 +containers: + - name: dmaap/dbc-client + version: 2.0.7-20210712T090259Z diff --git a/version.properties b/version.properties index 6f46efa..00f338b 100644 --- a/version.properties +++ b/version.properties @@ -27,7 +27,7 @@ major=2 minor=0 -patch=6 +patch=7 base_version=${major}.${minor}.${patch} # Release must be completed with git revision # in Jenkins |