diff options
author | vmuthukrishnan@aarnanetworks.com <vmuthukrishnan@aarnanetworks.com> | 2020-09-08 17:06:57 +0000 |
---|---|---|
committer | vmuthukrishnan@aarnanetworks.com <vmuthukrishnan@aarnanetworks.com> | 2020-09-08 17:07:19 +0000 |
commit | 4557a0e400de554ef3474bcd5d7c36a85b5be937 (patch) | |
tree | 882ced41c5b1fab1350a0274afd93f19a93c752f /components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts | |
parent | b708ee62df489337479bd00a4f0cd5b502d2f9c9 (diff) |
PNF demo blueprint
Change-Id: I830174d054fdd11fe8ebfbdeafe4abeb5b223dac
Issue-ID: CCSDK-2624
Signed-off-by: vmuthukrishnan@aarnanetworks.com <vmuthukrishnan@aarnanetworks.com>
Diffstat (limited to 'components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts')
16 files changed, 761 insertions, 0 deletions
diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/bootstrap-cds.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/bootstrap-cds.sh new file mode 100755 index 000000000..2966d19ff --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/bootstrap-cds.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/blueprint-model/bootstrap \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw ' { +"loadModelType" : true, +"loadResourceDictionary" : true, +"loadCBA" : true +}' + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/connect-cds-mariadb.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/connect-cds-mariadb.sh new file mode 100755 index 000000000..ce8c01791 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/connect-cds-mariadb.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +MARIADB_POD_NAME=$(kubectl get pods -n onap | grep 'dev-cds-db-0' | head -n 1 | awk '{print $1}') +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${MARIADB_POD_NAME}" ] + then + echo "CDS MariDB POD is not found so cannot proceed further" + exit 1; +fi + +# CDS Mariadb password +MYSQL_PASSWORD=Lase6+CopuBavb +MYSQL_USER=sdnctl +MYSQL_ROOT_PASSWORD=Zumu5%NoyuJagx + +echo "Going to connect to CDS MariaDB database sdnctl" +kubectl exec -n onap ${MARIADB_POD_NAME} -it -- mysql -u root -pZumu5%NoyuJagx sdnctl + + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/create-config-assing-data.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/create-config-assing-data.sh new file mode 100755 index 000000000..a169047cb --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/create-config-assing-data.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +resolution_key=${1} +pnf_ip_address=${2} +stream_count=${3} + + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +if [ -z "${resolution_key}" ] || [ -z "${pnf_ip_address}" ] || [ -z "${stream_count}" ] + then + echo -e "Invalid config assing resolution-key ${resolution_key} \ + OR pnf-ip-address ${pnf_ip_address} OR stream_count ${stream_count}" + echo "Usage: $0 <resolution-key> <pnf_ip_address> <stream_count>" + exit 0 +fi + +template_file="./templates/day-n-pnf-config.template" +temp_file="/tmp/day-n-pnf-config.json" +cp -f $template_file $temp_file + +# Now replace the tokens +sed -i "s|STREAM_COUNT|${stream_count}|g" $temp_file +sed -i "s|PNF_IP_ADDRESS|${pnf_ip_address}|g" $temp_file +sed -i "s|CONFIG_NAME|${resolution_key}|g" $temp_file + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/execution-service/process \ +--header 'Content-Type: application/json;charset=UTF-8' \ +--header 'Accept: application/json;charset=UTF-8,application/json' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Host: cds-blueprints-processor-http:8080' \ +--header 'Content-Type: text/json' \ +--data "@$temp_file" | python3 -m json.tool + + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dd-microk8s.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dd-microk8s.sh new file mode 100755 index 000000000..b7891d82c --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dd-microk8s.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +JSON_FILE=$1 + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] || [ -z "${JSON_FILE}" ] + then + echo "CDS BP Service IP is not found OR dd.json file is not given" + echo "Usage : $0 <Data Dictionary JSON file path>" + exit 1; +fi + +l=`jq '.|length' ${JSON_FILE}` +echo "Found $l Dictionary Definition Entries" +i=0 +while [ $i -lt $l ] +do + echo "i = $i" + d=`jq ".[$i]" ${JSON_FILE}` + echo $d + curl -k -v -O "http://${CDS_BP_SVC_IP}:8080/api/v1/dictionary" \ + --header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ + --header 'Content-Type: application/json' \ + -d"$d" + + sleep 1 + + echo -e "\n*****************************************\n" + i=$(( $i + 1 )) + +done diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dd.json b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dd.json new file mode 100644 index 000000000..c7361c9e4 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dd.json @@ -0,0 +1,155 @@ +[ + { + "name": "netconf-password", + "tags": "netconf-password", + "data_type": "string", + "description": "netconf-password", + "entry_schema": "string", + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "updatedBy": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "definition": { + "tags": "netconf-password", + "name": "netconf-password", + "property": { + "description": "netconf-password string attribute", + "type": "string" + }, + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + } + }, + { + "name": "netconf-username", + "tags": "netconf-username", + "data_type": "string", + "description": "netconf-username", + "entry_schema": "string", + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "updatedBy": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "definition": { + "tags": "netconf-username", + "name": "netconf-username", + "property": { + "description": "netconf-username string attribute", + "type": "string" + }, + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + } + }, + { + "name": "netconf-server-port", + "tags": "netconf-server-port", + "data_type": "string", + "description": "netconf-server-port", + "entry_schema": "string", + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "updatedBy": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "definition": { + "tags": "netconf-server-port", + "name": "netconf-server-port", + "property": { + "description": "netconf-server-port string attribute", + "type": "string" + }, + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + } + }, + { + "name": "pnf-id", + "tags": "pnf-id", + "data_type": "string", + "description": "pnf-id", + "entry_schema": "string", + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "updatedBy": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "definition": { + "tags": "pnf-id", + "name": "pnf-id", + "property": { + "description": "pnf-id string attribute", + "type": "string" + }, + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + } + }, + { + + "name": "pnf-ipv4-address", + "tags": "pnf-ipv4-address", + "data_type": "string", + "description": "pnf-ipv4-address", + "entry_schema": "string", + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "updatedBy": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "definition": { + "tags": "pnf-ipv4-address", + "name": "pnf-ipv4-address", + "property": { + "description": "pnf-ipv4-address string attribute", + "type": "string" + }, + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + } + + }, + { + "name": "stream-count", + "tags": "stream-count", + "data_type": "string", + "description": "stream-count", + "entry_schema": "string", + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "updatedBy": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "definition": { + "tags": "stream-count", + "name": "stream-count", + "property": { + "description": "stream-count string attribute", + "type": "integer" + }, + "updated-by": "Aarna service <vmuthukrishnan@aarnanetworks.com>", + "sources": { + "input": { + "type": "source-default", + "properties": {} + }, + "default": { + + "type": "source-default", + + "properties": {} + + } + } + } + } +] diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dictionary b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dictionary new file mode 100644 index 000000000..2b4985931 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/dictionary @@ -0,0 +1 @@ +{"name":"stream-count","dataType":"integer","entrySchema":null,"resourceDictionaryGroup":"default","definition":{"tags":"stream-count","name":"stream-count","property":{"description":"stream-count string attribute","required":null,"type":"integer","status":null,"constraints":null,"metadata":null,"value":null,"default":null,"entry_schema":null,"external-schema":null},"group":"default","updated-by":"Aarna service <vmuthukrishnan@aarnanetworks.com>","sources":{"input":{"description":null,"type":"source-default","metadata":null,"directives":null,"properties":{},"attributes":null,"capabilities":null,"requirements":null,"interfaces":null,"artifacts":null,"copy":null,"node_filter":null},"default":{"description":null,"type":"source-default","metadata":null,"directives":null,"properties":{},"attributes":null,"capabilities":null,"requirements":null,"interfaces":null,"artifacts":null,"copy":null,"node_filter":null}}},"description":"stream-count string attribute","tags":"stream-count","creationDate":"2020-09-08T12:47:55.545Z","updatedBy":"Aarna service <vmuthukrishnan@aarnanetworks.com>"}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/enrich-and-download-cds-blueprint.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/enrich-and-download-cds-blueprint.sh new file mode 100755 index 000000000..4741321ef --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/enrich-and-download-cds-blueprint.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +zip_file=$1 + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +if [ ! -f "$zip_file" ] + then + echo "Invalid CDS blueprint zip file argument $zip_file" + echo "Usage: $0 <CDS Blueprint ZIP file path>" + exit 0 +fi + + +# Remove the temporary CBA +rm -rf /tmp/CBA +mkdir -p /tmp/CBA + +# Enriched CBA file +ENRICHED_CBA_FILE="/tmp/CBA/ENRICHED-CBA.zip" + + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/blueprint-model/enrich \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form "file=@${zip_file}" \ +-o ${ENRICHED_CBA_FILE} + +echo "You can take a look at the enriched CBA archive file ${ENRICHED_CBA_FILE}" + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/enrich-and-publish-cds-blueprint.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/enrich-and-publish-cds-blueprint.sh new file mode 100755 index 000000000..39c3f32e6 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/enrich-and-publish-cds-blueprint.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +zip_file=$1 + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +if [ ! -f "$zip_file" ] + then + echo "Invalid Enriched CDS blueprint zip file argument $zip_file" + echo "Usage: $0 <Enriched CDS Blueprint ZIP file path>" + exit 0 +fi + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/blueprint-model/enrichandpublish \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form "file=@${zip_file}" + + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/get-cds-blueprint-models.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/get-cds-blueprint-models.sh new file mode 100755 index 000000000..dc35fde68 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/get-cds-blueprint-models.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +# Make the REST API to get the models +curl -v --location --request GET http://${CDS_BP_SVC_IP}:8080/api/v1/blueprint-model \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' | python3 -m json.tool + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/kotlin/ConfigDeploy.kt b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/kotlin/ConfigDeploy.kt new file mode 100644 index 000000000..96ef69937 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/kotlin/ConfigDeploy.kt @@ -0,0 +1,87 @@ +/* + * Copyright © 2020 Aarna Networks, Inc. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts + +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory +import org.springframework.http.HttpMethod +import org.springframework.web.client.RestTemplate +import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfClientService +import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfDevice +import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfDeviceInfo + +open class ConfigDeploy : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!! + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + + /* + * Here resolution-key could be day-1, day-2 etc.. + * This will come as part of config-deploy request payload. + */ + + val resolution_key = getDynamicProperties("resolution-key").asText() + log.info("Got the resolution_key: $resolution_key from config-deploy going to retrive the data from DB") + + // Read the config-assing data using the resolution key + Prefix name for the template + // We can select the given configuration using the resolution_key=day-1 or day-2 + // With the template prefix name for example "netconfrpc" to load the + // Store configuration from the CDS DB + val payload = storedContentFromResolvedArtifactNB(resolution_key, "netconfrpc") + log.info("PNF configuration data from DB : \n$payload\n") + + // "netconf-connection" is the tosca Node reference to "execute" + // workflow. + val netconf_device = netconfDevice("netconf-connection") + val netconf_rpc_client = netconf_device.netconfRpcService + val netconf_session = netconf_device.netconfSession + netconf_session.connect() + + /** + * Invoke the NETCONF RPC, we already have the teamplate loaded + * using "resolution-key" & template name prefix. + */ + val dev_response = netconf_rpc_client.invokeRpc(payload) + log.info("NETCONF device response message : dev_response\n") + + /** + netconf_rpc_client.lock("candidate") + netconf_rpc_client.discardConfig() + netconf_rpc_client.editConfig(payload, "candidate", "merge") + netconf_rpc_client.commit() + netconf_rpc_client.unLock("candidate") + netconf_rpc_client.getConfig("", "running") + */ + + log.info("Closing NETCONF device sessing with the device\n") + netconf_session.disconnect() + + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + } +} diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/process-config-deploy.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/process-config-deploy.sh new file mode 100755 index 000000000..27daefea9 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/process-config-deploy.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +resolution_key=${1} +pnf_ip_address=${2} +pnf_username="netconf" +pnf_password="netconf" + + + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +if [ -z "${resolution_key}" ] || [ -z "${pnf_ip_address}" ] + then + echo -e "Invalid config assing resolution-key ${resolution_key} \ + OR pnf-ip-address ${pnf_ip_address}" + echo "Usage: $0 <resolution-key> <pnf_ip_address>" + exit 0 +fi + +template_file="./templates/pnf-config-deploy.template" +temp_file="/tmp/pnf-config-deploy.json" +cp -f $template_file $temp_file + +# Now replace the tokens +sed -i "s|PNF_IP_ADDRESS|${pnf_ip_address}|g" $temp_file +sed -i "s|CONFIG_NAME|${resolution_key}|g" $temp_file +sed -i "s|NETCONF_USERNAME|${pnf_username}|g" $temp_file +sed -i "s|NETCONF_PASSWORD|${pnf_password}|g" $temp_file + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/execution-service/process \ +--header 'Content-Type: application/json;charset=UTF-8' \ +--header 'Accept: application/json;charset=UTF-8,application/json' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Host: cds-blueprints-processor-http:8080' \ +--header 'Content-Type: text/json' \ +--data "@$temp_file" | python3 -m json.tool + + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/publish-enriched-cds-blueprint.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/publish-enriched-cds-blueprint.sh new file mode 100755 index 000000000..88b1d9654 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/publish-enriched-cds-blueprint.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +zip_file=$1 + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +if [ ! -f "$zip_file" ] + then + echo "Invalid Enriched CDS blueprint zip file argument $zip_file" + echo "Usage: $0 <CDS Blueprint ZIP file path>" + exit 0 +fi + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/blueprint-model/publish \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form "file=@${zip_file}" \ +-o $PWD/DOWLOADED-PUBLISHED-CBA.zip + + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/save-enriched-blueprint.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/save-enriched-blueprint.sh new file mode 100755 index 000000000..e0ea48565 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/save-enriched-blueprint.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +zip_file=$1 + +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_SVC_IP}" ] + then + echo "CDS BP Service IP is not found and cannot proceed further" + exit 1; +fi + +if [ ! -f "$zip_file" ] + then + echo "Invalid Enriched CDS blueprint zip file argument $zip_file" + echo "Usage: $0 <CDS Blueprint ZIP file path>" + exit 0 +fi + +# Make the REST API to load the models +curl -v --location --request POST http://${CDS_BP_SVC_IP}:8080/api/v1/blueprint-model \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form "file=@${zip_file}" | python3 -m json.tool + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/tail-cds-bp-log.sh b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/tail-cds-bp-log.sh new file mode 100755 index 000000000..f3b4aa75b --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/tail-cds-bp-log.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Copyright © 2020 Aarna Networks, Inc. +# +# 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. + +MARIADB_POD_NAME=$(kubectl get pods -n onap | grep 'dev-mariadb-galera-0' | head -n 1 | awk '{print $1}') +CDS_BP_POD_NAME=$(kubectl get pods -n onap | grep 'cds-blueprints-processor' | head -n 1 | awk '{print $1}') +CDS_BP_SVC_IP=$(kubectl get svc -n onap | grep 'cds-blueprints-processor-http' | awk '{print $3}') + +if [ -z "${CDS_BP_POD_NAME}" ] + then + echo "CDS BP POD is not found so cannot proceed further" + exit 1; +fi + +# Make the REST API to load the models +kubectl logs -f -n onap ${CDS_BP_POD_NAME} + +exit 0 diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/templates/day-n-pnf-config.template b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/templates/day-n-pnf-config.template new file mode 100644 index 000000000..474af68c8 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/templates/day-n-pnf-config.template @@ -0,0 +1,29 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "pnf_netconf", + "blueprintVersion": "1.0.0", + "actionName": "config-assign" + }, + "payload": { + "config-assign-request": { + "template-prefix": [ + "pnf", "netconfrpc" + ], + "resolution-key": "CONFIG_NAME", + "config-assign-properties": { + "pnf-id": "abcd", + "pnf-ipv4-address": "PNF_IP_ADDRESS", + "netconf-password": "netconf", + "netconf-username": "netconf", + "netconf-server-port": "830", + "stream-count": "STREAM_COUNT" + } + } + }, + "commonHeader": { + "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58", + "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c", + "originatorId": "SDNC_DG" + } +} diff --git a/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/templates/pnf-config-deploy.template b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/templates/pnf-config-deploy.template new file mode 100644 index 000000000..9103d2d03 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/PNF_DEMO/Scripts/templates/pnf-config-deploy.template @@ -0,0 +1,27 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "pnf_netconf", + "blueprintVersion": "1.0.0", + "actionName": "config-deploy" + }, + "payload": { + "config-deploy-request": { + "resolution-key": "CONFIG_NAME", + "config-deploy-properties": { + "pnf-id": "abcd", + "pnf-ipv4-address": "PNF_IP_ADDRESS", + "netconf-password": "NETCONF_PASSWORD", + "netconf-username": "NETCONF_USERNAME" + } + } + } + + , + "commonHeader": { + "subRequestId": "143748f9-3cd5-4910-81c9-a4601ff2ea58", + "requestId": "e5eb1f1e-3386-435d-b290-d49d8af8db4c", + "originatorId": "SDNC_DG" + } +} + |