diff options
author | efiacor <fiachra.corcoran@est.tech> | 2023-02-14 18:43:24 +0000 |
---|---|---|
committer | efiacor <fiachra.corcoran@est.tech> | 2023-02-15 10:29:26 +0000 |
commit | f0fb309e5bcdb31d86c51e56205f6d977dcb9fac (patch) | |
tree | ebee1ccf63487e41928e62b9840c2c0db6d050b5 | |
parent | 24d5996b9793250276690415bbf365801b88593d (diff) |
[PMSH] Fix dependencies and build script2.2.3-pmsh
onap-gerrit-review: -current-copyright-not-in-all-files
Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Change-Id: Ib94ea16c95e741b9882731f2cb880b67661166b8
Issue-ID: DCAEGEN2-3353
11 files changed, 579 insertions, 22 deletions
diff --git a/components/pm-subscription-handler/.gitignore b/components/pm-subscription-handler/.gitignore index 98ba212b..80574918 100644 --- a/components/pm-subscription-handler/.gitignore +++ b/components/pm-subscription-handler/.gitignore @@ -1,4 +1,4 @@ -mvn-phase-lib.sh +#mvn-phase-lib.sh tox-local.ini *.wgn .pytest_cache/ diff --git a/components/pm-subscription-handler/Changelog.md b/components/pm-subscription-handler/Changelog.md index 2f0b60a2..c768f38c 100755 --- a/components/pm-subscription-handler/Changelog.md +++ b/components/pm-subscription-handler/Changelog.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.2.3] +### Changed +* Fix dependencies and build script process (DCAEGEN2-3353) + ## [2.2.2] ### Changed * Bug fix for Create MG (DCAEGEN2-3118) diff --git a/components/pm-subscription-handler/Dockerfile b/components/pm-subscription-handler/Dockerfile index 9e3ebfe8..612b744f 100644 --- a/components/pm-subscription-handler/Dockerfile +++ b/components/pm-subscription-handler/Dockerfile @@ -1,5 +1,5 @@ # ============LICENSE_START=================================================== -# Copyright (C) 2020 Nordix Foundation. +# Copyright (C) 2020-2023 Nordix Foundation. # Copyright 2020 Deutsche Telekom. All rights reserved. # ============================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END===================================================== -FROM nexus3.onap.org:10001/onap/integration-python:8.0.0 as build +FROM nexus3.onap.org:10001/onap/integration-python:10.1.0 as build LABEL maintainer="lego@est.tech" USER root @@ -32,7 +32,7 @@ COPY requirements.txt ./ RUN pip install --prefix /opt -r requirements.txt --no-cache-dir # Second stage -FROM nexus3.onap.org:10001/onap/integration-python:8.0.0 +FROM nexus3.onap.org:10001/onap/integration-python:10.1.0 COPY --from=build /opt /opt @@ -43,7 +43,7 @@ ARG group=onap # set PATH & PYTHONPATH vars ENV APPDIR="/opt/app/pmsh" \ LD_LIBRARY_PATH=/opt/lib \ - PYTHONPATH=${APPDIR}/mod:/opt/lib/python3.9/site-packages \ + PYTHONPATH=${APPDIR}/mod:/opt/lib/python3.10/site-packages \ PATH=$PATH:${APPDIR}/bin \ LOGS_PATH="/var/log/ONAP/dcaegen2/services/pmsh" \ LOGGER_CONFIG="/opt/app/pmsh/log_config.yaml" diff --git a/components/pm-subscription-handler/mvn-phase-lib.sh b/components/pm-subscription-handler/mvn-phase-lib.sh new file mode 100644 index 00000000..58de1123 --- /dev/null +++ b/components/pm-subscription-handler/mvn-phase-lib.sh @@ -0,0 +1,553 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2023 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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========================================================= + + +#MVN_PROJECT_MODULEID="$1" +#MVN_PHASE="$2" +#PROJECT_ROOT=$(dirname $0) + +FQDN="${MVN_PROJECT_GROUPID}.${MVN_PROJECT_ARTIFACTID}" +if [ "$MVN_PROJECT_MODULEID" == "__" ]; then + MVN_PROJECT_MODULEID="" +fi + +if [[ "$MVN_PROJECT_VERSION" == *SNAPSHOT ]]; then + echo "=> for SNAPSHOT artifact build" + MVN_DEPLOYMENT_TYPE='SNAPSHOT' +else + echo "=> for STAGING/RELEASE artifact build" + MVN_DEPLOYMENT_TYPE='STAGING' +fi +echo "MVN_DEPLOYMENT_TYPE is [$MVN_DEPLOYMENT_TYPE]" + + +TIMESTAMP=$(date +%C%y%m%dT%H%M%S) + +# expected environment variables +if [ -z "${MVN_NEXUSPROXY}" ]; then + echo "MVN_NEXUSPROXY environment variable not set. Cannot proceed" + exit +fi +MVN_NEXUSPROXY_HOST=$(echo "$MVN_NEXUSPROXY" |cut -f3 -d'/' | cut -f1 -d':') +echo "=> Nexus Proxy at $MVN_NEXUSPROXY_HOST, $MVN_NEXUSPROXY" + +if [ -z "$WORKSPACE" ]; then + WORKSPACE=$(pwd) +fi + +export SETTINGS_FILE=${SETTINGS_FILE:-$HOME/.m2/settings.xml} + +RELEASE_TAG=${MVN_RELEASE_TAG:-R11} +if [ "$RELEASE_TAG" == "R1" ]; then + unset RELEASE_TAG +fi + + +# mvn phase in life cycle +MVN_PHASE="$2" + +echo "MVN_RELEASE_TAG is [$MVN_RELEASE_TAG]" +echo "MVN_PROJECT_MODULEID is [$MVN_PROJECT_MODULEID]" +echo "MVN_PHASE is [$MVN_PHASE]" +echo "MVN_PROJECT_GROUPID is [$MVN_PROJECT_GROUPID]" +echo "MVN_PROJECT_ARTIFACTID is [$MVN_PROJECT_ARTIFACTID]" +echo "MVN_PROJECT_VERSION is [$MVN_PROJECT_VERSION]" +echo "MVN_NEXUSPROXY is [$MVN_NEXUSPROXY]" +echo "MVN_RAWREPO_BASEURL_UPLOAD is [$MVN_RAWREPO_BASEURL_UPLOAD]" +echo "MVN_RAWREPO_BASEURL_DOWNLOAD is [$MVN_RAWREPO_BASEURL_DOWNLOAD]" +MVN_RAWREPO_HOST=$(echo "$MVN_RAWREPO_BASEURL_UPLOAD" | cut -f3 -d'/' |cut -f1 -d':') +echo "MVN_RAWREPO_HOST is [$MVN_RAWREPO_HOST]" +echo "MVN_RAWREPO_SERVERID is [$MVN_RAWREPO_SERVERID]" +echo "MVN_DOCKERREGISTRY_SNAPSHOT is [$MVN_DOCKERREGISTRY_SNAPSHOT]" +echo "MVN_DOCKERREGISTRY_PUBLIC is [$MVN_DOCKERREGISTRY_PUBLIC]" +echo "MVN_DOCKERREGISTRY_RELEASE is [$MVN_DOCKERREGISTRY_RELEASE]" +echo "MVN_PYPISERVER_SERVERID [$MVN_PYPISERVER_SERVERID]" +echo "MVN_PYPISERVER_BASEURL is [$MVN_PYPISERVER_BASEURL]" + + + +clean_templated_files() +{ + TEMPLATE_FILES=$(find . -name "*-template") + for F in $TEMPLATE_FILES; do + F2=$(echo "$F" | sed 's/-template$//') + rm -f "$F2" + done +} +clean_tox_files() +{ + TOX_FILES=$(find . -name ".tox") + TOX_FILES="$TOX_FILES $(find . -name 'venv-tox')" + for F in $TOX_FILES; do + rm -rf "$F" + done +} + +expand_templates() +{ + set +x + # set up env variables, get ready for template resolution + # NOTE: CCSDK artifacts do not distinguish REALESE vs SNAPSHOTs + export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.plugins" + export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.plugins" + export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.blueprints" + export ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.ccsdk.platform.blueprints" + + + if [ -z "$RELEASE_TAG" ]; then + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/releases" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/snapshots" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/releases" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/snapshots" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/releases" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/snapshots" + else + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/$RELEASE_TAG" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2/$RELEASE_TAG" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/$RELEASE_TAG" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.plugins/$RELEASE_TAG" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/$RELEASE_TAG" + export ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_snapshots="$MVN_RAWREPO_BASEURL_DOWNLOAD/org.onap.dcaegen2.platform.blueprints/$RELEASE_TAG" + fi + + + export ONAPTEMPLATE_PYPIURL_org_onap_dcaegen2="${MVN_PYPISERVER_BASEURL}" + + # docker registry templates are for poll, so use PUBLIC registry + export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_releases="${MVN_DOCKERREGISTRY_PUBLIC}" + export ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_snapshots="${MVN_DOCKERREGISTRY_PUBLIC}" + + # Mvn repo + export ONAPTEMPLATE_MVN_org_onap_dcaegen2_analytics_tca_snapshots="${MVN_NEXUSPROXY}/service/local/repositories/snapshots/content/org/onap/dcaegen2/analytics/tca" + export ONAPTEMPLATE_MVN_org_onap_dcaegen2_analytics_tca_staging="${MVN_NEXUSPROXY}/service/local/repositories/staging/content/org/onap/dcaegen2/analytics/tca" + export ONAPTEMPLATE_MVN_org_onap_dcaegen2_analytics_tca_releases="${MVN_NEXUSPROXY}/service/local/repositories/releases/content/org/onap/dcaegen2/analytics/tca" + + + export ONAPTEMPLATE_STANDARD_INPUTS_TYPES=" # standard inputs list + centos7image_id: + type: string + ubuntu1604image_id: + type: string + flavor_id: + type: string + security_group: + type: string + public_net: + type: string + private_net: + type: string + openstack: {} + keypair: + type: string + key_filename: + type: string + location_prefix: + type: string + location_domain: + type: string + codesource_url: + type: string + codesource_version: + type: string" + + + TEMPLATES=$(env |grep ONAPTEMPLATE | sed 's/=.*//' | sort -u) + if [ -z "$TEMPLATES" ]; then + echo "No template variables found!" + return 0 + fi + + TEMPLATE_FILES=$(find . -name "*-template") + for F in $TEMPLATE_FILES; do + F2=$(echo "$F" | sed 's/-template$//') + cp -p "$F" "$F2" + chmod u+w "$F2" + + echo "====> Resolving the following template from environment variables " + echo "$TEMPLATES" + for KEY in $TEMPLATES; do + VALUE1=$(eval 'echo "$'"$KEY"'"' | sed 1q) + VALUE2=$(eval 'echo "$'"$KEY"'"' | sed -e 's/\//\\\//g' -e 's/$/\\/' -e '$s/\\$//') + + echo "======> Resolving template $KEY to value $VALUE1 for file $F2" + sed -i "s/{{[[:space:]]*$KEY[[:space:]]*}}/$VALUE2/g" "$F2" + done + done + echo "====> Done template resolving" +} + +test_templates() +{ + # make certain that the type references exist + TMP=$(mktemp) + trap 'rm -f $TMP' 0 1 2 3 15 + + echo Verify that all of the import URLs are correct + find . -name '*-template' | sed -e 's/-template$//' | + while read file + do + egrep '^ - .?https?://' < "$file" + done | awk '{print $2}' | sed -e 's/"//g' | sort -u | + while read url + do + curl -L -w '%{http_code}' -s -o /dev/null "$url" > "$TMP" + case $(< "$TMP") in + 2* ) ;; + * ) echo ">>>>>>>>>>>>>>>> $url not found <<<<<<<<<<<<<<<<" ;; + esac + done + + echo Verify that the inputs are correct + PATH=$PATH:$PWD/check-blueprint-vs-input/bin + find . -name '*-template' | sed -e 's/-template$//' | + while read blueprint + do + check-blueprint-vs-input -b "$blueprint" -i check-blueprint-vs-input/lib/sample-inputs.yaml || true + done +} + + +run_tox_test() +{ + set -e -x + CURDIR=$(pwd) + TOXINIS=$(find . -name "tox.ini") + for TOXINI in "${TOXINIS[@]}"; do + DIR=$(dirname "$TOXINI") + cd "${CURDIR}/${DIR}" + rm -rf ./venv-tox ./.tox + python3 -m venv ./venv-tox + source ./venv-tox/bin/activate + + #pip3 install pip==9.0.3 + pip3 install --upgrade argparse + #pip3 install tox==2.9.1 + if [ "$RUN_BLACK" = yes ] + then + pip3 install black + python3 -m black --line-length 120 --check . + fi + pip3 freeze + tox + deactivate + rm -rf ./venv-tox ./.tox + done +} + +build_wagons() +{ + rm -rf ./*.wgn venv-pkg + SETUPFILES=$(find . -name "setup.py") + + python3 -m venv ./venv-pkg + source ./venv-pkg/bin/activate + + pip3 install --upgrade pip + pip3 install wagon + + CURDIR=$(pwd) + for SETUPFILE in $SETUPFILES; do + PLUGIN_DIR=$(dirname "$SETUPFILE") + PLUGIN_NAME=$(grep 'name' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9a-zA-Z\.]*//g') + PLUGIN_VERSION=$(grep 'version' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9\.]*//g') + + echo "In $PLUGIN_DIR, build plugin $PLUGIN_NAME, version $PLUGIN_VERSION" + + wagon create -r "${PLUGIN_DIR}/requirements.txt" --format tar.gz "${PLUGIN_DIR}" + + PKG_FILE_NAMES=( "${PLUGIN_NAME}-${PLUGIN_VERSION}"*.wgn ) + echo Built package: "${PKG_FILE_NAMES[@]}" + cd "$CURDIR" + done + + deactivate + rm -rf venv-pkg +} + +build_archives_for_wagons() +{ + rm -rf ./*.tgz ./*.zip venv-pkg + + SETUPFILES=$(find "$(pwd)" -name "setup.py") + CURDIR=$(pwd) + for SETUPFILE in $SETUPFILES; do + PLUGIN_FULL_DIR=$(dirname "$SETUPFILE") + PLUGIN_BASE_DIR=$(basename "$PLUGIN_FULL_DIR") + PLUGIN_NAME=$(grep 'name' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9a-zA-Z\.]*//g') + PLUGIN_VERSION=$(grep 'version' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9\.]*//g') + + cd "${PLUGIN_FULL_DIR}"/.. + echo "In $(pwd), build plugin zip $PLUGIN_NAME, version $PLUGIN_VERSION" + + zip -r "${PLUGIN_NAME}-${PLUGIN_VERSION}.zip" "./${PLUGIN_BASE_DIR}" + tar -czvf "${PLUGIN_NAME}-${PLUGIN_VERSION}.tgz" "./${PLUGIN_BASE_DIR}" + + echo "Built archives for package ${PLUGIN_NAME}-${PLUGIN_VERSION} at $(pwd)" + cd "$CURDIR" + done +} + + +upload_raw_file() +{ + # Extract the username and password to the nexus repo from the settings file + USER=$(xpath -q -e "//servers/server[id='$MVN_RAWREPO_SERVERID']/username/text()" "$SETTINGS_FILE") + PASS=$(xpath -q -e "//servers/server[id='$MVN_RAWREPO_SERVERID']/password/text()" "$SETTINGS_FILE") + NETRC=$(mktemp) + echo "machine $MVN_RAWREPO_HOST login $USER password $PASS" > "$NETRC" + + REPO="$MVN_RAWREPO_BASEURL_UPLOAD" + + OUTPUT_FILE=$1 + EXT=$(echo "$OUTPUT_FILE" | rev |cut -f1 -d '.' |rev) + if [ "$EXT" == 'yaml' ]; then + OUTPUT_FILE_TYPE='text/x-yaml' + elif [ "$EXT" == 'sh' ]; then + OUTPUT_FILE_TYPE='text/x-shellscript' + elif [ "$EXT" == 'gz' ]; then + OUTPUT_FILE_TYPE='application/gzip' + elif [ "$EXT" == 'tgz' ]; then + OUTPUT_FILE_TYPE='application/gzip' + elif [ "$EXT" == 'zip' ]; then + OUTPUT_FILE_TYPE='application/zip' + elif [ "$EXT" == 'wgn' ]; then + OUTPUT_FILE_TYPE='application/gzip' + else + OUTPUT_FILE_TYPE='application/octet-stream' + fi + + # for multi module projects, the raw repo path must match with project name, not project + module + # FQDN is project + module + # GROUPID is project name + if [ "$MVN_PROJECT_ARTIFACTID" == "$MVN_PROJECT_MODULEID" ]; then + PROJECT_NAME=${MVN_PROJECT_GROUPID} + else + PROJECT_NAME=${FQDN} + fi + + if [ -z "$RELEASE_TAG" ]; then + SEND_TO="${REPO}/${PROJECT_NAME}" + else + SEND_TO="${REPO}/${PROJECT_NAME}/${RELEASE_TAG}" + fi + + if [ ! -z "$2" ]; then + SEND_TO="$SEND_TO/$2" + fi + + echo "Sending ${OUTPUT_FILE} to Nexus: ${SEND_TO}" + curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}-${TIMESTAMP}" + curl -vkn --netrc-file "${NETRC}" --upload-file "${OUTPUT_FILE}" -X PUT -H "Content-Type: $OUTPUT_FILE_TYPE" "${SEND_TO}/${OUTPUT_FILE}" +} + +upload_wagon_archives() +{ + SETUPFILES=$(find "$(pwd)" -name "setup.py") + CURDIR=$(pwd) + for SETUPFILE in $SETUPFILES; do + PLUGIN_FULL_DIR=$(dirname "$SETUPFILE") + PLUGIN_BASE_DIR=$(basename "$PLUGIN_FULL_DIR") + PLUGIN_NAME=$(grep 'name' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9a-zA-Z\.]*//g') + PLUGIN_VERSION=$(grep 'version' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9\.]*//g') + + cd "${PLUGIN_FULL_DIR}"/.. + echo "In $(pwd), upload zip archive for $PLUGIN_NAME, version $PLUGIN_VERSION" + ARCHIVE_FILE_NAME="${PLUGIN_NAME}-${PLUGIN_VERSION}.zip" + if [ -z "$ARCHIVE_FILE_NAME" ]; then + echo "!!! No zip archive file found ${ARCHIVE_FILE_NAME}" + exit -1 + fi + upload_raw_file "${ARCHIVE_FILE_NAME}" "${PLUGIN_NAME}/${PLUGIN_VERSION}" + + echo "In $(pwd), upload tgz archive for $PLUGIN_NAME, version $PLUGIN_VERSION" + ARCHIVE_FILE_NAME="${PLUGIN_NAME}-${PLUGIN_VERSION}.tgz" + if [ -z "$ARCHIVE_FILE_NAME" ]; then + echo "!!! No tgz archive file found ${ARCHIVE_FILE_NAME}" + exit -1 + fi + upload_raw_file "${ARCHIVE_FILE_NAME}" "${PLUGIN_NAME}/${PLUGIN_VERSION}" + + cd "${CURDIR}" + done +} + +upload_wagons_and_type_yamls() +{ + SETUPFILES=$(find . -name "setup.py") + + CURDIR=$(pwd) + for SETUPFILE in $SETUPFILES; do + PLUGIN_DIR=$(dirname "$SETUPFILE") + PLUGIN_NAME=$(grep 'name' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9a-zA-Z\.]*//g') + PLUGIN_VERSION=$(grep 'version' "$SETUPFILE" | cut -f2 -d'=' | sed 's/[^0-9\.]*//g') + PLUGIN_VERSION_MAJOR=$(echo "$PLUGIN_VERSION" | cut -f1 -d'.') + PLUGIN_VERSION_MAJOR_MINOR=$(echo "$PLUGIN_VERSION" | cut -f1-2 -d'.') + + echo "Found setup file in $PLUGIN_DIR, for plugin $PLUGIN_NAME version $PLUGIN_VERSION" + + TYPEFILE_NAME=$(grep -R "package_name:[[:space:]]*${PLUGIN_NAME}" | cut -f1 -d ':') + if [ -z "$TYPEFILE_NAME" ]; then + echo "!!! No typefile found with matching package name $PLUGIN_NAME" + exit -1 + fi + NEWFILENAME="${PLUGIN_NAME}"_types.yaml + if [ "$TYPEFILE_NAME" != "$NEWFILENAME" ]; then + echo "copy typefile to standard naming" + cp -f "$TYPEFILE_NAME" "$NEWFILENAME" + fi + + TYPEFILE_PACKAGE_VERSION=$(grep -R 'package_version' "$TYPEFILE_NAME" |cut -f2 -d ':' |sed -r 's/\s+//g') + WAGONFILE_NAME=$(ls -1 "${PLUGIN_NAME}"-"${TYPEFILE_PACKAGE_VERSION}"-*.wgn) + if [ -z "$WAGONFILE_NAME" ]; then + echo "!!! No wagonfile found with matching package name and version as required in typefile: " + echo " $TYPEFILE_NAME plugin $PLUGIN_NAME package version ${TYPEFILE_PACKAGE_VERSION}" + exit -1 + fi + + upload_raw_file "${NEWFILENAME}" "${PLUGIN_NAME}/${PLUGIN_VERSION}" + upload_raw_file "${WAGONFILE_NAME}" "${PLUGIN_NAME}/${PLUGIN_VERSION}" + + rm -r "$WAGONFILE_NAME" + if [ "$TYPEFILE_NAME" != "$NEWFILENAME" ]; then + rm -f "$NEWFILENAME" + fi + done +} + +upload_files_of_extension() +{ + FILES=$(ls -1 ./*."$1") + for F in $FILES ; do + upload_raw_file "$F" "$2" + done +} +upload_files_of_extension_recursively() +{ + FILES=$(find . -name "*.$1") + for F in $FILES ; do + upload_raw_file "$F" "$2" + done +} + + +generate_pypirc_then_publish() +{ + set +x + USER=$(xpath -e "//servers/server[id='$MVN_PYPISERVER_SERVERID']/username/text()" "$SETTINGS_FILE") + PASS=$(xpath -e "//servers/server[id='$MVN_PYPISERVER_SERVERID']/password/text()" "$SETTINGS_FILE") + + if [[ "$MVN_PYPISERVER_BASEURL" != */ ]]; then + MVN_PYPISERVER_BASEURL="${MVN_PYPISERVER_BASEURL}/" + fi + + + cat > ~/.pypirc <<EOL +[distutils] +index-servers = + $MVN_PYPISERVER_SERVERID + +[$MVN_PYPISERVER_SERVERID] +repository: $MVN_PYPISERVER_BASEURL +username: $USER +password: $PASS +EOL + + # this may fail if a package of same version exists + python setup.py sdist register -r "$MVN_PYPISERVER_SERVERID" upload -r "$MVN_PYPISERVER_SERVERID" + set -x +} + + + +# following the https://wiki.onap.org/display/DW/Independent+Versioning+and+Release+Process +#IndependentVersioningandReleaseProcess-StandardizedDockerTagging +build_and_push_docker() +{ + # Old tagging + #IMAGENAME="onap/${FQDN}.${MVN_PROJECT_MODULEID}" + # new tagging + ENDID=$(echo $FQDN | rev | cut -f1 -d '.' |rev) + if [ "$ENDID" == "${MVN_PROJECT_MODULEID}" ]; then + #IMAGENAME="onap/${FQDN/org.onap./}" + IMAGENAME="onap/${FQDN}" + else + #IMAGENAME="onap/${FQDN/org.onap./}.${MVN_PROJECT_MODULEID}" + IMAGENAME="onap/${FQDN}.${MVN_PROJECT_MODULEID}" + fi + + IMAGENAME=$(echo "$IMAGENAME" | sed -e 's/_*$//g' -e 's/\.*$//g') + IMAGENAME=$(echo "$IMAGENAME" | tr '[:upper:]' '[:lower:]') + + # use the major and minor version of the MVN artifact version as docker image version + VERSION="${MVN_PROJECT_VERSION//[^0-9.]/}" + VERSION2=$(echo "$VERSION" | cut -f1-2 -d'.') + + LFQI="${IMAGENAME}:${VERSION}-${TIMESTAMP}"Z + # build a docker image + docker build --rm -f ./Dockerfile -t "${LFQI}" ./ + + # all local builds push to SNAPSHOT repo + REPO="" + if [ $MVN_DEPLOYMENT_TYPE == "SNAPSHOT" ]; then + REPO=$MVN_DOCKERREGISTRY_SNAPSHOT + elif [ $MVN_DEPLOYMENT_TYPE == "STAGING" ]; then + REPO=$MVN_DOCKERREGISTRY_SNAPSHOT + else + echo "Fail to determine DEPLOYMENT_TYPE" + REPO=$MVN_DOCKERREGISTRY_SNAPSHOT + fi + echo "DEPLOYMENT_TYPE is: $MVN_DEPLOYMENT_TYPE, repo is $REPO" + + if [ ! -z "$REPO" ]; then + USER=$(xpath -e "//servers/server[id='$REPO']/username/text()" "$SETTINGS_FILE") + PASS=$(xpath -e "//servers/server[id='$REPO']/password/text()" "$SETTINGS_FILE") + if [ -z "$USER" ]; then + echo "Error: no user provided" + fi + if [ -z "$PASS" ]; then + echo "Error: no password provided" + fi + [ -z "$PASS" ] && PASS_PROVIDED="<empty>" || PASS_PROVIDED="<password>" + echo docker login "$REPO" -u "$USER" -p "$PASS_PROVIDED" + + set +x + docker login "$REPO" -u "$USER" -p "$PASS" + set -x + + # local tag is imagename:version-timestamp + OLDTAG="${LFQI}" + # three tags are pushed: + # {imagename}:{semver}-SNAPSHOT-{timestamp}Z this is what CIMAN-132 asks + # {imagename}:{semver} latest of current version, for testing + # {imagename}:latest latest of all, used mainly by csit + # LFQI="${IMAGENAME}:${VERSION}-${TIMESTAMP}"Z + + + + # Updating tags for ${REPO}/${IMAGENAME}:${VERSION} to include STAGING-latest; and adding new tag for major:minor-STAGING-latest + PUSHTAGS="${REPO}/${IMAGENAME}:${VERSION}-SNAPSHOT-${TIMESTAMP}Z ${REPO}/${IMAGENAME}:${VERSION2}-STAGING-latest ${REPO}/${IMAGENAME}:${VERSION}-STAGING-latest ${REPO}/${IMAGENAME}:latest" + + for NEWTAG in ${PUSHTAGS} + do + echo "tagging ${OLDTAG} to ${NEWTAG}" + docker tag "${OLDTAG}" "${NEWTAG}" + echo "pushing ${NEWTAG}" + docker push "${NEWTAG}" + OLDTAG="${NEWTAG}" + done + fi +} diff --git a/components/pm-subscription-handler/mvn-phase-script.sh b/components/pm-subscription-handler/mvn-phase-script.sh index f51fa1ca..9737db1a 100755 --- a/components/pm-subscription-handler/mvn-phase-script.sh +++ b/components/pm-subscription-handler/mvn-phase-script.sh @@ -1,6 +1,6 @@ #!/bin/bash # ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. +# Copyright (C) 2019-2023 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ PROJECT_ROOT=$(dirname $0) echo "MVN_RELEASE_TAG is set to [$MVN_RELEASE_TAG]" -RELEASE_TAG=${MVN_RELEASE_TAG:-R6} +RELEASE_TAG=${MVN_RELEASE_TAG:-R11} if [[ "$RELEASE_TAG" != "R1" ]]; then RELEASE_TAGGED_DIR="${RELEASE_TAG}/" else diff --git a/components/pm-subscription-handler/pmsh_service/mod/exit_handler.py b/components/pm-subscription-handler/pmsh_service/mod/exit_handler.py index 69f2408f..f558f365 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/exit_handler.py +++ b/components/pm-subscription-handler/pmsh_service/mod/exit_handler.py @@ -1,5 +1,5 @@ # ============LICENSE_START=================================================== -# Copyright (C) 2020-2022 Nordix Foundation. +# Copyright (C) 2020-2023 Nordix Foundation. # ============================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -49,7 +49,8 @@ class ExitHandler: logger.info(f'Cancelling thread {thread.name}') thread.cancel() logger.info('Closing all DB connections') - db.session.bind.dispose() + if db.session.bind is not None: + db.session.bind.dispose() db.session.close() db.engine.dispose() ExitHandler.shutdown_signal_received = True diff --git a/components/pm-subscription-handler/pmsh_service/pmsh_service_main.py b/components/pm-subscription-handler/pmsh_service/pmsh_service_main.py index dbc58e51..fcddde6a 100755 --- a/components/pm-subscription-handler/pmsh_service/pmsh_service_main.py +++ b/components/pm-subscription-handler/pmsh_service/pmsh_service_main.py @@ -1,5 +1,5 @@ # ============LICENSE_START=================================================== -# Copyright (C) 2019-2022 Nordix Foundation. +# Copyright (C) 2019-2023 Nordix Foundation. # ============================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ def main(): try: app = create_app() app.app_context().push() - db.create_all(app=app) + db.create_all() pmsh_app_conf = AppConfig() except Exception as e: logger.error(f'Failed to get config and create application: {e}', exc_info=True) diff --git a/components/pm-subscription-handler/pom.xml b/components/pm-subscription-handler/pom.xml index db570202..5e1ee0f9 100644 --- a/components/pm-subscription-handler/pom.xml +++ b/components/pm-subscription-handler/pom.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- # ============LICENSE_START======================================================= -# Copyright (C) 2019-2022 Nordix Foundation. +# Copyright (C) 2019-2023 Nordix Foundation. # Copyright 2020 Deutsche Telekom. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,7 @@ <groupId>org.onap.dcaegen2.services</groupId> <artifactId>pmsh</artifactId> <name>dcaegen2-services-pm-subscription-handler</name> - <version>2.2.2-SNAPSHOT</version> + <version>2.2.3-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.sources>.</sonar.sources> diff --git a/components/pm-subscription-handler/setup.py b/components/pm-subscription-handler/setup.py index 4397a243..a50239dc 100644 --- a/components/pm-subscription-handler/setup.py +++ b/components/pm-subscription-handler/setup.py @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (C) 2019-2022 Nordix Foundation. +# Copyright (C) 2019-2023 Nordix Foundation. # Copyright (C) 2021 AT&T Property. All rights reserved. # Copyright 2020 Deutsche Telekom. All rights reserved. # ================================================================================ @@ -22,7 +22,7 @@ from setuptools import setup, find_packages setup( name="pm_subscription_handler", - version="2.2.2", + version="2.2.3", packages=find_packages(), author="lego@est.tech", author_email="lego@est.tech", @@ -34,12 +34,11 @@ setup( "requests==2.22.0", "tenacity==6.0.0", "connexion==2.5.0", - "MarkupSafe==2.0.1", - "flask_sqlalchemy==2.4.1", - "Flask==1.1.4", + "flask_sqlalchemy==3.0.1", + "Flask==2.2", "tornado==6.1", "swagger-ui-bundle==0.0.6", - "psycopg2-binary==2.8.6", + "psycopg2-binary==2.9.5", "onap_dcae_cbs_docker_client==2.2.1", "onappylog==1.0.9", "ruamel.yaml==0.16.10", diff --git a/components/pm-subscription-handler/tox.ini b/components/pm-subscription-handler/tox.ini index 38acbbb8..9ee1c7df 100644 --- a/components/pm-subscription-handler/tox.ini +++ b/components/pm-subscription-handler/tox.ini @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. +# Copyright (C) 2019-2023 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ # ============LICENSE_END========================================================= [tox] -envlist = flake8,py39 +envlist = flake8,py39,py310 skip_missing_interpreters = true [testenv] diff --git a/components/pm-subscription-handler/version.properties b/components/pm-subscription-handler/version.properties index e50aee35..cf8d147e 100644 --- a/components/pm-subscription-handler/version.properties +++ b/components/pm-subscription-handler/version.properties @@ -1,6 +1,6 @@ major=2 minor=2 -patch=2 +patch=3 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT |