From 1ff5827ffde7af1d8aed23890a571455300ade6d Mon Sep 17 00:00:00 2001 From: Michał Grzesik Date: Wed, 10 Mar 2021 17:26:04 +0100 Subject: Add cofig-assign and config-deploy to cds workflow Add cofig-assign and config-deploy to cds workflow, cloud region and vf params list updated, exporting onap settings for onapsdk Issue-ID: INT-1868 Signed-off-by: Michal Grzesik Change-Id: I68acbc2ecedfafb4d2291707f5fef82e8feab831 --- .../templates/cba/Definitions/data_types.json | 51 +++---------- .../templates/cba/Definitions/vFW_CNF_CDS.json | 86 +++++++++++++++++----- .../templates/cba/Scripts/kotlin/ConfigDeploy.kt | 59 +++++++++++++++ .../templates/cba/Templates/cnf-mapping.json | 22 ++++++ .../templates/cba/Templates/cnf-template.vtl | 3 + 5 files changed, 163 insertions(+), 58 deletions(-) create mode 100644 heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt create mode 100644 heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json create mode 100644 heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl (limited to 'heat/vFW_CNF_CDS/templates') diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json index 5f3a2c09..b5697555 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json @@ -1,33 +1,9 @@ { "data_types": { - "dt-config-deploy-properties": { - "description": "Dynamic DataType definition for workflow(config-deploy).", + "dt-config-assign-properties": { + "description": "Dynamic DataType definition for workflow(config-assign).", "version": "1.0.0", "properties": { - "vpg_onap_private_ip_0": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" - } - }, - "vnf-id": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" - } - }, "service-instance-id": { "description": "", "required": false, @@ -39,20 +15,15 @@ "entry_schema": { "type": "" } - }, - "active-streams": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" - } - }, - "put-active-streams": { + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-config-deploy-properties": { + "description": "Dynamic DataType definition for workflow(config-deploy).", + "version": "1.0.0", + "properties": { + "service-instance-id": { "description": "", "required": false, "type": "string", diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json index 60846f6c..9053c9b2 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json @@ -98,30 +98,51 @@ } } }, + "config-assign": { + "steps": { + "config-assign": { + "description": "Create a message", + "target": "config-assign-process", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "store-result": { + "required": true, + "type": "boolean" + }, + "config-assign-properties": { + "description": "Dynamic PropertyDefinition for workflow(config-assign).", + "required": true, + "type": "dt-config-assign-properties" + } + } + }, "config-deploy": { "steps": { "config-deploy": { - "description": "Config Deploy Workflow", + "description": "Run kotlin script", "target": "config-deploy-process" } }, "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, "config-deploy-properties": { "description": "Dynamic PropertyDefinition for workflow(config-deploy).", "required": true, "type": "dt-config-deploy-properties" } - }, - "outputs": { - "dry-run": { - "type": "json", - "value": { - "get_attribute": [ - "config-deploy-process", - "assignment-params" - ] - } - } } } }, @@ -220,29 +241,58 @@ } } }, - "config-deploy-process": { + "config-assign-process": { "type": "component-resource-resolution", "interfaces": { "ResourceResolutionComponent": { "operations": { "process": { "inputs": { + "resolution-key": { + "get_input": "resolution-key" + }, + "store-result": true, "artifact-prefix-names": [ - "nf-params" + "cnf" ] + }, + "outputs": { + "resource-assignment-params": { + "get_attribute": [ + "SELF", + "assignment-params" + ] + }, + "status": "success" } } } } }, "artifacts": { - "nf-params-template": { + "cnf-template": { "type": "artifact-template-velocity", - "file": "Templates/nf-params-template.vtl" + "file": "Templates/cnf-template.vtl" }, - "nf-params-mapping": { + "cnf-mapping": { "type": "artifact-mapping-resource", - "file": "Templates/nf-params-mapping.json" + "file": "Templates/cnf-mapping.json" + } + } + }, + "config-deploy-process": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.ConfigDeploy", + "dynamic-properties": "*config-deploy-properties" + } + } + } } } } diff --git a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt new file mode 100644 index 00000000..c4849601 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt @@ -0,0 +1,59 @@ +/* + * 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 + +open class ConfigDeploy : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!! + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + + /* + * Resolution key 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 + val prefix = "cnf" + val payload = storedContentFromResolvedArtifactNB(resolution_key, prefix) + log.info("cnf configuration data from DB : \n$payload\n") + + println("Run config-deploy") + println("$payload") + + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + } +} diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json new file mode 100644 index 00000000..4e012f95 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json @@ -0,0 +1,22 @@ +[ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [], + "version": 0 + } +] diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl new file mode 100644 index 00000000..459d3c3a --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl @@ -0,0 +1,3 @@ +{ + "config deploy results for cnf service instance" : "${service-instance-id}" +} -- cgit 1.2.3-korg