diff options
author | k.kedron <k.kedron@partner.samsung.com> | 2021-04-26 12:22:08 +0200 |
---|---|---|
committer | k.kedron <k.kedron@partner.samsung.com> | 2021-06-28 13:46:10 +0200 |
commit | 14edec94f9110bd9a73823bd042e4e714018ebb2 (patch) | |
tree | 401cd22130ac6955edc1f1a41218249e3f5a9336 /operations/scripts | |
parent | 5ec59f8ea2751b78797424e0a224b9cd6f1cf1b7 (diff) |
Add a1-pe-sim packages
Add a1-pe-sim cba
Add data-types for cba
Add a1-pe-sim cnf csar
Add helm chart for cnf
mvn pom.xml to build artifacts
Issue-ID: INT-1887
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: Ia72fd7cb240092b7be759456ce4d49136864e85d
Diffstat (limited to 'operations/scripts')
-rwxr-xr-x | operations/scripts/enrich.sh | 158 | ||||
-rwxr-xr-x[-rw-r--r--] | operations/scripts/k8s_get_node_ip.sh | 0 | ||||
-rwxr-xr-x | operations/scripts/onboard-cba.sh | 23 |
3 files changed, 181 insertions, 0 deletions
diff --git a/operations/scripts/enrich.sh b/operations/scripts/enrich.sh new file mode 100755 index 0000000..0e3921f --- /dev/null +++ b/operations/scripts/enrich.sh @@ -0,0 +1,158 @@ +#!/bin/bash + +usage() { + echo "Usage:" + echo " ./enrich.sh IP [BLUEPRINT_PROCESSOR_PORT] [CBA_PATH] [DD_PATH]" + echo + echo "Parameters:" + echo "IP - ip of the k8s instance" + echo "BLUEPRINT_PROCESSOR_PORT (default 30499) - exposed cds-blueprints-processor-http service port" + echo "CBA_PATH (default ./oran-sim-cba) - path for folder with CBA" + echo "DD_PATH (default ./oran-sim-cba-data-dictionary) - path for folder with DD required to execute the enrichment" + echo + echo "Environment variables respected:" + echo "ENABLE_PUBLISHING - if set to 1, script will also try to upload CBA to CDS after successful enrichment." + echo " Use only if you're sure what you're doing" + echo "SKIP_BOOTSTRAP - if set to 1, script won't try to 'bootstrap' CDS for enrichment (operation needed just once per lifecycle of CDS instance)." + echo "SKIP_DD_UPLOAD - if set to 1, script won't try to upload DataDictionary files." + echo " This can be used to speed up a bit subsequent attempts to enrich when there were no changes to Data Dictionary files in the meantime." + exit 1 +} + +# Wrapper function log messages +log() { + echo -e "$L_GREEN$*$L_RESET" >&2 +} + + +# Curl wrapper with improved error handling and embed generic flags +# Safe to use with -o and -f (muted) +cds_curl() { + local res code preserve_res + declare -a cmd=(curl -sS -H 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' -w "%{http_code}") + res=$(mktemp) + cmd+=(-o "${res}") + + while test $# -gt 0; do + case "$1" in + -f|--fail) + shift + ;; + -o) + preserve_res="$2" + shift 2 + ;; + --output) + preserve_res="${1##*=}" + shift + ;; + *) + cmd+=("$1") + shift + ;; + esac + done + + + log "Running: $L_BOLD'${cmd[*]}'" + if ! code="$("${cmd[@]}")"; then + log "Curl Failure: '$code'; body:" + cat "$res" + rm -f "$res" + return 1 + fi + if ! [[ "${code}" =~ 20* ]]; then + log "Remote responded with code $code; body:" + cat "$res" + rm -f "$res" + return 1 + fi + if test -n "${preserve_res:-}"; then + mv "$res" "$preserve_res" + else + cat "$res" + rm -f "$res" + fi +} + +if test -t 1 && test -t 2; then + L_BOLD=$(tput bold) + L_GREEN=$(tput setaf 2) + L_RESET=$(tput sgr0) +else + L_BOLD= + L_GREEN= + L_RESET= +fi + +IP=$1 +if [ -z "${IP}" ]; then + usage +fi + +set -euo pipefail + +# SINCE FRANKFURT RELEASE THE BLUEPRINT_PROCESSOR POD SERVICE MUST BE EXPOSED +DEFAULT_PROCESSOR_PORT=30499 +BLUEPRINT_PROCESSOR_PORT="${2:-$DEFAULT_PROCESSOR_PORT}" +BLUEPRINT_PROCESSOR_URI=http://${IP}:${BLUEPRINT_PROCESSOR_PORT} + +URL_BOOTSTRAP=${BLUEPRINT_PROCESSOR_URI}/api/v1/blueprint-model/bootstrap +URL_ENRICH=${BLUEPRINT_PROCESSOR_URI}/api/v1/blueprint-model/enrich +URL_PUBLISH=${BLUEPRINT_PROCESSOR_URI}/api/v1/blueprint-model/publish +URL_DD=${BLUEPRINT_PROCESSOR_URI}/api/v1/dictionary + +CBA_PATH="${3:-./oran-sim-cba}" +DD_PATH="${4:-./oran-sim-cba-data-dictionary}" + +CBA_FILE=tmp/cba.zip +CBA_ENRICHED_FILE=tmp/cba_enriched.zip + +CBA_ZIP=${CBA_PATH}/${CBA_FILE} +CBA_ZIP_ENRICHED=${CBA_PATH}/${CBA_ENRICHED_FILE} + +if [ "${SKIP_BOOTSTRAP:-0}" == "1" ]; then + log "Skipping Bootstrap." +else + log "Bootstraping CDS..." + cds_curl -X POST "$URL_BOOTSTRAP" -H 'Content-Type: application/json' \ + -d '{ "loadModelType": true, "loadResourceDictionary": true, "loadCBA": false }' + log "Success" +fi +log "\n" + +if [ "${SKIP_DD_UPLOAD:-0}" == "1" ]; then + log "Skipping Data Dictionary upload." +else + for f in "$DD_PATH"/*.json; do + log "Pushing data dictionary '$f'" + cds_curl -X POST "$URL_DD" -H 'Content-Type: application/json' -d "@$f" + log + done +fi +log "\n" + + +[ ! -d "$(dirname "$CBA_ZIP")" ] && mkdir -p "$(dirname "$CBA_ZIP")" +[ -f "$CBA_ZIP" ] && rm "$CBA_ZIP" +[ -f "$CBA_ZIP_ENRICHED" ] && rm "$CBA_ZIP_ENRICHED" + +pushd "$CBA_PATH" || exit +zip -uqr $CBA_FILE . --exclude=*.git* +popd || exit + +log "Doing enrichment..." +file "$CBA_ZIP" +cds_curl -X POST "$URL_ENRICH" -H 'Content-Type: multipart/form-data' -F file=@"$CBA_ZIP" -o "$CBA_ZIP_ENRICHED" +file "$CBA_ZIP_ENRICHED" +log "Success" +log "\n" + +if [ "${ENABLE_PUBLISHING:-0}" == "1" ]; then + log "Publishing..." + cds_curl -X POST "$URL_PUBLISH" -H 'Content-Type: multipart/form-data' -F file=@"$CBA_ZIP_ENRICHED" + log + log "Success" +else + log "Publishing skipped. Enable by calling script with environment variable ENABLE_PUBLISHING=1" +fi diff --git a/operations/scripts/k8s_get_node_ip.sh b/operations/scripts/k8s_get_node_ip.sh index 4f423e8..4f423e8 100644..100755 --- a/operations/scripts/k8s_get_node_ip.sh +++ b/operations/scripts/k8s_get_node_ip.sh diff --git a/operations/scripts/onboard-cba.sh b/operations/scripts/onboard-cba.sh new file mode 100755 index 0000000..9c80d58 --- /dev/null +++ b/operations/scripts/onboard-cba.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright (C) 2019 by Samsung Electronics Co., Ltd. +# +# This software is the confidential and proprietary information of Samsung Electronics co., Ltd. +# ("Confidential Information"). You shall not disclose such Confidential Information and shall use +# it only in accordance with the terms of the license agreement you entered into with Samsung. + +# +# Onboards CDS model into CDS runtime. CDS model package file is called CBA (CDS Model Package). +# +set -e + +# Parameters +# $1 Path to cba zip file (Optional) +# $2 Kubernetes node ip (Optional) + + +CBA_ZIP=${1:-../examples/vnf/vnf-simulator-for-onap-me/cds/cba/onap-me-cba.zip} +if [[ "$1" == "" ]]; then + echo "CBA zip not provided. Using default: ${CBA_ZIP}" +fi +NODE_IP=${2:-$(../common/k8s_get_node_ip.sh)} +curl -X POST http://${NODE_IP}:30499/api/v1/blueprint-model/publish -H 'content-type: multipart/form-data' -H 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' -F file=@${CBA_ZIP} |