diff options
Diffstat (limited to 'components/model-catalog/blueprint-model')
21 files changed, 278 insertions, 206 deletions
diff --git a/components/model-catalog/blueprint-model/pom.xml b/components/model-catalog/blueprint-model/pom.xml new file mode 100644 index 000000000..7e0e3cf9d --- /dev/null +++ b/components/model-catalog/blueprint-model/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright © 2018-2019 AT&T Intellectual Property. + ~ + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> + <artifactId>cba-parent</artifactId> + <version>0.7.0-SNAPSHOT</version> + <relativePath>../../../ms/blueprintsprocessor/cba-parent</relativePath> + </parent> + + <groupId>org.onap.ccsdk.cds.cba</groupId> + <artifactId>blueprint-model</artifactId> + <version>0.7.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <name>CBA - Blueprints</name> + <description>CBA - Blueprints</description> + + <modules> + <module>test-blueprint</module> + </modules> +</project> diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta index 8f1df9f2a..854c20ba2 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta @@ -3,4 +3,6 @@ CSAR-Version: 1.0 Created-By: Brinda Santh <brindasanth@in.ibm.com> Entry-Definitions: Definitions/activation-blueprint.json Template-Tags: Brinda Santh, activation-blueprint +Template-Name: baseconfiguration +Template-Version: 1.0.0 diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_cli/pom.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_cli/pom.xml index c71449678..ea76d50b9 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_cli/pom.xml +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_cli/pom.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright © 2019 IBM. + ~ Modification Copyright © 2018-2019 AT&T Intellectual Property. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -18,16 +19,15 @@ <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> - <artifactId>cba-parent</artifactId> + <groupId>org.onap.ccsdk.cds.cba</groupId> + <artifactId>test-blueprint-model</artifactId> <version>0.7.0-SNAPSHOT</version> </parent> - <groupId>org.onap.ccsdk.cds.components.cba</groupId> <artifactId>capability_cli</artifactId> - <name>CBA Capability CLI</name> - <description>CBA Capability CLI</description> + <name>CBA - Test Capability CLI</name> + <description>CBA - Test Capability CLI</description> <dependencies> <dependency> diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta index 9066e4845..8aad13cfd 100755 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta @@ -3,6 +3,5 @@ CSAR-Version: 1.0 Created-By: Brinda Santh M Entry-Definitions: Definitions/activation-blueprint.json Template-Tags: Brinda Santh, activation-blueprint - -Name: Plans/ActivateProcess.bpmn -Content-Type: application/vnd.oasis.bpmn +Template-Name: capability_python +Template-Version: 1.0.0 diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta index b8f3a202a..f85c611f8 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta @@ -3,4 +3,5 @@ CSAR-Version: 1.0 Created-By: Alexis de Talhouët Entry-Definitions: Definitions/golden-blueprint.json Template-Tags: test -Content-Type: application/vnd.oasis.bpmn +Template-Name: golden +Template-Version: 1.0.0
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/pom.xml b/components/model-catalog/blueprint-model/test-blueprint/pom.xml new file mode 100644 index 000000000..f9dab0227 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright © 2018-2019 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.ccsdk.cds.cba</groupId> + <artifactId>blueprint-model</artifactId> + <version>0.7.0-SNAPSHOT</version> + </parent> + + <artifactId>test-blueprint-model</artifactId> + <version>0.7.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <name>CBA - Test Blueprints</name> + <description>CBA - Test Blueprints</description> + + <modules> + <module>capability_cli</module> + <module>resource-audit</module> + </modules> +</project> diff --git a/components/model-catalog/blueprint-model/test-blueprint/remote_ansible/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/remote_ansible/TOSCA-Metadata/TOSCA.meta index 17448a835..efaeabf11 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/remote_ansible/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/test-blueprint/remote_ansible/TOSCA-Metadata/TOSCA.meta @@ -2,4 +2,6 @@ TOSCA-Meta-File-Version: 1.0.0 CSAR-Version: 1.0 Created-By: Serge Simard <serge@agilitae.com> Entry-Definitions: Definitions/remote_ansible.json -Template-Tags: Serge Simard, remote_ansible
\ No newline at end of file +Template-Tags: Serge Simard, remote_ansible +Template-Name: remote_ansible +Template-Version: 1.0.0
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/TOSCA-Metadata/TOSCA.meta index 2c3a91f28..2e3ed2c2e 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/TOSCA-Metadata/TOSCA.meta @@ -3,4 +3,5 @@ CSAR-Version: 1.0 Created-By: Brinda Santh <brindasanth@in.ibm.com> Entry-Definitions: Definitions/remote_scripts.json Template-Tags: Brinda Santh, remote_scripts -Content-Type: application/vnd.oasis.bpmn +Template-Name: remote_scripts +Template-Version: 1.0.0 diff --git a/components/model-catalog/blueprint-model/test-blueprint/resource-audit/pom.xml b/components/model-catalog/blueprint-model/test-blueprint/resource-audit/pom.xml index 527e2b62b..5f6c49e0c 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/resource-audit/pom.xml +++ b/components/model-catalog/blueprint-model/test-blueprint/resource-audit/pom.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright © 2019 IBM. + ~ Modification Copyright © 2018-2019 AT&T Intellectual Property. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -16,15 +17,18 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <parent> - <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> - <artifactId>cba-parent</artifactId> + <groupId>org.onap.ccsdk.cds.cba</groupId> + <artifactId>test-blueprint-model</artifactId> <version>0.7.0-SNAPSHOT</version> </parent> + <groupId>org.onap.ccsdk.cds.components.cba</groupId> <artifactId>resource-audit</artifactId> - <name>CBA Resource Audit</name> - <description>CBA Resource Audit</description> + + <name>CBA - Test Resource Audit</name> + <description>CBA - Test Resource Audit</description> <dependencies> <dependency> diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json index aa5295e44..6ec3b4105 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json @@ -12,12 +12,6 @@ "derived_from" : "tosca.artifacts.Implementation", "file_ext" : [ "json" ] }, - "artifact-script-jython" : { - "description" : "Jython Script File", - "version" : "1.0.0", - "derived_from" : "tosca.artifacts.Implementation", - "file_ext" : [ "py" ] - }, "artifact-template-velocity" : { "description" : " Velocity Template used for Configuration", "version" : "1.0.0", diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json index 1a7ba559a..62702b7e2 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json @@ -4,7 +4,7 @@ "template_author" : "Rodrigo Ottero", "author-email" : "rodrigo.ottero@est.tech", "user-groups" : "ADMIN, OPERATION", - "template_name" : "configuration_over_restconf", + "template_name" : "pnf_config", "template_version" : "1.0.0", "template_tags" : "pnf, restconf, config, configuration" }, @@ -124,8 +124,8 @@ "operation_host" : "SELF" }, "inputs" : { - "script-type" : "jython", - "script-class-reference" : "Scripts/python/RestconfConfigDeploy.py", + "script-type" : "kotlin", + "script-class-reference" : "cba.pnf.config.RestconfConfigDeploy", "dynamic-properties" : "*config-deploy-properties" }, "outputs" : { @@ -144,10 +144,6 @@ "config-deploy-mapping" : { "type" : "artifact-mapping-resource", "file" : "Definitions/config-deploy-pnf-mapping.json" - }, - "component-script" : { - "type" : "artifact-script-jython", - "file" : "Scripts/python/RestconfConfigDeploy.py" } } } diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt new file mode 100644 index 000000000..a2372c9db --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt @@ -0,0 +1,81 @@ +/* +* ============LICENSE_START======================================================= +* Copyright (C) 2019 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 +* +* 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========================================================= + */ + + +package cba.pnf.config + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.contentFromResolvedArtifactNB +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfMountDevice +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfApplyDeviceConfig +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfUnMountDevice +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfDeviceConfig +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.logger + +class RestconfConfigDeploy : AbstractScriptComponentFunction() { + private val CONFIGLET_TEMPLATE_NAME = "config-assign" + private val CONFIGLET_RESOURCE_PATH = "yang-ext:mount/mynetconf:netconflist" + private val RESTCONF_SERVER_IDENTIFIER = "sdnc" + private val log = logger(AbstractScriptComponentFunction::class.java) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("Started execution of process method") + try { + // Extract Resolution key & Device ID + val resolutionKey = getDynamicProperties("resolution-key").asText() + log.info("resolution_key: $resolutionKey") + val deviceID: String = requestPayloadActionProperty("config-deploy-properties")?.get(0)?.get("pnf-id")?.textValue()!! + log.info("device_id: $deviceID") + val webclientService = restconfClientService(RESTCONF_SERVER_IDENTIFIER) + + try { + // Mount the device + val mountPayload = contentFromResolvedArtifactNB("config-deploy") + log.debug("Mounting Device : $deviceID") + restconfMountDevice(webclientService, deviceID, mountPayload, mutableMapOf("Content-Type" to "application/json")) + + //Log the current configuration for the subtree + val currentConfig: Any = restconfDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH) + log.info("Current configuration subtree : $currentConfig") + //Apply configlet + restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH, + storedContentFromResolvedArtifactNB(resolutionKey, CONFIGLET_TEMPLATE_NAME), + mutableMapOf("Content-Type" to "application/yang.patch+json")) + + } catch (err: Exception) { + log.error("an error occurred while configuring device {}", err) + } finally { + //Un mount device + restconfUnMountDevice(webclientService, deviceID, "") + } + } catch (bpe: BluePrintProcessorException) { + log.error("Error looking up server identifier ", bpe) + } + } + + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Recover function called!") + log.info("Execution request : $executionRequest") + log.error("Exception", runtimeException) + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py deleted file mode 100644 index af0b7e129..000000000 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py +++ /dev/null @@ -1,78 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2019 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 -# -# 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========================================================= - -from java.lang import Exception as JavaException - -from restconf_client import RestconfClient -from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction - - -class RestconfConfigDeploy(AbstractScriptComponentFunction): - log = globals()["log"] - configlet_template_name = "config-assign" - configlet_resource_path = "/yang-ext:mount/mynetconf:netconflist" - restconf_server_identifier = "sdnc" - - def process(self, execution_request): - - self.log.info("Started execution of process method") - try: - restconf_client = RestconfClient(self.log, self) - pnf_id, resolution_key = self.retrieve_parameters(execution_request) - web_client_service = restconf_client.web_client_service(self.restconf_server_identifier) - - try: - # mount the device - mount_payload = restconf_client.resolve_and_generate_message_from_template_prefix("config-deploy") - restconf_client.mount_device(web_client_service, pnf_id, mount_payload, "application/json") - - # log the current configuration subtree - current_configuration = restconf_client.retrieve_device_configuration_subtree( - web_client_service, pnf_id, self.configlet_resource_path) - self.log.info("Current configuration subtree: {}", current_configuration) - - # apply configuration - configlet = restconf_client.retrieve_resolved_template_from_database(resolution_key, self.configlet_template_name) - restconf_client.configure_device_json_patch( - web_client_service, pnf_id, self.configlet_resource_path, configlet) - except Exception, err: - self.log.error("an error occurred while configuring device {}", err) - raise err - finally: - restconf_client.unmount_device(web_client_service, pnf_id) - - except JavaException, err: - self.log.error("Java Exception in the script", err) - raise err - except Exception, err: - self.log.error("Python Exception in the script:" + str(err), err) - raise err - self.log.info("Ended execution of process method") - - def retrieve_parameters(self, execution_request): - resolution_key = self.getDynamicProperties("resolution-key").asText() - self.log.info("resolution_key: {}", resolution_key) - pnf_id = execution_request.payload.get("config-deploy-request").get("config-deploy-properties").get("pnf-id") - pnf_id = str(pnf_id).strip('\"') - self.log.info("pnf-id: {}", pnf_id) - return pnf_id, resolution_key - - def recover(self, runtime_exception, execution_request): - self.log.info("Recover function called!") - self.log.info("Execution request", execution_request) - self.log.error("Exception", runtime_exception) - print self.bluePrintRuntimeService.getBluePrintError().addError(runtime_exception.getMessage()) - return None diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/TOSCA-Metadata/TOSCA.meta index ca0637328..096bd7d3f 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/TOSCA-Metadata/TOSCA.meta @@ -1,7 +1,7 @@ TOSCA-Meta-File-Version: 1.0.0 CSAR-Version: 1.0 Created-By: Rodrigo Ottero -Entry-Definitions: Definitions/activation-blueprint.json -Template-Name: activation-blueprint +Entry-Definitions: Definitions/pnf_config.json +Template-Name: pnf_config Template-Version: 1.0.0 Template-Tags: activation-blueprint diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml index 518bbe020..85b10c611 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml @@ -8,7 +8,7 @@ processes: requestId: "123456-1000" subRequestId: sub-123456-1000 actionIdentifiers: &assign-ai - blueprintName: configuration_over_restconf + blueprintName: pnf_config blueprintVersion: "1.0.0" actionName: config-assign mode: sync @@ -35,7 +35,7 @@ processes: commonHeader: *commonHeader actionIdentifiers: &deploy-ai actionName: config-deploy - blueprintName: configuration_over_restconf + blueprintName: pnf_config blueprintVersion: "1.0.0" mode: sync payload: diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json index aa5295e44..6ec3b4105 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json @@ -12,12 +12,6 @@ "derived_from" : "tosca.artifacts.Implementation", "file_ext" : [ "json" ] }, - "artifact-script-jython" : { - "description" : "Jython Script File", - "version" : "1.0.0", - "derived_from" : "tosca.artifacts.Implementation", - "file_ext" : [ "py" ] - }, "artifact-template-velocity" : { "description" : " Velocity Template used for Configuration", "version" : "1.0.0", diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json index 214f7dd75..3ef585cb4 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json @@ -4,7 +4,7 @@ "template_author" : "Rahul Tyagi", "author-email" : "rahul.tyagi@est.tech", "user-groups" : "ADMIN, OPERATION", - "template_name" : "configuration_over_restconf", + "template_name" : "pnf_config_aai", "template_version" : "1.0.0", "template_tags" : "pnf, restconf, config, configuration" }, @@ -124,8 +124,8 @@ "operation_host" : "SELF" }, "inputs" : { - "script-type" : "jython", - "script-class-reference" : "Scripts/python/RestconfConfigDeploy.py", + "script-type" : "kotlin", + "script-class-reference" : "cba.pnf.config.aai.RestconfConfigDeploy", "dynamic-properties" : "*config-deploy-properties" }, "outputs" : { @@ -144,10 +144,6 @@ "config-deploy-mapping" : { "type" : "artifact-mapping-resource", "file" : "Definitions/config-deploy-pnf-mapping.json" - }, - "component-script" : { - "type" : "artifact-script-jython", - "file" : "Scripts/python/RestconfConfigDeploy.py" } } } diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt new file mode 100644 index 000000000..6a034ab94 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt @@ -0,0 +1,82 @@ +/* +* ============LICENSE_START======================================================= +* Copyright (C) 2019 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 +* +* 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========================================================= + */ + + +package cba.pnf.config.aai + + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.contentFromResolvedArtifactNB +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfMountDevice +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfApplyDeviceConfig +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfUnMountDevice +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfDeviceConfig +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.logger + +class RestconfConfigDeploy : AbstractScriptComponentFunction() { + private val CONFIGLET_TEMPLATE_NAME = "config-assign" + private val CONFIGLET_RESOURCE_PATH = "yang-ext:mount/mynetconf:netconflist" + private val RESTCONF_SERVER_IDENTIFIER = "sdnc" + private val log = logger(AbstractScriptComponentFunction::class.java) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("Started execution of process method") + try { + // Extract Resolution key & Device ID + val resolutionKey = getDynamicProperties("resolution-key").asText() + log.info("resolution_key: $resolutionKey") + val deviceID: String = requestPayloadActionProperty("config-deploy-properties")?.get(0)?.get("pnf-id")?.textValue()!! + log.info("device_id: $deviceID") + val webclientService = restconfClientService(RESTCONF_SERVER_IDENTIFIER) + + try { + // Mount the device + val mountPayload = contentFromResolvedArtifactNB("config-deploy") + log.debug("Mounting Device : $deviceID") + restconfMountDevice(webclientService, deviceID, mountPayload, mutableMapOf("Content-Type" to "application/json")) + + //Log the current configuration for the subtree + val currentConfig: Any = restconfDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH) + log.info("Current configuration subtree : $currentConfig") + //Apply configlet + restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH, + storedContentFromResolvedArtifactNB(resolutionKey, CONFIGLET_TEMPLATE_NAME), + mutableMapOf("Content-Type" to "application/yang.patch+json")) + + } catch (err: Exception) { + log.error("an error occurred while configuring device {}", err) + } finally { + //Un mount device + restconfUnMountDevice(webclientService, deviceID, "") + } + } catch (bpe: BluePrintProcessorException) { + log.error("Error looking up server identifier ", bpe) + } + } + + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Recover function called!") + log.info("Execution request : $executionRequest") + log.error("Exception", runtimeException) + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py deleted file mode 100644 index af0b7e129..000000000 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py +++ /dev/null @@ -1,78 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2019 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 -# -# 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========================================================= - -from java.lang import Exception as JavaException - -from restconf_client import RestconfClient -from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction - - -class RestconfConfigDeploy(AbstractScriptComponentFunction): - log = globals()["log"] - configlet_template_name = "config-assign" - configlet_resource_path = "/yang-ext:mount/mynetconf:netconflist" - restconf_server_identifier = "sdnc" - - def process(self, execution_request): - - self.log.info("Started execution of process method") - try: - restconf_client = RestconfClient(self.log, self) - pnf_id, resolution_key = self.retrieve_parameters(execution_request) - web_client_service = restconf_client.web_client_service(self.restconf_server_identifier) - - try: - # mount the device - mount_payload = restconf_client.resolve_and_generate_message_from_template_prefix("config-deploy") - restconf_client.mount_device(web_client_service, pnf_id, mount_payload, "application/json") - - # log the current configuration subtree - current_configuration = restconf_client.retrieve_device_configuration_subtree( - web_client_service, pnf_id, self.configlet_resource_path) - self.log.info("Current configuration subtree: {}", current_configuration) - - # apply configuration - configlet = restconf_client.retrieve_resolved_template_from_database(resolution_key, self.configlet_template_name) - restconf_client.configure_device_json_patch( - web_client_service, pnf_id, self.configlet_resource_path, configlet) - except Exception, err: - self.log.error("an error occurred while configuring device {}", err) - raise err - finally: - restconf_client.unmount_device(web_client_service, pnf_id) - - except JavaException, err: - self.log.error("Java Exception in the script", err) - raise err - except Exception, err: - self.log.error("Python Exception in the script:" + str(err), err) - raise err - self.log.info("Ended execution of process method") - - def retrieve_parameters(self, execution_request): - resolution_key = self.getDynamicProperties("resolution-key").asText() - self.log.info("resolution_key: {}", resolution_key) - pnf_id = execution_request.payload.get("config-deploy-request").get("config-deploy-properties").get("pnf-id") - pnf_id = str(pnf_id).strip('\"') - self.log.info("pnf-id: {}", pnf_id) - return pnf_id, resolution_key - - def recover(self, runtime_exception, execution_request): - self.log.info("Recover function called!") - self.log.info("Execution request", execution_request) - self.log.error("Exception", runtime_exception) - print self.bluePrintRuntimeService.getBluePrintError().addError(runtime_exception.getMessage()) - return None diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/TOSCA-Metadata/TOSCA.meta index 21f431861..903600836 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/TOSCA-Metadata/TOSCA.meta @@ -1,7 +1,7 @@ TOSCA-Meta-File-Version: 1.0.0 CSAR-Version: 1.0 Created-By: Rahul Tyagi -Entry-Definitions: Definitions/activation-blueprint.json -Template-Name: activation-blueprint +Entry-Definitions: Definitions/pnf_config_aai.json +Template-Name: pnf_config_aai Template-Version: 1.0.0 -Template-Tags: activation-blueprint +Template-Tags: pnf_config_aai diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml index 1a5995e06..0692eea7f 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml @@ -8,7 +8,7 @@ processes: requestId: "123456-1000" subRequestId: sub-123456-1000 actionIdentifiers: &assign-ai - blueprintName: configuration_over_restconf + blueprintName: pnf_config_aai blueprintVersion: "1.0.0" actionName: config-assign mode: sync @@ -35,7 +35,7 @@ processes: commonHeader: *commonHeader actionIdentifiers: &deploy-ai actionName: config-deploy - blueprintName: configuration_over_restconf + blueprintName: pnf_config_aai blueprintVersion: "1.0.0" mode: sync payload: |