diff options
author | tragait <rahul.tyagi@est.tech> | 2019-11-06 11:44:11 +0000 |
---|---|---|
committer | tragait <rahul.tyagi@est.tech> | 2019-11-13 14:51:40 +0000 |
commit | 6f7a427e53f4e129d84198f4c94036b4fe6b3898 (patch) | |
tree | 87238feaa6262bd4c96a910cc0b3df38f0a7905d | |
parent | 54eb2f2680d4f2447a4d48b612b2b83e37d90754 (diff) |
CCSDK-1603:Changes in 'Config via netconf' BP to pull data from AAI
This commit includes changes in blueprint for "Configuration over
netconf", So that CDS can fetch data from AAI.
It has enhancement in UAT test yaml file, so this blueprint
can be tested.
An enhancement is also included to introduce request headers
in the source-rest.
Change-Id: I4ff973538249925239b89da4c5720ec63ffe8037
Issue-ID: CCSDK-1603
Signed-off-by: tragait <rahul.tyagi@est.tech>
29 files changed, 1045 insertions, 48 deletions
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/activation-blueprint.json index d185128d5..1a7ba559a 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/activation-blueprint.json @@ -32,7 +32,7 @@ "steps" : { "activate-process" : { "description" : "Create a configlet", - "target" : "config-assign-process", + "target" : "config-assign", "activities" : [ { "call_operation" : "" } ] @@ -58,7 +58,7 @@ "steps" : { "activate-process" : { "description" : "Send a configlet to the pnf", - "target" : "config-deploy-process", + "target" : "config-deploy", "activities" : [ { "call_operation" : "" } ] @@ -78,21 +78,6 @@ } }, "node_templates" : { - "config-assign-process" : { - "type" : "dg-generic", - "properties" : { - "content" : { - "get_artifact" : [ "SELF", "dg-config-assign-process" ] - }, - "dependency-node-templates" : [ "config-assign" ] - }, - "artifacts" : { - "dg-config-assign-process" : { - "type" : "artifact-directed-graph", - "file" : "Plans/CONFIG_configAssign.xml" - } - } - }, "config-assign" : { "type" : "component-resource-resolution", "interfaces" : { @@ -104,7 +89,7 @@ "get_input" : "resolution-key" }, "store-result" : true, - "artifact-prefix-names" : ["config-assign"] + "artifact-prefix-names" : [ "config-assign" ] }, "outputs" : { "resource-assignment-params" : { @@ -127,21 +112,6 @@ } } }, - "config-deploy-process" : { - "type" : "dg-generic", - "properties" : { - "content" : { - "get_artifact" : [ "SELF", "dg-config-deploy-process" ] - }, - "dependency-node-templates" : [ "config-deploy" ] - }, - "artifacts" : { - "dg-config-assign-process" : { - "type" : "artifact-directed-graph", - "file" : "Plans/CONFIG_configDeploy.xml" - } - } - }, "config-deploy" : { "type" : "component-script-executor", "interfaces" : { @@ -149,7 +119,9 @@ "operations" : { "process" : { "implementation" : { - "primary" : "component-script" + "primary" : "component-script", + "timeout" : 180, + "operation_host" : "SELF" }, "inputs" : { "script-type" : "jython", diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/node_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/node_types.json index 8c2c0abea..bfae6779e 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/node_types.json @@ -24,6 +24,12 @@ "required" : false, "type" : "string" }, + "occurrence" : { + "description" : "Number of time to perform the resolution.", + "required" : false, + "type" : "integer", + "default" : 1 + }, "store-result" : { "description" : "Whether or not to store the output.", "required" : false, @@ -80,8 +86,14 @@ "derived_from" : "tosca.nodes.Component" }, "component-script-executor" : { - "description" : "This is Restconf Transaction Configuration Component API", + "description" : "This is CLI Transaction Configuration Component API", "version" : "1.0.0", + "attributes" : { + "response-data" : { + "required" : false, + "type" : "json" + } + }, "capabilities" : { "component-node" : { "type" : "tosca.capabilities.Node" @@ -114,7 +126,7 @@ }, "outputs" : { "response-data" : { - "description" : "Execution Response Data in JSON format.", + "description" : "Execution Response Data.", "required" : false, "type" : "string" }, @@ -155,6 +167,82 @@ "properties" : { }, "derived_from" : "tosca.nodes.ResourceSource" }, + "source-rest" : { + "description" : "This is Rest Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "type" : { + "required" : true, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON" ] + } ], + "default" : "JSON" + }, + "headers" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "verb" : { + "required" : true, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "GET", "POST", "DELETE", "PUT" ] + } ], + "default" : "GET" + }, + "payload" : { + "required" : false, + "type" : "string", + "default" : "" + }, + "endpoint-selector" : { + "required" : false, + "type" : "string" + }, + "url-path" : { + "required" : true, + "type" : "string" + }, + "path" : { + "required" : true, + "type" : "string" + }, + "expression-type" : { + "required" : false, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON_PATH", "JSON_POINTER" ] + } ], + "default" : "JSON_PATH" + }, + "input-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "output-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "key-dependencies" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "derived_from" : "tosca.nodes.ResourceSource" + }, "tosca.nodes.Component" : { "description" : "This is default Component Node", "version" : "1.0.0", diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/resources_definition_types.json index 114eb1992..d1183f14b 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/resources_definition_types.json @@ -15,17 +15,32 @@ } }, "pnf-ipv4-address" : { - "tags" : "pnf-ipv4-address", + "tags" : "aai-get", "name" : "pnf-ipv4-address", "property" : { - "description" : "pnf-ipv4-address", + "description" : "primary aai data to get resource", "type" : "string" }, - "updated-by" : "Rodrigo Ottero <rodrigo.ottero@est.tech>", + "updated-by" : "Rahul, Tyagi <rahul.tyagi@est.tech>", "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } + "aai-data" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "verb" : "GET", + "url-path" : "/aai/v14/network/pnfs/pnf/$pnf-id", + "path" : "/ipaddress-v4-oam", + "input-key-mapping" : { + "pnf-id" : "pnf-id" + }, + "headers" : { + "Accept" : "application/json" + }, + "output-key-mapping" : { + "ipaddress-v4-oam" : "value" + }, + "key-dependencies" : [ "pnf-id" ] + } } } } diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Environments/source-db.properties b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Environments/source-db.properties new file mode 100644 index 000000000..49a7eb47b --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Environments/source-db.properties @@ -0,0 +1 @@ +dynamic-db-source.password=sdnctl
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Environments/source-rest.properties b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Environments/source-rest.properties new file mode 100644 index 000000000..b07c80995 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Environments/source-rest.properties @@ -0,0 +1,9 @@ +blueprintsprocessor.restclient.sdnc.type=basic-auth +blueprintsprocessor.restclient.sdnc.url=http://127.0.0.1:9111 +blueprintsprocessor.restclient.sdnc.userId=sampleuser +blueprintsprocessor.restclient.sdnc.token=sampletoken + +blueprintsprocessor.restclient.sdnc1.type=basic-auth +blueprintsprocessor.restclient.sdnc1.url=http://127.0.0.1:9111 +blueprintsprocessor.restclient.sdnc1.userId=sampleuser +blueprintsprocessor.restclient.sdnc1.token=sampletoken
\ 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 index f8225e0ce..af0b7e129 100644 --- 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 @@ -24,7 +24,7 @@ class RestconfConfigDeploy(AbstractScriptComponentFunction): log = globals()["log"] configlet_template_name = "config-assign" configlet_resource_path = "/yang-ext:mount/mynetconf:netconflist" - restconf_server_identifier = "sdncodl" + restconf_server_identifier = "sdnc" def process(self, execution_request): 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 fbdb2eea8..518bbe020 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 @@ -18,7 +18,6 @@ processes: config-assign-properties: service-instance-id: siid_1234 pnf-id: &pnfId pnf-id-2019-07-12 - pnf-ipv4-address: &pnfAddress "192.168.100.11" service-model-uuid: service-model-uuid pnf-customization-uuid: pnf-customization-uuid expectedResponse: @@ -45,9 +44,10 @@ processes: config-deploy-properties: service-instance-id: siid_1234 pnf-id: *pnfId - pnf-ipv4-address: *pnfAddress service-model-uuid: service-model-uuid pnf-customization-uuid: pnf-customization-uuid + pnf-ipv4-address: &pnfAddress 13.13.13.13 + ipaddress-v6-oam: 1::13 expectedResponse: commonHeader: *commonHeader actionIdentifiers: *deploy-ai @@ -60,7 +60,7 @@ processes: message: success external-services: - - selector: sdncodl + - selector: sdnc expectations: - request: method: PUT @@ -114,4 +114,4 @@ external-services: value: { netconflist: { netconf: [ { netconf-id: "30", netconf-param: "3000" }]}} - request: method: DELETE - path: *configUri + path: *configUri
\ No newline at end of file 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/activation-blueprint.json new file mode 100644 index 000000000..214f7dd75 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/activation-blueprint.json @@ -0,0 +1,156 @@ +{ + "tosca_definitions_version" : "controller_blueprint_1_0_0", + "metadata" : { + "template_author" : "Rahul Tyagi", + "author-email" : "rahul.tyagi@est.tech", + "user-groups" : "ADMIN, OPERATION", + "template_name" : "configuration_over_restconf", + "template_version" : "1.0.0", + "template_tags" : "pnf, restconf, config, configuration" + }, + "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" : { + "config-deploy-properties" : { + "resolution-key" : { + "get_input" : "resolution-key" + } + } + }, + "topology_template" : { + "workflows" : { + "config-assign" : { + "steps" : { + "activate-process" : { + "description" : "Create a configlet", + "target" : "config-assign", + "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" : { + "activate-process" : { + "description" : "Send a configlet to the pnf", + "target" : "config-deploy", + "activities" : [ { + "call_operation" : "" + } ] + } + }, + "inputs" : { + "resolution-key" : { + "required" : true, + "type" : "string" + }, + "config-deploy-properties" : { + "description" : "Dynamic PropertyDefinition for workflow(config-deploy).", + "required" : true, + "type" : "dt-config-deploy-properties" + } + } + } + }, + "node_templates" : { + "config-assign" : { + "type" : "component-resource-resolution", + "interfaces" : { + "ResourceResolutionComponent" : { + "operations" : { + "process" : { + "inputs" : { + "resolution-key" : { + "get_input" : "resolution-key" + }, + "store-result" : true, + "artifact-prefix-names" : [ "config-assign" ] + }, + "outputs" : { + "resource-assignment-params" : { + "get_attribute" : [ "SELF", "assignment-params" ] + }, + "status" : "success" + } + } + } + } + }, + "artifacts" : { + "config-assign-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/config-assign-restconf-configlet-template.vtl" + }, + "config-assign-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Definitions/config-assign-pnf-mapping.json" + } + } + }, + "config-deploy" : { + "type" : "component-script-executor", + "interfaces" : { + "ComponentScriptExecutor" : { + "operations" : { + "process" : { + "implementation" : { + "primary" : "component-script", + "timeout" : 180, + "operation_host" : "SELF" + }, + "inputs" : { + "script-type" : "jython", + "script-class-reference" : "Scripts/python/RestconfConfigDeploy.py", + "dynamic-properties" : "*config-deploy-properties" + }, + "outputs" : { + "response-data" : "", + "status" : "success" + } + } + } + } + }, + "artifacts" : { + "config-deploy-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/config-deploy-restconf-mount-template.vtl" + }, + "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" + } + } + } + } + } +}
\ No newline at end of file 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 new file mode 100644 index 000000000..aa5295e44 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json @@ -0,0 +1,28 @@ +{ + "artifact_types" : { + "artifact-directed-graph" : { + "description" : "Directed Graph File", + "version" : "1.0.0", + "derived_from" : "tosca.artifacts.Implementation", + "file_ext" : [ "json", "xml" ] + }, + "artifact-mapping-resource" : { + "description" : "Resource Mapping File used along with Configuration template", + "version" : "1.0.0", + "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", + "derived_from" : "tosca.artifacts.Implementation", + "file_ext" : [ "vtl" ] + } + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/config-assign-pnf-mapping.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/config-assign-pnf-mapping.json new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/config-assign-pnf-mapping.json @@ -0,0 +1 @@ +[] diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/config-deploy-pnf-mapping.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/config-deploy-pnf-mapping.json new file mode 100644 index 000000000..dd8889c80 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/config-deploy-pnf-mapping.json @@ -0,0 +1,25 @@ +[ + { + "name": "pnf-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "pnf-id", + "dictionary-source": "input", + "dependencies": [ + ] + }, + { + "name": "pnf-ipv4-address", + "input-param": false, + "property": { + "type": "string" + }, + "dictionary-name": "pnf-ipaddress-aai", + "dictionary-source": "aai-data", + "dependencies": [ + "pnf-id" + ] + } +] diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/data_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/data_types.json new file mode 100644 index 000000000..a0804bb3f --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/data_types.json @@ -0,0 +1,23 @@ +{ + "data_types" : { + "dt-config-assign-properties" : { + "description" : "Dynamic DataType definition for workflow(config-assign).", + "version" : "1.0.0", + "properties" : { }, + "derived_from" : "tosca.datatypes.Dynamic" + }, + "dt-config-deploy-properties" : { + "description" : "Dynamic DataType definition for workflow(config-deploy).", + "version" : "1.0.0", + "properties" : { + "pnf-ipv4-address" : { + "type" : "string" + }, + "pnf-id" : { + "type" : "string" + } + }, + "derived_from" : "tosca.datatypes.Dynamic" + } + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/node_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/node_types.json new file mode 100644 index 000000000..bfae6779e --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/node_types.json @@ -0,0 +1,262 @@ +{ + "node_types" : { + "component-resource-resolution" : { + "description" : "This is Resource Assignment Component API", + "version" : "1.0.0", + "attributes" : { + "assignment-params" : { + "required" : true, + "type" : "string" + } + }, + "capabilities" : { + "component-node" : { + "type" : "tosca.capabilities.Node" + } + }, + "interfaces" : { + "ResourceResolutionComponent" : { + "operations" : { + "process" : { + "inputs" : { + "resolution-key" : { + "description" : "Key for service instance related correlation.", + "required" : false, + "type" : "string" + }, + "occurrence" : { + "description" : "Number of time to perform the resolution.", + "required" : false, + "type" : "integer", + "default" : 1 + }, + "store-result" : { + "description" : "Whether or not to store the output.", + "required" : false, + "type" : "boolean" + }, + "resource-type" : { + "description" : "Request type.", + "required" : false, + "type" : "string" + }, + "artifact-prefix-names" : { + "description" : "Template , Resource Assignment Artifact Prefix names", + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + }, + "request-id" : { + "description" : "Request Id, Unique Id for the request.", + "required" : true, + "type" : "string" + }, + "resource-id" : { + "description" : "Resource Id.", + "required" : false, + "type" : "string" + }, + "action-name" : { + "description" : "Action Name of the process", + "required" : false, + "type" : "string" + }, + "dynamic-properties" : { + "description" : "Dynamic Json Content or DSL Json reference.", + "required" : false, + "type" : "json" + } + }, + "outputs" : { + "resource-assignment-params" : { + "required" : true, + "type" : "string" + }, + "status" : { + "required" : true, + "type" : "string" + } + } + } + } + } + }, + "derived_from" : "tosca.nodes.Component" + }, + "component-script-executor" : { + "description" : "This is CLI Transaction Configuration Component API", + "version" : "1.0.0", + "attributes" : { + "response-data" : { + "required" : false, + "type" : "json" + } + }, + "capabilities" : { + "component-node" : { + "type" : "tosca.capabilities.Node" + } + }, + "interfaces" : { + "ComponentScriptExecutor" : { + "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" + }, + "dynamic-properties" : { + "description" : "Dynamic Json Content or DSL Json reference.", + "required" : false, + "type" : "json" + } + }, + "outputs" : { + "response-data" : { + "description" : "Execution Response Data.", + "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", + "properties" : { + "content" : { + "required" : true, + "type" : "string" + }, + "dependency-node-templates" : { + "description" : "Dependent Step Components NodeTemplate name.", + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "derived_from" : "tosca.nodes.Workflow" + }, + "source-input" : { + "description" : "This is Input Resource Source Node Type", + "version" : "1.0.0", + "properties" : { }, + "derived_from" : "tosca.nodes.ResourceSource" + }, + "source-rest" : { + "description" : "This is Rest Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "type" : { + "required" : true, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON" ] + } ], + "default" : "JSON" + }, + "headers" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "verb" : { + "required" : true, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "GET", "POST", "DELETE", "PUT" ] + } ], + "default" : "GET" + }, + "payload" : { + "required" : false, + "type" : "string", + "default" : "" + }, + "endpoint-selector" : { + "required" : false, + "type" : "string" + }, + "url-path" : { + "required" : true, + "type" : "string" + }, + "path" : { + "required" : true, + "type" : "string" + }, + "expression-type" : { + "required" : false, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON_PATH", "JSON_POINTER" ] + } ], + "default" : "JSON_PATH" + }, + "input-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "output-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "key-dependencies" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "derived_from" : "tosca.nodes.ResourceSource" + }, + "tosca.nodes.Component" : { + "description" : "This is default Component Node", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "tosca.nodes.ResourceSource" : { + "description" : "TOSCA base type for Resource Sources", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "tosca.nodes.Workflow" : { + "description" : "This is Directed Graph Node Type", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + } + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/policy_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/policy_types.json new file mode 100644 index 000000000..1e44cc70a --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/policy_types.json @@ -0,0 +1,3 @@ +{ + "policy_types" : { } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/relationship_types.json new file mode 100644 index 000000000..4ddd7a57c --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/relationship_types.json @@ -0,0 +1,3 @@ +{ + "relationship_types" : { } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/resources_definition_types.json new file mode 100644 index 000000000..235a05d27 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/resources_definition_types.json @@ -0,0 +1,47 @@ +{ + "pnf-id" : { + "tags" : "pnf-id", + "name" : "pnf-id", + "property" : { + "description" : "pnf-id", + "type" : "string" + }, + "updated-by" : "Rahul Tyagi <rahul.tyagi@est.tech>", + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } + }, + "pnf-ipaddress-aai" : { + "tags" : "aai-get", + "name" : "pnf-ipaddress-aai", + "property" : { + "description" : "primary aai data to get resource", + "type" : "string" + }, + "updated-by" : "Rahul, Tyagi <rahul.tyagi@est.tech>", + "sources" : { + "aai-data" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "verb" : "GET", + "url-path" : "/aai/v14/network/pnfs/pnf/$pnf-id", + "path" : "/ipaddress-v4-oam", + "input-key-mapping" : { + "pnf-id" : "pnf-id" + }, + "headers" : { + "Accept" : "application/json" + }, + "output-key-mapping" : { + "ipaddress-v4-oam" : "value" + }, + "key-dependencies" : [ "pnf-id" ] + } + } + } + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Environments/source-db.properties b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Environments/source-db.properties new file mode 100644 index 000000000..49a7eb47b --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Environments/source-db.properties @@ -0,0 +1 @@ +dynamic-db-source.password=sdnctl
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Environments/source-rest.properties b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Environments/source-rest.properties new file mode 100644 index 000000000..bc1eb7417 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Environments/source-rest.properties @@ -0,0 +1,4 @@ +blueprintsprocessor.restclient.sdnc.type=basic-auth +blueprintsprocessor.restclient.sdnc.url=http://127.0.0.1:9111 +blueprintsprocessor.restclient.sdnc.userId=sampleuser +blueprintsprocessor.restclient.sdnc.token=sampletoken
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Plans/CONFIG_configAssign.xml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Plans/CONFIG_configAssign.xml new file mode 100644 index 000000000..a3eedf172 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Plans/CONFIG_configAssign.xml @@ -0,0 +1,15 @@ +<?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="ResourceAssignAndActivate" mode="sync"> + <block atomic="true"> + <execute plugin="config-assign" method="process"> + <outcome value="failure"> + <return status="failure"/> + </outcome> + <outcome value="success"> + <return status="success"/> + </outcome> + </execute> + </block> + </method> +</service-logic> diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Plans/CONFIG_configDeploy.xml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Plans/CONFIG_configDeploy.xml new file mode 100644 index 000000000..f4e1b996f --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Plans/CONFIG_configDeploy.xml @@ -0,0 +1,15 @@ +<?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="ResourceAssignAndActivate" 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> 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 new file mode 100644 index 000000000..af0b7e129 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py @@ -0,0 +1,78 @@ +# ============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 new file mode 100644 index 000000000..21f431861 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/TOSCA-Metadata/TOSCA.meta @@ -0,0 +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 +Template-Version: 1.0.0 +Template-Tags: activation-blueprint diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Templates/config-assign-restconf-configlet-template.vtl b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Templates/config-assign-restconf-configlet-template.vtl new file mode 100644 index 000000000..af91ba00d --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Templates/config-assign-restconf-configlet-template.vtl @@ -0,0 +1,53 @@ +{ + "ietf-restconf:yang-patch":{ + "patch-id":"patch-1", + "edit":[ + { + "edit-id":"edit1", + "operation":"merge", + "target":"/", + "value":{ + "netconflist":{ + "netconf":[ + { + "netconf-id":"10", + "netconf-param":"1000" + } + ] + } + } + }, + { + "edit-id":"edit2", + "operation":"merge", + "target":"/", + "value":{ + "netconflist":{ + "netconf":[ + { + "netconf-id":"20", + "netconf-param":"2000" + } + ] + } + } + }, + { + "edit-id":"edit3", + "operation":"merge", + "target":"/", + "value":{ + "netconflist":{ + "netconf":[ + { + "netconf-id":"30", + "netconf-param":"3000" + } + ] + } + } + } + + ] + } +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Templates/config-deploy-restconf-mount-template.vtl b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Templates/config-deploy-restconf-mount-template.vtl new file mode 100644 index 000000000..8098b05d8 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Templates/config-deploy-restconf-mount-template.vtl @@ -0,0 +1,18 @@ +{ + "node": [ + { + "node-id": "${pnf-id}", + "netconf-node-topology:protocol": { + "name": "TLS" + }, + "netconf-node-topology:host": "${pnf-ipv4-address}", + "netconf-node-topology:key-based": { + "username": "netconf", + "key-id": "ODL_private_key_0" + }, + "netconf-node-topology:port": 6513, + "netconf-node-topology:tcp-only": false, + "netconf-node-topology:max-connection-attempts": 5 + } + ] +}
\ No newline at end of file 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 new file mode 100644 index 000000000..1a5995e06 --- /dev/null +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Tests/uat.yaml @@ -0,0 +1,130 @@ +%YAML 1.1 +--- +processes: + - name: config-assign + request: + commonHeader: &commonHeader + originatorId: sdnc + requestId: "123456-1000" + subRequestId: sub-123456-1000 + actionIdentifiers: &assign-ai + blueprintName: configuration_over_restconf + blueprintVersion: "1.0.0" + actionName: config-assign + mode: sync + payload: + config-assign-request: + resolution-key: &resKey "RES-KEY 61" + config-assign-properties: + service-instance-id: siid_1234 + pnf-id: &pnfId pnf-id-2019-07-12 + service-model-uuid: service-model-uuid + pnf-customization-uuid: pnf-customization-uuid + expectedResponse: + commonHeader: *commonHeader + actionIdentifiers: *assign-ai + status: + code: 200 + eventType: EVENT_COMPONENT_EXECUTED + errorMessage: null + message: success + payload: + config-assign-response: {} + - name: config-deploy + request: + commonHeader: *commonHeader + actionIdentifiers: &deploy-ai + actionName: config-deploy + blueprintName: configuration_over_restconf + blueprintVersion: "1.0.0" + mode: sync + payload: + config-deploy-request: + resolution-key: *resKey + config-deploy-properties: + service-instance-id: siid_1234 + pnf-id: *pnfId + service-model-uuid: service-model-uuid + pnf-customization-uuid: pnf-customization-uuid + expectedResponse: + commonHeader: *commonHeader + actionIdentifiers: *deploy-ai + payload: + config-deploy-response: {} + status: + code: 200 + errorMessage: null + eventType: EVENT_COMPONENT_EXECUTED + message: success + +external-services: + - selector: aai-data + expectations: + - request: + method: GET + path: [ /aai/v14/network/pnfs/pnf, *pnfId] + headers: + Accept: application/json + response: + headers: + Content-Type: application/json + body: + ipaddress-v4-oam: &pnfAddress 13.13.13.13 + ipaddress-v6-oam: 1::13 + - selector: sdnc + expectations: + - request: + method: PUT + path: &configUri [ restconf/config, &nodeIdentifier [network-topology:network-topology/topology/topology-netconf/node, *pnfId]] + headers: + Content-Type: application/json + body: + node: + - node-id: *pnfId + netconf-node-topology:protocol: { name: TLS } + netconf-node-topology:host: *pnfAddress + netconf-node-topology:key-based: + username: netconf + key-id: ODL_private_key_0 + netconf-node-topology:port: 6513 + netconf-node-topology:tcp-only: false + netconf-node-topology:max-connection-attempts: 5 + response: + status: 201 + - request: + method: GET + path: [ restconf/operational, *nodeIdentifier] + response: + body: + node: [ { netconf-node-topology:connection-status: connected }] + - request: + method: GET + path: [*configUri, &configletResourcePath yang-ext:mount/mynetconf:netconflist] + response: + body: {} + - request: + method: PATCH + path: [*configUri, *configletResourcePath] + headers: + Content-Type: application/yang.patch+json + body: + ietf-restconf:yang-patch: + patch-id: patch-1 + edit: + - edit-id: edit1 + operation: merge + target: / + value: { netconflist: { netconf: [ { netconf-id: "10", netconf-param: "1000" }]}} + - edit-id: edit2 + operation: merge + target: / + value: { netconflist: { netconf: [ { netconf-id: "20", netconf-param: "2000" }]}} + - edit-id: edit3 + operation: merge + target: / + value: { netconflist: { netconf: [ { netconf-id: "30", netconf-param: "3000" }]}} + - request: + method: DELETE + path: *configUri + + diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-rest.json b/components/model-catalog/definition-type/starter-type/node_type/source-rest.json index f9995a883..224778be1 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/source-rest.json +++ b/components/model-catalog/definition-type/starter-type/node_type/source-rest.json @@ -14,6 +14,13 @@ } ] }, + "headers" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, "verb": { "required": true, "type": "string", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/pnf-ipaddress-aai.json b/components/model-catalog/resource-dictionary/starter-dictionary/pnf-ipaddress-aai.json new file mode 100755 index 000000000..f96319266 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/pnf-ipaddress-aai.json @@ -0,0 +1,32 @@ +{ + "tags": "aai-get", + "name": "pnf-ipaddress-aai", + "property": { + "description": "primary aai data to get resource", + "type": "string" + }, + "updated-by": "Rahul, Tyagi <rahul.tyagi@est.tech>", + "sources": { + "aai-data": { + "type": "source-rest", + "properties": { + "type": "JSON", + "verb": "GET", + "url-path": "/aai/v14/network/pnfs/pnf/$pnf-id", + "path": "/ipaddress-v4-oam", + "input-key-mapping": { + "pnf-id": "pnf-id" + }, + "headers" : { + "Accept" : "application/json" + }, + "output-key-mapping": { + "ipaddress-v4-oam": "value" + }, + "key-dependencies": [ + "pnf-id" + ] + } + } + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt index 604d4d40b..2a0e7a443 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt @@ -63,6 +63,8 @@ open class RestResourceSource : ResourceSourceProperties() { var inputKeyMapping: MutableMap<String, String>? = null @get:JsonProperty("output-key-mapping") var outputKeyMapping: MutableMap<String, String>? = null + @get:JsonProperty("headers") + var headers: Map<String, String> = emptyMap() @get:JsonProperty("key-dependencies") lateinit var keyDependencies: MutableList<String> } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt index 2b9239f4c..e9aa2749a 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt @@ -83,10 +83,12 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS logger.info("RestResource ($dSource) dictionary information: " + "URL:($urlPath), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})") + val requestHeaders = sourceProperties.headers + logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") // Get the Rest Client Service val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties) - val response = restClientService.exchangeResource(verb, urlPath, payload) + val response = restClientService.exchangeResource(verb, urlPath, payload, requestHeaders.toMap()) val responseStatusCode = response.status val responseBody = response.body val outputKeyMapping = sourceProperties.outputKeyMapping |