diff options
Diffstat (limited to 'components/model-catalog')
19 files changed, 747 insertions, 591 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json index a8329b837..fdc18c56d 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -278,6 +278,29 @@ } } }, + "activate-restconf": { + "type": "component-restconf-executor", + "interfaces": { + "ComponentRestconfExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "DefaultRestconf_cba$MountNEditConfigure", + "instance-dependencies": [] + }, + "outputs": { + "response-data": "", + "status": "success" + } + } + } + } + } + }, "sample-netconf-device": { "type": "vnf-netconf-device", "capabilities": { @@ -366,6 +389,19 @@ } } }, + "activate-restconf": { + "steps": { + "activate-process": { + "description": "Activate Restconf flow", + "target": "activate-restconf", + "activities": [ + { + "call_operation": "ComponentRestconfExecutor.process" + } + ] + } + } + }, "assign-activate": { "inputs": { "assign-activate-properties": { diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json index 3658a260d..07e4df140 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json @@ -136,6 +136,16 @@ "operations": { "process": { "inputs": { + "resolution-key": { + "description": "Key for service instance related correlation.", + "required": false, + "type": "string" + }, + "store-result": { + "description": "Whether or not to store the output.", + "required": false, + "type": "boolean" + }, "resource-type": { "description": "Request type.", "required": false, @@ -186,6 +196,71 @@ }, "derived_from": "tosca.nodes.Component" }, + "component-restconf-executor": { + "description": "This is Restconf Transaction Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "ComponentRestconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": { + "description": "Script type, kotlin type is supported", + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "kotlin", + "jython", + "internal" + ] + } + ], + "default": "internal" + }, + "script-class-reference": { + "description": "Kotlin Script class name or jython script name.", + "required": true, + "type": "string" + }, + "instance-dependencies": { + "description": "Instance names to inject to Jython or Kotlin Script.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" + } + }, + "outputs": { + "response-data": { + "description": "Execution Response Data in JSON format.", + "required": false, + "type": "string" + }, + "status": { + "description": "Status of the Component Execution ( success or failure )", + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, "dg-generic": { "description": "This is Generic Directed Graph Type", "version": "1.0.0", @@ -205,6 +280,48 @@ }, "derived_from": "tosca.nodes.Workflow" }, + "source-capability": { + "description": "This is Component Resource Source Node Type", + "version": "1.0.0", + "properties": { + "script-type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "kotlin", + "internal", + "jython" + ] + } + ], + "default": "kotlin" + }, + "script-class-reference": { + "description": "Capability reference name for internal and kotlin, for jython script file path", + "required": true, + "type": "string" + }, + "instance-dependencies": { + "description": "Instance dependency Names to Inject to Kotlin / Jython Script.", + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "description": "Resource Resolution dependency dictionary names.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" + }, "source-input": { "description": "This is Input Resource Source Node Type", "version": "1.0.0", @@ -223,7 +340,7 @@ }, "derived_from": "tosca.nodes.ResourceSource" }, - "source-processor-db": { + "source-primary-db": { "description": "This is Database Resource Source Node Type", "version": "1.0.0", "properties": { @@ -287,6 +404,26 @@ ], "default": "JSON" }, + "verb": { + "required": false, + "type": "string", + "constraints": [ + { + "valid_values": [ + "GET", + "POST", + "DELETE", + "PUT" + ] + } + ], + "default": "GET" + }, + "payload": { + "required": false, + "type": "string", + "default": "" + }, "endpoint-selector": { "required": false, "type": "string" diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json index 6e3d5e94f..d926aa3fc 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json @@ -27,7 +27,7 @@ "properties": {} }, "processor-db": { - "type": "source-processor-db", + "type": "source-primary-db", "properties": { "endpoint-selector": "dynamic-db-source", "query": "SELECT artifact_name FROM sdnctl.BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/DefaultRestconf.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/DefaultRestconf.cba.kts new file mode 100644 index 000000000..770c36360 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/DefaultRestconf.cba.kts @@ -0,0 +1,37 @@ +/* + * Copyright © 2019 IBM. + * + * 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. + */ + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.RestconfComponentFunction +import org.slf4j.LoggerFactory + +open class MountNEditConfigure : RestconfComponentFunction() { + + val log = LoggerFactory.getLogger(MountNEditConfigure::class.java)!! + + override fun getName(): String { + return "MountNEditConfigure" + } + + override fun process(executionRequest: ExecutionServiceInput) { + log.info("processing request..") + + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("processing request..") + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts index a471349ef..de2f15d2e 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +15,23 @@ * limitations under the License. */ -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.* -import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.slf4j.LoggerFactory open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() { - lateinit var resourceAssignment: ResourceAssignment + private val log = LoggerFactory.getLogger(ScriptResourceAssignmentProcessor::class.java)!! override fun getName(): String { - return "resource-assignment-processor-custom-capability" + return "ScriptResourceAssignmentProcessor" } - override fun process(resourceAssignment: ResourceAssignment) { - this.resourceAssignment = resourceAssignment + override fun process(executionRequest: ResourceAssignment) { + log.info("Processing input") } - override fun prepareResponse(): ResourceAssignment { - return resourceAssignment + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + log.info("Recovering input") } - - override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { - TODO("To Implement") - } - }
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py index 78a38a225..d65aefabb 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py @@ -37,11 +37,19 @@ class RestconfConfigDeploy(RestconfComponentFunction): web_client_service = self.restClientService(self.restconf_server_identifier) try: + # mount the device mount_payload = self.resolveAndGenerateMessage("config-deploy-mapping", "config-deploy-template") restconf_client.mount_device(web_client_service, pnf_id, mount_payload) + # 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 = self.resolveFromDatabase(resolution_key, self.configlet_template_name) - restconf_client.configure_device(web_client_service, pnf_id, self.configlet_resource_path, configlet) + 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 diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json deleted file mode 100644 index b6464f3c8..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json +++ /dev/null @@ -1,333 +0,0 @@ -{ - "tosca_definitions_version" : "controller_blueprint_1_0_0", - "metadata" : { - "template_author" : "Alexis de Talhouët", - "author-email" : "adetalhouet89@gmail.com", - "user-groups" : "ADMIN, OPERATION", - "template_name" : "test", - "template_version" : "1.0.0", - "template_tags" : "test" - }, - "imports" : [ { - "file" : "Definitions/data_types.json" - }, { - "file" : "Definitions/relationship_types.json" - }, { - "file" : "Definitions/artifact_types.json" - }, { - "file" : "Definitions/node_types.json" - }, { - "file" : "Definitions/policy_types.json" - } ], - "dsl_definitions" : { - "ipam-1" : { - "type" : "token-auth", - "url" : "http://localhost:32778", - "token" : "Token 0123456789abcdef0123456789abcdef01234567" - }, - "config-deploy-properties" : { - "resolution-key" : { - "get_input" : "resolution-key" - } - } - }, - "topology_template" : { - "workflows" : { - "resource-assignment" : { - "steps" : { - "resource-assignment-process" : { - "description" : "Resource Assign Workflow", - "target" : "resource-assignment-process", - "activities" : [ { - "call_operation" : "" - } ] - } - }, - "inputs" : { - "artifact-name" : { - "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "string" - } - }, - "store-result" : { - "required" : true, - "type" : "boolean" - }, - "resolution-key" : { - "required" : true, - "type" : "string" - }, - "resource-assignment-properties" : { - "description" : "Dynamic PropertyDefinition for workflow(resource-assignment).", - "required" : true, - "type" : "dt-resource-assignment-properties" - } - } - }, - "config-deploy" : { - "steps" : { - "config-deploy" : { - "description" : "Resource Assign and Python Netconf Activation Workflow", - "target" : "config-deploy-process", - "activities" : [ { - "call_operation" : "" - } ] - } - }, - "inputs" : { - "resolution-key" : { - "required" : false, - "type" : "string" - }, - "password" : { - "required" : true, - "type" : "string" - }, - "username" : { - "required" : true, - "type" : "string" - }, - "ip" : { - "required" : true, - "type" : "string" - }, - "config-deploy-properties" : { - "description" : "Dynamic PropertyDefinition for workflow(config-deploy).", - "required" : true, - "type" : "dt-config-deploy-properties" - } - } - }, - "rollback" : { - "steps" : { - "rollback" : { - "description" : "Roolback Workflow", - "target" : "rollback-process", - "activities" : [ { - "call_operation" : "" - } ] - } - }, - "inputs" : { - "resolution-key" : { - "required" : false, - "type" : "string" - }, - "password" : { - "required" : true, - "type" : "string" - }, - "username" : { - "required" : true, - "type" : "string" - }, - "ip" : { - "required" : true, - "type" : "string" - }, - "config-deploy-properties" : { - "description" : "Dynamic PropertyDefinition for workflow(config-deploy).", - "required" : true, - "type" : "dt-config-deploy-properties" - }, - "rollback-properties" : { - "description" : "Dynamic PropertyDefinition for workflow(rollback).", - "required" : true, - "type" : "dt-rollback-properties" - } - } - } - }, - "node_templates" : { - "resource-assignment-process" : { - "type" : "dg-generic", - "properties" : { - "content" : { - "get_artifact" : [ "SELF", "dg-resource-assignment-process" ] - }, - "dependency-node-templates" : [ "resource-assignment" ] - }, - "artifacts" : { - "dg-resource-assignment-process" : { - "type" : "artifact-directed-graph", - "file" : "Plans/ResourceAssignment.xml" - } - } - }, - "resource-assignment" : { - "type" : "component-resource-resolution", - "interfaces" : { - "ResourceResolutionComponent" : { - "operations" : { - "process" : { - "inputs" : { - "resolution-key" : { - "get_input" : "resolution-key" - }, - "store-result" : { - "get_input" : "store-result" - }, - "artifact-prefix-names" : { - "get_input" : "artifact-name" - } - }, - "outputs" : { - "resource-assignment-params" : { - "get_attribute" : [ "SELF", "assignment-params" ] - }, - "status" : "success" - } - } - } - } - }, - "artifacts" : { - "hostname-template" : { - "type" : "artifact-template-velocity", - "file" : "Templates/hostname-template.vtl" - }, - "hostname-mapping" : { - "type" : "artifact-mapping-resource", - "file" : "Templates/hostname-mapping.json" - }, - "vf-module-1-template" : { - "type" : "artifact-template-velocity", - "file" : "Templates/vf-module-1-template.vtl" - }, - "vf-module-1-mapping" : { - "type" : "artifact-mapping-resource", - "file" : "Templates/vf-module-1-mapping.json" - } - } - }, - "config-deploy-process" : { - "type" : "dg-generic", - "properties" : { - "content" : { - "get_artifact" : [ "SELF", "dg-config-deploy-process" ] - }, - "dependency-node-templates" : [ "config-deploy" ] - }, - "artifacts" : { - "dg-config-deploy-process" : { - "type" : "artifact-directed-graph", - "file" : "Plans/ConfigDeploy.xml" - } - } - }, - "config-deploy" : { - "type" : "component-netconf-executor", - "requirements" : { - "netconf-connection" : { - "capability" : "netconf", - "node" : "netconf-device", - "relationship" : "tosca.relationships.ConnectsTo" - } - }, - "interfaces" : { - "ComponentNetconfExecutor" : { - "operations" : { - "process" : { - "inputs" : { - "script-type" : "jython", - "script-class-reference" : "Scripts/python/NetconfRpcExample.py", - "instance-dependencies" : [ ], - "dynamic-properties" : "*config-deploy-properties" - }, - "outputs" : { - "response-data" : "", - "status" : "SUCCESS" - } - } - } - } - }, - "artifacts" : { - "vfw-interface-template" : { - "type" : "artifact-template-velocity", - "file" : "Templates/vfw-interface-template.vtl" - }, - "vfw-interface-mapping" : { - "type" : "artifact-mapping-resource", - "file" : "Templates/vfw-interface-mapping.json" - } - } - }, - "rollback-process" : { - "type" : "dg-generic", - "properties" : { - "content" : { - "get_artifact" : [ "SELF", "dg-rollback-process" ] - }, - "dependency-node-templates" : [ "config-deploy" ] - }, - "artifacts" : { - "dg-rollback-process" : { - "type" : "artifact-directed-graph", - "file" : "Plans/Rollback.xml" - } - } - }, - "rollback" : { - "type" : "component-netconf-executor", - "requirements" : { - "netconf-connection" : { - "capability" : "netconf", - "node" : "netconf-device", - "relationship" : "tosca.relationships.ConnectsTo" - } - }, - "interfaces" : { - "ComponentNetconfExecutor" : { - "operations" : { - "process" : { - "inputs" : { - "script-type" : "jython", - "script-class-reference" : "Scripts/python/Rollback.py", - "instance-dependencies" : [ ], - "dynamic-properties" : "*config-deploy-properties" - }, - "outputs" : { - "response-data" : "", - "status" : "SUCCESS" - } - } - } - } - }, - "artifacts" : { - "junos-rollback-RPC-template" : { - "type" : "artifact-template-velocity", - "file" : "Templates/junos-rollback-RPC-template.vtl" - }, - "junos-rollback-RPC-mapping" : { - "type" : "artifact-mapping-resource", - "file" : "Templates/junos-rollback-RPC-mapping.json" - } - } - }, - "netconf-device" : { - "type" : "vnf-netconf-device", - "capabilities" : { - "netconf" : { - "properties" : { - "login-key" : { - "get_input" : "password" - }, - "login-account" : { - "get_input" : "username" - }, - "target-ip-address" : { - "get_input" : "ip" - }, - "port-number" : 830, - "connection-time-out" : 5 - } - } - } - } - } - } -}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json index d60e6f00c..8f3b9b4c5 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json @@ -1,106 +1,90 @@ { - "data_types" : { - "dt-config-deploy-properties" : { - "description" : "Dynamic DataType definition for workflow(config-deploy).", - "version" : "1.0.0", - "properties" : { - "vfw_interface_ip" : { - "type" : "dt-netbox-ip" - }, - "interface-name" : { - "type" : "string" - }, - "interface-description" : { - "type" : "string" - }, - "unit-number" : { - "type" : "string" - }, - "prefix-id" : { - "type" : "string", - "default" : "11" - }, - "vf-module-type" : { - "type" : "string" - }, - "vf-module-number" : { - "type" : "string", - "default" : "3" + "data_types": { + "dt-resource-assignment-properties": { + "description": "Dynamic DataType definition for workflow(resource-assignment).", + "version": "1.0.0", + "properties": { + "vfw_interface_ip": { + "type": "dt-netbox-ip" + }, + "interface-description": { + "type": "string" + }, + "vf-module-type": { + "type": "string" + }, + "vf-module-number": { + "type": "string", + "default": "3" + }, + "prefix-id": { + "type": "integer", + "default": 11 } }, - "derived_from" : "tosca.datatypes.Dynamic" + "derived_from": "tosca.datatypes.Dynamic" }, - "dt-netbox-ip" : { - "description" : "This is Netbox IP Data Type", - "version" : "1.0.0", - "properties" : { - "address" : { - "required" : true, - "type" : "string" - }, - "id" : { - "required" : true, - "type" : "integer" + "dt-config-assign-properties": { + "description": "Dynamic DataType definition for workflow(config-assign).", + "version": "1.0.0", + "properties": { + "hostname": { + "type": "string" } }, - "derived_from" : "tosca.datatypes.Root" + "derived_from": "tosca.datatypes.Dynamic" }, - "dt-resource-assignment-properties" : { - "description" : "Dynamic DataType definition for workflow(resource-assignment).", - "version" : "1.0.0", - "properties" : { - "hostname" : { - "type" : "string" + "dt-config-deploy-properties": { + "description": "Dynamic DataType definition for workflow(config-deploy).", + "version": "1.0.0", + "properties": { + "vfw_interface_ip": { + "type": "dt-netbox-ip" + }, + "interface-name": { + "type": "string" }, - "vfw_interface_ip" : { - "type" : "dt-netbox-ip" + "interface-description": { + "type": "string" }, - "interface-description" : { - "type" : "string" + "unit-number": { + "type": "string" }, - "vf-module-type" : { - "type" : "string" + "prefix-id": { + "type": "string", + "default": "11" }, - "vf-module-number" : { - "type" : "string", - "default" : "3" + "vf-module-type": { + "type": "string" }, - "prefix-id" : { - "type" : "integer", - "default" : 11 + "vf-module-number": { + "type": "string", + "default": "3" } }, - "derived_from" : "tosca.datatypes.Dynamic" + "derived_from": "tosca.datatypes.Dynamic" }, - "dt-rollback-properties" : { - "description" : "Dynamic DataType definition for workflow(rollback).", - "version" : "1.0.0", - "properties" : { - "vfw_interface_ip" : { - "type" : "dt-netbox-ip" - }, - "interface-name" : { - "type" : "string" - }, - "interface-description" : { - "type" : "string" - }, - "unit-number" : { - "type" : "string" - }, - "prefix-id" : { - "type" : "string", - "default" : "11" - }, - "vf-module-type" : { - "type" : "string" - }, - "vf-module-number" : { - "type" : "string", - "default" : "3" + "dt-rollback-properties": { + "description": "Dynamic DataType definition for workflow(rollback).", + "version": "1.0.0", + "properties": { + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-netbox-ip": { + "description": "This is Netbox IP Data Type", + "version": "1.0.0", + "properties": { + "address": { + "required": true, + "type": "string" + }, + "id": { + "required": true, + "type": "integer" } }, - "derived_from" : "tosca.datatypes.Dynamic" + "derived_from": "tosca.datatypes.Root" } } }
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json new file mode 100644 index 000000000..6a9df9b58 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json @@ -0,0 +1,326 @@ +{ + "metadata": { + "template_author": "Alexis de Talhouët", + "author-email": "adetalhouet89@gmail.com", + "user-groups": "ADMIN, OPERATION", + "template_name": "test", + "template_version": "1.0.0", + "template_tags": "test" + }, + "imports": [ + { + "file": "Definitions/data_types.json" + }, + { + "file": "Definitions/relationship_types.json" + }, + { + "file": "Definitions/artifact_types.json" + }, + { + "file": "Definitions/node_types.json" + }, + { + "file": "Definitions/policy_types.json" + } + ], + "dsl_definitions": { + "ipam-1": { + "type": "token-auth", + "url": "http://localhost:32768", + "token": "Token 0123456789abcdef0123456789abcdef01234567" + }, + "config-deploy-properties": { + "resolution-key": { + "get_input": "resolution-key" + } + } + }, + "topology_template": { + "workflows": { + "resource-assignment": { + "steps": { + "resource-assignment": { + "description": "Resource Assign Workflow", + "target": "resource-assignment", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "resource-assignment-properties": { + "description": "Dynamic PropertyDefinition for workflow(resource-assignment).", + "required": true, + "type": "dt-resource-assignment-properties" + } + }, + "outputs": { + "meshed-template": { + "type": "json", + "value": { + "get_attribute": [ + "resource-assignment", + "assignment-params" + ] + } + } + } + }, + "config-assign": { + "steps": { + "config-assign": { + "description": "Config Assign Workflow", + "target": "config-assign", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "config-assign-properties": { + "description": "Dynamic PropertyDefinition for workflow(config-assign).", + "required": true, + "type": "dt-config-assign-properties" + } + }, + "outputs": { + "dry-run": { + "type": "json", + "value": { + "get_attribute": [ + "config-assign", + "assignment-params" + ] + } + } + } + }, + "config-deploy": { + "steps": { + "config-deploy": { + "description": "Resource Assign and Python Netconf Activation Workflow", + "target": "config-deploy", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "resolution-key": { + "required": false, + "type": "string" + }, + "password": { + "required": true, + "type": "string" + }, + "username": { + "required": true, + "type": "string" + }, + "ip": { + "required": true, + "type": "string" + }, + "config-deploy-properties": { + "description": "Dynamic PropertyDefinition for workflow(config-deploy).", + "required": true, + "type": "dt-config-deploy-properties" + } + } + }, + "rollback": { + "steps": { + "rollback": { + "description": "Rollback Workflow", + "target": "rollback", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "resolution-key": { + "required": false, + "type": "string" + }, + "password": { + "required": true, + "type": "string" + }, + "username": { + "required": true, + "type": "string" + }, + "ip": { + "required": true, + "type": "string" + }, + "rollback-properties": { + "description": "Dynamic PropertyDefinition for workflow(rollback).", + "required": true, + "type": "dt-rollback-properties" + } + } + } + }, + "node_templates": { + "resource-assignment": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "vf-module-1" + ] + } + } + } + } + }, + "artifacts": { + "vf-module-1-template": { + "type": "artifact-template-velocity", + "file": "Templates/vf-module-1-template.vtl" + }, + "vf-module-1-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/vf-module-1-mapping.json" + } + } + }, + "config-assign": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "resolution-key": { + "get_input": "resolution-key" + }, + "store-result": true, + "artifact-prefix-names": [ + "hostname" + ] + } + } + } + } + }, + "artifacts": { + "hostname-template": { + "type": "artifact-template-velocity", + "file": "Templates/hostname-template.vtl" + }, + "hostname-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/hostname-mapping.json" + } + } + }, + "config-deploy": { + "type": "component-netconf-executor", + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "ComponentNetconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "jython", + "script-class-reference": "Scripts/python/ConfigDeploy.py", + "instance-dependencies": [], + "dynamic-properties": "*config-deploy-properties" + } + } + } + } + }, + "artifacts": { + "vfw-interface-template": { + "type": "artifact-template-velocity", + "file": "Templates/vfw-interface-template.vtl" + }, + "vfw-interface-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/vfw-interface-mapping.json" + } + } + }, + "rollback": { + "type": "component-netconf-executor", + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "ComponentNetconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "jython", + "script-class-reference": "Scripts/python/Rollback.py", + "instance-dependencies": [] + } + } + } + } + }, + "artifacts": { + "junos-rollback-RPC-template": { + "type": "artifact-template-velocity", + "file": "Templates/junos-rollback-RPC-template.vtl" + }, + "junos-rollback-RPC-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/junos-rollback-RPC-mapping.json" + } + } + }, + "netconf-device": { + "type": "vnf-netconf-device", + "capabilities": { + "netconf": { + "properties": { + "login-key": { + "get_input": "password" + }, + "login-account": { + "get_input": "username" + }, + "target-ip-address": { + "get_input": "ip" + }, + "port-number": 830, + "connection-time-out": 5 + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json index 15f02a1ce..1169a8d58 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json @@ -55,7 +55,7 @@ "type" : "source-capability", "properties" : { "script-type" : "jython", - "script-class-reference" : "DescriptionExample", + "script-class-reference" : "Scripts/python/DescriptionExample.py", "instance-dependencies" : [ ] } } diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml deleted file mode 100644 index ec154a15b..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<service-logic xmlns="http://www.onap.org/sdnc/svclogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module="CONFIG" version="1.0.0"> - <method rpc="ConfigDeploy" mode="sync"> - <block atomic="true"> - <execute plugin="config-deploy" method="process"> - <outcome value="failure"> - <return status="failure" /> - </outcome> - <outcome value="success"> - <return status="success" /> - </outcome> - </execute> - </block> - </method> -</service-logic>
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml deleted file mode 100644 index 15872e524..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<service-logic - xmlns='http://www.onap.org/sdnc/svclogic' - xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' - xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' - module='CONFIG' - version='1.0.0'> - <method rpc='ResourceAssignment' mode='sync'> - <block atomic="true"> - <execute plugin="resource-assignment" method="process"> - <outcome value='failure'> - <return status="failure"> - </return> - </outcome> - <outcome value='success'> - <return status="success"> - </return> - </outcome> - </execute> - </block> - </method> -</service-logic>
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml deleted file mode 100644 index c1231d7a5..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<service-logic xmlns="http://www.onap.org/sdnc/svclogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module="CONFIG" version="1.0.0"> - <method rpc="Rollback" mode="sync"> - <block atomic="true"> - <execute plugin="rollback" method="process"> - <outcome value="failure"> - <return status="failure" /> - </outcome> - <outcome value="success"> - <return status="success" /> - </outcome> - </execute> - </block> - </method> -</service-logic>
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/README b/components/model-catalog/blueprint-model/test-blueprint/golden/README index 06f91123e..3fba19cfc 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/README +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/README @@ -4,8 +4,19 @@ Example Pre-requisite Netbox running: https://github.com/netbox-community/netbox-docker + NETCONF capable device (JUNOS use in this example, but templates could be changed for another OS) - Blueprint processor + + Blueprint processor micro-service runnint + + CDS SQL database, populated with reference data as bellow: + + CREATE TABLE `demo` ( + `id` text DEFAULT NULL, + `value` text DEFAULT NULL + ) + + INSERT INTO `demo` VALUES ('1','vsn'),('2','vpg'),('3','vfw'); resources @@ -25,61 +36,74 @@ Example interface-name | input interface-description | capability (python script) - 3 workflow + 4 workflows + + resource-assignment - resource-assignment (dry-run) + Ability to resolve templates with their mappings and provide the result as output. + Example provide one templates: vf-module-1 - Ability to resolve multiple templates and mappings at the same time, - based on the request 'artifact-name', and provide the result as output. - Example provide two templates: hostname and vf-module-1 + Input: - In order to perform dry-run, we need to store the template and have - the ability to retrieve the stored result later point in time. For this - we have to specify that we want to store the result, and we need to provide - a resolution-key. + Nothing specific to pass as input to the request. The resolution will use SQL and script to + resolve all the parameters. + + Output: + + { + "resource-assignment-response": { + "meshed-template": { + "vf-module-1": "<interface>\n <description>This is the Virtual Firewall entity</description>\n <vfw>10.10.10.69/24</vfw>\n</interface>" + } + } + } - Here is the request payload: + config-assign (dry-run) + + Ability to resolve templates with their mappings and provide the result as output. + Example provide one templates: hostname + + This action uses the same functionality as resource-assignment, and in addition, + store the resulting meshed-template to be used later. + + Input - artifact name: template(s) to resolve - store-result: whether to save the generated configlet in DB resolution-key: To identify the configlet saved in the DB hostname: Value defined to be result trough input in the hostname mapping file - { - "resource-assignment-request": { - "artifact-name": [ "hostname", "vf-module-1" ], - "resolution-key": "hostname-demo-123", - "store-result": true, - "resource-assignment-properties": { - "hostname": "demo123" + { + "config-assign-request": { + "resolution-key": "config-assign-demo-123", + "config-assign-properties": { + "hostname": "demo-config-assign" } } - } + } Output: - { - "resource-assignment-params": { - "hostname": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration xmlns:junos=\"http://xml.juniper.net/junos/17.4R1/junos\">\n <system xmlns=\"http://yang.juniper.net/junos-qfx/conf/system\">\n <host-name operation=\"delete\" />\n <host-name operation=\"create\">demo123</host-name>\n </system>\n</configuration>\n", - "vf-module-1": "<interface>\n <description>This is the Virtual Firewall entity</description>\n <vfw>10.10.10.39/24</vfw>\n</interface>" - }, - "status": "success" - } + { + "config-assign-response": { + "dry-run": { + "hostname": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration xmlns:junos=\"http://xml.juniper.net/junos/17.4R1/junos\">\n <system xmlns=\"http://yang.juniper.net/junos-qfx/conf/system\">\n <host-name operation=\"delete\" />\n <host-name operation=\"create\">demo-config-assign</host-name>\n </system>\n</configuration>\n" + } + } + } config-deploy This action will run a python script that will retrieved the resolved template - from previous step using the resolution-key and the artifact-name. + from previous step using the resolution-key. The script will also resolve another template during its execution: the Interface Template. Finally, this action will push these resolved templates into a device (JUNOS) using NETCONF. The python script will make use of utilities classes provided by the platform: resolution helper and netconf client. Information about the device is modelled as a requirement of this action, specifying that - username, password and ip of the device should be provided as input. Note: you could resolve - those information using the resource resolution framework, if need be. + username, password and ip of the device should be provided as input. + Note: you could resolve those information using the resource resolution framework, if need be. - Here is the request payload: + Input: resolution-key: To identify the configlet saved in the DB in previous step username: NETCONF device user @@ -88,16 +112,18 @@ Example interface-name: Name of the interface to configure unit-number: Unit to configure for the interface - { - "resolution-key": "hostname-demo-123", - "username": "user", - "password": "pass", + { + "config-deploy-request": { + "resolution-key": "config-assign-demo-123", + "username": "admin", + "password": "passwd", "ip": "10.198.1.35", "config-deploy-properties": { "interface-name": "ge-0/0/7", - unit-number": "0" + "unit-number": "0" } } + } Output: @@ -109,26 +135,30 @@ Example specific RPC. To do so, a python script will be used, similar as in previous action, to dynamically resolve the rollback template payload, and send the RPC to the device. - Information about the NETCONF device is provided in a similar fashion as previous step. Actually, the - same model is used. + Information about the NETCONF device is provided in a similar fashion as previous step. - Here is the request payload: + Input: username: NETCONF device user password: NETCONF device password ip: NETCONF device ip - { - "username": "pass", - "password": "user", - "ip": "10.10.10.10" - } + { + "rollback-request": { + "username": "admin", + "password": "passwd", + "ip": "10.198.1.35", + "rollback-properties": { + + } + } + } Output: No specific output beside success or failure. -Postman collection used for this example. 4 requests are provided one per workflow to execute, and 1 to load the CBA in the runtime environment. +Postman collection used for this example. 5 requests are provided one per workflow to execute, and 1 to load the CBA in the runtime environment. - https://www.getpostman.com/collections/4d199ff02a735bd3e680
\ No newline at end of file + hhttps://www.getpostman.com/collections/4d199ff02a735bd3e680
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/ConfigDeploy.py index 7663a875e..66d12edae 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/ConfigDeploy.py @@ -14,16 +14,14 @@ import netconf_constant from common import ResolutionHelper -from java.lang import Exception as JavaException from netconfclient import NetconfClient from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \ NetconfComponentFunction -class NetconfRpcExample(NetconfComponentFunction): +class ConfigDeploy(NetconfComponentFunction): def process(self, execution_request): - try: log = globals()[netconf_constant.SERVICE_LOG] print(globals()) @@ -51,11 +49,7 @@ class NetconfRpcExample(NetconfComponentFunction): nc.unlock() nc.disconnect() - except JavaException, err: - log.error("Java Exception in the script {}", err) - except Exception, err: - log.error("Python Exception in the script {}", err) - def recover(self, runtime_exception, execution_request): - print self.addError(runtime_exception.getMessage()) - return None + log.error("Exception in the script {}", runtime_exception) + print self.addError(runtime_exception.cause.message) + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py index 4cf635afe..8482a89d3 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py @@ -19,28 +19,24 @@ from java.lang import Exception as JavaException class DescriptionExample(AbstractRAProcessor): def process(self, resource_assignment): - try: - # get dependencies result - value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type") - - # logic based on dependency outcome - result = "" - if value == "vfw": - result = "This is the Virtual Firewall entity" - elif value == "vsn": - result = "This is the Virtual Sink entity" - elif value == "vpg": - result = "This is the Virtual Packet Generator" + # get dependencies result + value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type") + + # logic based on dependency outcome + result = "" + if value == "vfw": + result = "This is the Virtual Firewall entity" + elif value == "vsn": + result = "This is the Virtual Sink entity" + elif value == "vpg": + result = "This is the Virtual Packet Generator" - # set value for resource getting currently resolved - self.set_resource_data_value(resource_assignment, result) + # set value for resource getting currently resolved + self.set_resource_data_value(resource_assignment, result) - except JavaException, err: - log.error("Java Exception in the script {}", err) - except Exception, err: - log.error("Python Exception in the script {}", err) return None def recover(self, runtime_exception, resource_assignment): - print self.addError(runtime_exception.getMessage()) - return None
\ No newline at end of file + log.error("Exception in the script {}", runtime_exception) + print self.addError(runtime_exception.cause.message) + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py index a2bef328e..40b3c3dcd 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py @@ -14,7 +14,6 @@ import netconf_constant from common import ResolutionHelper -from java.lang import Exception as JavaException from netconfclient import NetconfClient from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \ NetconfComponentFunction @@ -23,25 +22,22 @@ from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \ class Rollback(NetconfComponentFunction): def process(self, execution_request): - try: - log = globals()[netconf_constant.SERVICE_LOG] - print(globals()) - nc = NetconfClient(log, self, "netconf-connection") - rr = ResolutionHelper(self) + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) - # rollback config on device - nc.connect() - payloadHostnameRollback = rr.resolve_and_generate_message_from_template_prefix("junos-rollback-RPC") - nc.invoke_rpc(payloadHostnameRollback) - nc.commit() - nc.disconnect() + nc = NetconfClient(log, self, "netconf-connection") + rr = ResolutionHelper(self) - except JavaException, err: - log.error("Java Exception in the script {}", err) - except Exception, err: - log.error("Python Exception in the script {}", err) + # rollback config on device + nc.connect() + payloadHostnameRollback = rr.resolve_and_generate_message_from_template_prefix("junos-rollback-RPC") + nc.invoke_rpc(payloadHostnameRollback) + nc.commit() + nc.disconnect() + return None def recover(self, runtime_exception, execution_request): - print self.addError(runtime_exception.getMessage()) - return None + log.error("Exception in the script {}", runtime_exception) + print self.addError(runtime_exception.cause.message) + return None 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 065eda192..b8f3a202a 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 @@ -1,6 +1,6 @@ TOSCA-Meta-File-Version: 1.0.0 CSAR-Version: 1.0 Created-By: Alexis de Talhouët -Entry-Definitions: Definitions/activation-blueprint.json +Entry-Definitions: Definitions/golden-blueprint.json Template-Tags: test Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto index 4062a8cc8..3349443d4 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto @@ -3,11 +3,15 @@ import "BluePrintCommon.proto"; option java_multiple_files = true; package org.onap.ccsdk.cds.controllerblueprints.management.api; -message BluePrintManagementInput { +message BluePrintUploadInput { + org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; + FileChunk fileChunk = 2; +} + +message BluePrintRemoveInput { org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; string blueprintName = 2; string blueprintVersion = 3; - FileChunk fileChunk = 4; } message BluePrintManagementOutput { @@ -20,6 +24,6 @@ message FileChunk { } service BluePrintManagementService { - rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); - rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); + rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintManagementOutput); + rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintManagementOutput); } |