From 052b7bd78ad4808f6eac31553c12cee7569eaefb Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 4 Sep 2018 20:24:35 +0000 Subject: Controller Blueprints Microservice Refactor controller blueprint core and resource dictionary modules to components module. Change-Id: If5ba5e35e9c95bc19bc78fb10bd62d6551ba7aca Issue-ID: CCSDK-514 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../Definitions/activation-blueprint.json | 411 ++++++++++++++ .../Mappings/baseconfig-mapping.json | 3 + .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 +++ .../Scripts/SamplePythonComponentNode.py | 8 + .../baseconfiguration/Scripts/__init__.py | 0 .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 8 + .../Templates/baseconfig-template.vtl | 1 + .../load/blueprints/baseconfiguration/__init__.py | 0 .../Definitions/sample-nodetype.json | 34 ++ .../Definitions/simple-baseconfig.json | 345 ++++++++++++ .../Mappings/baseconfig-mapping.json | 3 + .../simple-baseconfig/Plans/ActivateProcess.bpmn | 66 +++ .../Scripts/SamplePythonComponentNode.py | 8 + .../simple-baseconfig/Scripts/__init__.py | 0 .../simple-baseconfig/TOSCA-Metadata/TOSCA.meta | 8 + .../Templates/base-config-template.vtl | 40 ++ .../Templates/baseconfig-template.vtl | 1 + .../Templates/licence-template.vtl | 4 + .../load/blueprints/simple-baseconfig/__init__.py | 0 .../artifact_type/artifact-bpmn-camunda.json | 8 + .../artifact_type/artifact-directed-graph.json | 9 + .../artifact_type/artifact-mapping-resource.json | 8 + .../artifact_type/artifact-script-python.json | 8 + .../artifact_type/artifact-template-velocity.json | 8 + .../tosca.artifacts.Implementation.json | 5 + .../model_type/data_type/datatype-property.json | 27 + .../data_type/datatype-resource-assignment.json | 46 ++ .../load/model_type/data_type/dt-license-key.json | 11 + .../load/model_type/data_type/dt-v4-aggregate.json | 15 + .../data_type/tosca.datatypes.Credential.json | 31 ++ .../node_type/artifact-config-template.json | 37 ++ .../node_type/component-config-generator.json | 72 +++ .../node_type/component-netconf-executor.json | 79 +++ .../node_type/component-resource-assignment.json | 68 +++ .../model_type/node_type/dg-activate-netconf.json | 66 +++ .../model_type/node_type/dg-config-generator.json | 65 +++ .../node_type/dg-resource-assign-activate.json | 70 +++ .../node_type/dg-resource-assignment.json | 65 +++ .../model_type/node_type/vnf-netconf-device.json | 42 ++ components/core/pom.xml | 68 +++ .../core/BluePrintConstants.kt | 142 +++++ .../core/BluePrintException.kt | 49 ++ .../core/BluePrintProcessorException.kt | 49 ++ .../controllerblueprints/core/BluePrintTypes.kt | 91 +++ .../core/ConfigModelConstant.kt | 44 ++ .../controllerblueprints/core/CustomFunctions.kt | 75 +++ .../core/data/BluePrintExpressionData.kt | 70 +++ .../core/data/BluePrintModel.kt | 612 +++++++++++++++++++++ .../core/factory/BluePrintEnhancerFactory.kt | 45 ++ .../core/factory/BluePrintParserFactory.kt | 51 ++ .../core/factory/BluePrintValidatorFactory.kt | 45 ++ .../core/service/BluePrintChainedService.kt | 117 ++++ .../core/service/BluePrintContext.kt | 177 ++++++ .../core/service/BluePrintEnhancerService.kt | 259 +++++++++ .../core/service/BluePrintExpressionService.kt | 176 ++++++ .../core/service/BluePrintParserService.kt | 62 +++ .../core/service/BluePrintRepoService.kt | 98 ++++ .../core/service/BluePrintRuntimeService.kt | 278 ++++++++++ .../core/service/BluePrintValidatorService.kt | 360 ++++++++++++ .../core/service/PropertyAssignmentService.kt | 200 +++++++ .../core/utils/BluePrintMetadataUtils.kt | 95 ++++ .../core/utils/BluePrintRuntimeUtils.kt | 55 ++ .../core/utils/JacksonReactorUtils.kt | 108 ++++ .../core/utils/JacksonUtils.kt | 248 +++++++++ .../core/utils/ResourceResolverUtils.kt | 62 +++ .../core/utils/ServiceTemplateUtils.kt | 44 ++ .../core/utils/TopologicalSortingUtils.kt | 131 +++++ .../core/CustomFunctionsTest.kt | 35 ++ .../core/service/BluePrintContextTest.kt | 70 +++ .../core/service/BluePrintEnhancerServiceTest.kt | 41 ++ .../core/service/BluePrintExpressionServiceTest.kt | 109 ++++ .../core/service/BluePrintParserFactoryTest.kt | 42 ++ .../core/service/BluePrintRepoFileServiceTest.kt | 57 ++ .../core/service/BluePrintRuntimeServiceTest.kt | 131 +++++ .../BluePrintValidatorDefaultServiceTest.kt | 49 ++ .../core/utils/BluePrintMetadataUtilsTest.kt | 40 ++ .../core/utils/JacksonReactorUtilsTest.kt | 51 ++ .../core/utils/JacksonUtilsTest.kt | 93 ++++ .../core/utils/TopologicalSortingUtilsTest.kt | 36 ++ .../src/test/resources/componentnode/default.json | 100 ++++ .../core/src/test/resources/data/alltype-data.json | 10 + .../src/test/resources/data/default-context.json | 5 + .../resources/dictionary/dictionary_schema.json | 261 +++++++++ .../src/test/resources/properties/convert.json | 33 ++ .../src/test/resources/properties/default.json | 16 + components/parent/pom.xml | 299 ++++++++++ components/pom.xml | 45 ++ .../node_type/source-component-java.json | 31 ++ .../load/model_type/node_type/source-db.json | 44 ++ .../load/model_type/node_type/source-default.json | 18 + .../load/model_type/node_type/source-input.json | 18 + .../load/model_type/node_type/source-rest.json | 61 ++ .../node_type/tosca.nodes.ResourceSource.json | 5 + .../load/resource_dictionary/db-source.json | 26 + .../load/resource_dictionary/default-source.json | 18 + .../load/resource_dictionary/input-source.json | 19 + .../load/resource_dictionary/mdsal-source.json | 36 ++ components/resource-dict/pom.xml | 49 ++ .../resource/dict/ResourceAssignmentProcessor.kt | 34 ++ .../resource/dict/ResourceDefinition.kt | 100 ++++ .../resource/dict/ResourceDictionaryConstants.kt | 34 ++ .../service/ResourceAssignmentEnhancerService.kt | 86 +++ .../service/ResourceAssignmentValidationService.kt | 151 +++++ .../dict/service/ResourceDefinitionRepoService.kt | 61 ++ .../service/ResourceDefinitionValidationService.kt | 114 ++++ .../dict/utils/BulkResourceSequencingUtils.kt | 109 ++++ .../resource/dict/utils/ResourceDictionaryUtils.kt | 78 +++ .../resource/dict/ResourceDefinitionTest.java | 60 ++ .../ResourceAssignmentEnhancerServiceTest.java | 48 ++ .../ResourceAssignmentValidationServiceTest.kt | 57 ++ .../service/ResourceDefinitionRepoServiceTest.java | 36 ++ .../ResourceDefinitionValidationServiceTest.java | 56 ++ .../utils/BulkResourceSequencingUtilsTest.java | 37 ++ .../dict/utils/ResourceDictionaryUtilsTest.java | 99 ++++ .../resources/data/resource-assignment-input.json | 10 + .../src/test/resources/enrich/simple-enrich.json | 37 ++ .../src/test/resources/validation/cyclic.json | 111 ++++ .../src/test/resources/validation/duplicate.json | 110 ++++ .../src/test/resources/validation/success.json | 110 ++++ 119 files changed, 8943 insertions(+) create mode 100644 components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json create mode 100644 components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json create mode 100644 components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn create mode 100644 components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py create mode 100644 components/core/load/blueprints/baseconfiguration/Scripts/__init__.py create mode 100644 components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta create mode 100644 components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl create mode 100644 components/core/load/blueprints/baseconfiguration/__init__.py create mode 100644 components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json create mode 100644 components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json create mode 100644 components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json create mode 100644 components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn create mode 100644 components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py create mode 100644 components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py create mode 100644 components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta create mode 100644 components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl create mode 100644 components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl create mode 100644 components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl create mode 100644 components/core/load/blueprints/simple-baseconfig/__init__.py create mode 100644 components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json create mode 100644 components/core/load/model_type/artifact_type/artifact-directed-graph.json create mode 100644 components/core/load/model_type/artifact_type/artifact-mapping-resource.json create mode 100644 components/core/load/model_type/artifact_type/artifact-script-python.json create mode 100644 components/core/load/model_type/artifact_type/artifact-template-velocity.json create mode 100644 components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json create mode 100644 components/core/load/model_type/data_type/datatype-property.json create mode 100644 components/core/load/model_type/data_type/datatype-resource-assignment.json create mode 100644 components/core/load/model_type/data_type/dt-license-key.json create mode 100644 components/core/load/model_type/data_type/dt-v4-aggregate.json create mode 100644 components/core/load/model_type/data_type/tosca.datatypes.Credential.json create mode 100644 components/core/load/model_type/node_type/artifact-config-template.json create mode 100644 components/core/load/model_type/node_type/component-config-generator.json create mode 100644 components/core/load/model_type/node_type/component-netconf-executor.json create mode 100644 components/core/load/model_type/node_type/component-resource-assignment.json create mode 100644 components/core/load/model_type/node_type/dg-activate-netconf.json create mode 100644 components/core/load/model_type/node_type/dg-config-generator.json create mode 100644 components/core/load/model_type/node_type/dg-resource-assign-activate.json create mode 100644 components/core/load/model_type/node_type/dg-resource-assignment.json create mode 100644 components/core/load/model_type/node_type/vnf-netconf-device.json create mode 100644 components/core/pom.xml create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt create mode 100644 components/core/src/test/resources/componentnode/default.json create mode 100644 components/core/src/test/resources/data/alltype-data.json create mode 100644 components/core/src/test/resources/data/default-context.json create mode 100644 components/core/src/test/resources/dictionary/dictionary_schema.json create mode 100644 components/core/src/test/resources/properties/convert.json create mode 100644 components/core/src/test/resources/properties/default.json create mode 100644 components/parent/pom.xml create mode 100644 components/pom.xml create mode 100644 components/resource-dict/load/model_type/node_type/source-component-java.json create mode 100644 components/resource-dict/load/model_type/node_type/source-db.json create mode 100644 components/resource-dict/load/model_type/node_type/source-default.json create mode 100644 components/resource-dict/load/model_type/node_type/source-input.json create mode 100644 components/resource-dict/load/model_type/node_type/source-rest.json create mode 100644 components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json create mode 100644 components/resource-dict/load/resource_dictionary/db-source.json create mode 100644 components/resource-dict/load/resource_dictionary/default-source.json create mode 100644 components/resource-dict/load/resource_dictionary/input-source.json create mode 100644 components/resource-dict/load/resource_dictionary/mdsal-source.json create mode 100644 components/resource-dict/pom.xml create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java create mode 100644 components/resource-dict/src/test/resources/data/resource-assignment-input.json create mode 100644 components/resource-dict/src/test/resources/enrich/simple-enrich.json create mode 100644 components/resource-dict/src/test/resources/validation/cyclic.json create mode 100644 components/resource-dict/src/test/resources/validation/duplicate.json create mode 100644 components/resource-dict/src/test/resources/validation/success.json diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json new file mode 100644 index 000000000..635e177a1 --- /dev/null +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -0,0 +1,411 @@ +{ + "metadata": { + "template_author": "Brinda Santh Muthuramalingam", + "author-email": "brindasanth@gmail.com", + "user-groups" : "ADMIN, OPERATION", + "template_name": "baseconfiguration", + "template_version": "1.0.0", + "template_tags": "brinda, tosca" + }, + "topology_template": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "node_templates": { + "activate-process": { + "type": "bpmn-activate", + "properties": { + "process-name": { "get_input" : "action-name" }, + "version" : { "get_property" : ["SELF", "process-name"] }, + "content": { "get_artifact" : ["SELF", "activate-process"] } + }, + "artifacts": { + "activate-process": { + "type": "artifact-bpmn-camunda", + "file": "Plans/ActivateProcess.bpmn" + } + } + }, + "resource-assignment": { + "type": "component-resource-assignment", + "properties":{ + "request-id": ["1234", "1234"] + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { "get_input" : "action-name" }, + "resource-type": "vnf-type", + "request-id": { "get_input" : "request-id" }, + "resource-id": { "get_input" : "hostname" }, + "template-content": { "get_artifact" : ["SELF", "baseconfig-template"] }, + "mapping-content": { "get_artifact" : ["SELF", "baseconfig-mapping"] } + }, + "outputs": { + "resource-assignment-params": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "baseconfig-template": { + "type": "artifact-template-velocity", + "file": "Templates/baseconfig-template.vtl" + }, + "baseconfig-mapping": { + "type": "artifact-mapping-resource", + "file": "Mappings/baseconfig-mapping.json" + } + } + }, + "resource-assignment-py": { + "type": "component-resource-assignment", + "properties":{ + "request-id": ["1234", "1234"] + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "implementation" :{ + "primary" : "component-script" + }, + "inputs": { + "action-name": { "get_input" : "action-name" } + }, + "outputs": { + "resource-assignment-params": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/baseconfig-template.vtl" + } + } + } + }, + "workflows":{ + "activate-process":{ + "steps" : { + "call-resource-assignment" : { + "description" : "Invoke Resource Assignment Component", + "target" : "resource-assignment", + "activities" : [ + { + "call_operation": "ResourceAssignmentNode.process" + } + ], + "on_success" : [ + "download-baseconfig" + ] + }, + "download-baseconfig" : { + "description" : "Call Download Base Config Component", + "target" : "activate-netconf", + "activities" : [ + { + "call_operation": "NetconfTransactionNode.process" + } + ], + "on_success" : [ + "download-licence" + ] + }, + "download-licence" : { + "description" : "Call Download Licence Component", + "target" : "activate-netconf", + "activities" : [ + { + "call_operation": "NetconfTransactionNode.process" + } + ] + } + } + } + } + }, + "artifact_types": { + "artifact-template-velocity": { + "description": " Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-mapping-resource": { + "description": " Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-kotlin": { + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "kt" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-python": { + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-bpmn-camunda": { + "description": " Camunda BPM File", + "version": "1.0.0", + "file_ext": [ + "bpmn" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-component-jar": { + "description": "Component Jar", + "version": "1.0.0", + "file_ext": [ + "jar" + ], + "derived_from": "tosca.artifacts.Implementation" + } + }, + "node_types": { + "bpmn-activate": { + "description": "This is BPMN Activate node type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default" : "LATEST" + } + }, + "derived_from": "tosca.nodes.Component" + }, + "tosca.nodes.Component": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "type": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": false, + "type": "string" + } + }, + "interfaces": { + "DefaultOperation": { + "operations": { + "validate": { + "inputs": { + "action-name": { + "description": "validate for action", + "required": false, + "type": "string" + } + } + } + } + } + }, + "artifacts" :{ + "component-jar": { + "description": "Component Jar", + "type": "artifact-component-jar", + "file": "Component/basecomponent.jar" + } + }, + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Python": { + "description": "This is Resource Assignment Python Component API", + "version": "1.0.0", + "properties": { + "type": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": false, + "type": "string" + } + }, + "interfaces": { + "DefaultOperation": { + "operations": { + "validate": { + "inputs": { + "action-name": { + "description": "validate for action", + "required": false, + "type": "string" + } + } + } + } + } + }, + "artifacts" :{ + "component-jar": { + "description": "Component Jar", + "type": "artifact-component-jar", + "file": "Component/basecomponent.jar" + } + }, + "derived_from": "tosca.nodes.Root" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "template-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "mapping-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-resource-assignment-python": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.component.Python" + } + }, + "data_types": { + "sample-property" : { + "description": "This is sample data type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default" : "LATEST" + } + }, + "derived_from" : "tosca.datatypes.Root" + } + } +} \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json b/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json new file mode 100644 index 000000000..6abfb51bd --- /dev/null +++ b/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json @@ -0,0 +1,3 @@ +{ + "assignments": "Sample Assignments" +} \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn b/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn new file mode 100644 index 000000000..5e94c0f8e --- /dev/null +++ b/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn @@ -0,0 +1,66 @@ + + + + + SequenceFlow_0l0dq58 + + + SequenceFlow_1ay0k6p + + + + + + + + + + SequenceFlow_0l0dq58 + SequenceFlow_1ay0k6p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py new file mode 100644 index 000000000..eb198c79a --- /dev/null +++ b/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py @@ -0,0 +1,8 @@ +from com.brvith.orchestrator.core.interfaces import ComponentNode + +class SamplePythonComponentNode(ComponentNode): + def prepare(self, context, componentContext): + return None + + def prepare(self, context, componentContext): + return None \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/Scripts/__init__.py b/components/core/load/blueprints/baseconfiguration/Scripts/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..fb38c1594 --- /dev/null +++ b/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Brinda Santh M +Entry-Definitions: Definitions/activation-blueprint.json +Template-Tags: Brinda Santh, activation-blueprint + +Name: Plans/ActivateProcess.bpmn +Content-Type: application/vnd.oasis.bpmn diff --git a/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl b/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl new file mode 100644 index 000000000..026c59176 --- /dev/null +++ b/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl @@ -0,0 +1 @@ +This is Sample Velocity Template \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/__init__.py b/components/core/load/blueprints/baseconfiguration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json b/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json new file mode 100644 index 000000000..6d469ea84 --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json @@ -0,0 +1,34 @@ +{ + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "type": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": false, + "type": "string" + } + }, + "interfaces": { + "DefaultOperation": { + "operations": { + "validate": { + "inputs": { + "action-name": { + "description": "validate for action", + "required": false, + "type": "string" + } + } + } + } + } + }, + "artifacts" :{ + "component-jar": { + "description": "Component Jar", + "type": "artifact-component-jar", + "file": "Component/basecomponent.jar" + } + }, + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json new file mode 100644 index 000000000..e78f32f02 --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json @@ -0,0 +1,345 @@ +{ + "metadata": { + "template_author": "Brinda Santh", + "template_name": "simple-baseconfig", + "template_version": "1.0.0", + "service-type": "Sample Service", + "release": "1806", + "vnf-type": "VPE" + }, + "topology_template": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "service-instance-id": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "node_templates": { + "vpe-netconf-device": { + "capabilities": { + "netconf": { + "properties": { + "login-key": "sdnc", + "login-account": "sndc-local", + "source": "local", + "target-ip-address": "{\"get_attribute\":\"lo0-local-ipv4-address\"}", + "port-number": 22, + "connection-time-out": 30 + } + } + }, + "type": "vnf-netconf-device" + }, + "activate-netconf-component": { + "capabilities": { + "component-node": {} + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "vpe-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { + "operations": { + "process": { + "inputs": { + "action-name": "{ \"get_input\" : \"action-name\" }", + "service-template-name": "{ \"get_attribute\" : \"template_name\" }", + "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }", + "resource-type": "vnf-type", + "request-id": "{ \"get_input\" : \"request-id\" }", + "resource-id": "{ \"get_input\" : \"hostname\" }", + "execution-script": "execution-script" + }, + "outputs": { + "response-data": "{ \"get_attribute\" : \"netconf-executor-baseconfig.response-data\" }", + "status": "{ \"get_attribute\" : \"netconf-executor-baseconfig.status\" }" + }, + "implementation" : { + "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py" + } + } + } + } + }, + "type": "component-netconf-executor" + }, + "resource-assignment-ra-component": { + "capabilities": { + "component-node": {} + }, + "interfaces": { + "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": { + "operations": { + "process": { + "inputs": { + "template-names": [ + "base-config-template", + "licence-template" + ], + "action-name": "{ \"get_input\" : \"action-name\" }", + "service-template-name": "{ \"get_attribute\" : \"template_name\" }", + "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }", + "resource-type": "vnf-type", + "request-id": "{ \"get_input\" : \"request-id\" }", + "resource-id": "{ \"get_input\" : \"hostname\" }" + }, + "outputs": { + "resource-assignment-params": "success", + "status": "status" + } + } + } + } + }, + "type": "component-resource-assignment" + }, + "resource-assignment-action": { + "properties": { + "mode": "sync", + "version": "LATEST", + "is-start-flow": "false" + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "resource-assignment-ra-component", + "relationship": "tosca.relationships.DependsOn" + } + }, + "capabilities": { + "dg-node": {}, + "content": { + "properties": { + "type": "json" + } + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignment": { + "inputs": { + "params": [] + } + } + } + } + }, + "type": "dg-resource-assignment" + }, + "activate-action": { + "properties": { + "mode": "sync", + "version": "LATEST", + "is-start-flow": "false" + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "activate-netconf-component", + "relationship": "tosca.relationships.DependsOn" + } + }, + "capabilities": { + "dg-node": {}, + "content": { + "properties": { + "type": "json" + } + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ActivateNetconf": { + "inputs": { + "params": [] + } + } + } + } + }, + "type": "dg-activate-netconf" + }, + "base-config-template": { + "capabilities": { + "content": { + "properties": { + "content": "db://base-config-template" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "bundle-mac", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "bundle-mac", + "dictionary-source": "db", + "dependencies": [ + "hostname" + ], + "version": 0 + }, + { + "name": "wan-aggregate-ipv4-addresses", + "property": { + "description": "", + "required": true, + "type": "list", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-v4-aggregate" + } + }, + "input-param": false, + "dictionary-name": "wan-aggregate-ipv4-addresses", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "oam-network-role", + "oam-v4-ip-type ", + "oam-vm-type" + ], + "version": 0 + }, + { + "name": "hostname", + "property": { + "required": true, + "type": "string" + }, + "dictionary-name": "hostname", + "dictionary-source": "input", + "version": 0, + "input-param": false + }, + { + "name": "service", + "property": { + "required": true, + "type": "string" + }, + "dictionary-name": "service", + "dictionary-source": "input", + "version": 0, + "input-param": false + }, + { + "name": "service-instance-id", + "property": { + "required": true, + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "version": 0, + "input-param": false + } + ] + } + } + }, + "properties": { + "action-names": [ + "resource-assignment-action" + ] + }, + "type": "artifact-config-template" + }, + "licence-template": { + "capabilities": { + "content": { + "properties": { + "content": "db://licence-template" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "licenses", + "property": { + "description": "", + "required": true, + "type": "list", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-license-key" + } + }, + "input-param": false, + "dictionary-name": "licenses", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id" + ], + "version": 0 + }, + { + "name": "service-instance-id", + "property": { + "required": true, + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "version": 0, + "input-param": false + } + ] + } + } + }, + "properties": { + "action-names": [ + "resource-assignment-action" + ] + }, + "type": "artifact-config-template" + } + } + }, + "node_types": { + }, + "data_types": { + } +} \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json b/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json new file mode 100644 index 000000000..6abfb51bd --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json @@ -0,0 +1,3 @@ +{ + "assignments": "Sample Assignments" +} \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn b/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn new file mode 100644 index 000000000..5e94c0f8e --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn @@ -0,0 +1,66 @@ + + + + + SequenceFlow_0l0dq58 + + + SequenceFlow_1ay0k6p + + + + + + + + + + SequenceFlow_0l0dq58 + SequenceFlow_1ay0k6p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py b/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py new file mode 100644 index 000000000..eb198c79a --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py @@ -0,0 +1,8 @@ +from com.brvith.orchestrator.core.interfaces import ComponentNode + +class SamplePythonComponentNode(ComponentNode): + def prepare(self, context, componentContext): + return None + + def prepare(self, context, componentContext): + return None \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py b/components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta b/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..d7ae5e8a2 --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Brinda Santh M +Entry-Definitions: Definitions/simple-baseconfig.json +Template-Tags: vrr-test, Brinda Santh + +Name: Plans/ActivateProcess.bpmn +Content-Type: application/vnd.oasis.bpmn diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl new file mode 100644 index 000000000..92dba1024 --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl @@ -0,0 +1,40 @@ + + + + ${group-name} + + + <*> + + + + + + 224.0.1.40/32 + + + 224.0.1.39/32 + + + 224.0.0.0/4 + + + + + + + + + + <*> + + 1000 + + + + + + + + + \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl new file mode 100644 index 000000000..026c59176 --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl @@ -0,0 +1 @@ +This is Sample Velocity Template \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl new file mode 100644 index 000000000..626974f27 --- /dev/null +++ b/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl @@ -0,0 +1,4 @@ + + + + diff --git a/components/core/load/blueprints/simple-baseconfig/__init__.py b/components/core/load/blueprints/simple-baseconfig/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json new file mode 100644 index 000000000..ac76b4f4f --- /dev/null +++ b/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json @@ -0,0 +1,8 @@ +{ + "description": " Camunda BPM File", + "version": "1.0.0", + "file_ext": [ + "bpmn" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-directed-graph.json b/components/core/load/model_type/artifact_type/artifact-directed-graph.json new file mode 100644 index 000000000..7ab3a5434 --- /dev/null +++ b/components/core/load/model_type/artifact_type/artifact-directed-graph.json @@ -0,0 +1,9 @@ +{ + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-mapping-resource.json b/components/core/load/model_type/artifact_type/artifact-mapping-resource.json new file mode 100644 index 000000000..0a3261b09 --- /dev/null +++ b/components/core/load/model_type/artifact_type/artifact-mapping-resource.json @@ -0,0 +1,8 @@ +{ + "description": " Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-script-python.json b/components/core/load/model_type/artifact_type/artifact-script-python.json new file mode 100644 index 000000000..b48d2b628 --- /dev/null +++ b/components/core/load/model_type/artifact_type/artifact-script-python.json @@ -0,0 +1,8 @@ +{ + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-template-velocity.json b/components/core/load/model_type/artifact_type/artifact-template-velocity.json new file mode 100644 index 000000000..9395d3970 --- /dev/null +++ b/components/core/load/model_type/artifact_type/artifact-template-velocity.json @@ -0,0 +1,8 @@ +{ + "description": " Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json b/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json new file mode 100644 index 000000000..5a7c95684 --- /dev/null +++ b/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json @@ -0,0 +1,5 @@ +{ + "description": "TOSCA base type for implementation artifacts", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/datatype-property.json b/components/core/load/model_type/data_type/datatype-property.json new file mode 100644 index 000000000..5584b10ea --- /dev/null +++ b/components/core/load/model_type/data_type/datatype-property.json @@ -0,0 +1,27 @@ +{ + "version": "1.0.0", + "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", + "properties": { + "type": { + "required": true, + "type": "string" + }, + "description": { + "required": false, + "type": "string" + }, + "required": { + "required": false, + "type": "boolean" + }, + "default": { + "required": false, + "type": "string" + }, + "entry_schema": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/datatype-resource-assignment.json b/components/core/load/model_type/data_type/datatype-resource-assignment.json new file mode 100644 index 000000000..cc9816ebb --- /dev/null +++ b/components/core/load/model_type/data_type/datatype-resource-assignment.json @@ -0,0 +1,46 @@ +{ + "version": "1.0.0", + "description": "This is Resource Assignment Data Type", + "properties": { + "property": { + "required": true, + "type": "datatype-property" + }, + "input-param": { + "required": true, + "type": "boolean" + }, + "dictionary-name": { + "required": false, + "type": "string" + }, + "dictionary-source": { + "required": false, + "type": "string" + }, + "dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "status": { + "required": false, + "type": "string" + }, + "message": { + "required": false, + "type": "string" + }, + "updated-date": { + "required": false, + "type": "string" + }, + "updated-by": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/dt-license-key.json b/components/core/load/model_type/data_type/dt-license-key.json new file mode 100644 index 000000000..e9c312b79 --- /dev/null +++ b/components/core/load/model_type/data_type/dt-license-key.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0", + "description": "This is dt-plicense-key Data Type", + "properties": { + "license-key": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/dt-v4-aggregate.json b/components/core/load/model_type/data_type/dt-v4-aggregate.json new file mode 100644 index 000000000..842a7f805 --- /dev/null +++ b/components/core/load/model_type/data_type/dt-v4-aggregate.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0", + "description": "This is dt-v4-aggregate Data Type", + "properties": { + "ipv4-address": { + "required": true, + "type": "string" + }, + "ipv4-plen": { + "required": false, + "type": "integer" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/tosca.datatypes.Credential.json b/components/core/load/model_type/data_type/tosca.datatypes.Credential.json new file mode 100644 index 000000000..820a55168 --- /dev/null +++ b/components/core/load/model_type/data_type/tosca.datatypes.Credential.json @@ -0,0 +1,31 @@ +{ + "version": "1.0.0", + "description": "Credential", + "properties": { + "protocol": { + "required": false, + "type": "string" + }, + "token_type": { + "required": true, + "type": "string", + "default" : "password" + }, + "token": { + "required": false, + "type": "string" + }, + "keys": { + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "user": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/artifact-config-template.json b/components/core/load/model_type/node_type/artifact-config-template.json new file mode 100644 index 000000000..be9bbfc0e --- /dev/null +++ b/components/core/load/model_type/node_type/artifact-config-template.json @@ -0,0 +1,37 @@ +{ + "description": "This is Configuration Velocity Template", + "version": "1.0.0", + "properties": { + "action-names": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "capabilities": { + "content": { + "type": "tosca.capability.Content", + "properties": { + "content": { + "required": true, + "type": "string" + } + } + }, + "mapping": { + "type": "tosca.capability.Mapping", + "properties": { + "mapping": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-resource-assignment" + } + } + } + } + }, + "derived_from": "tosca.nodes.Artifact" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/component-config-generator.json b/components/core/load/model_type/node_type/component-config-generator.json new file mode 100644 index 000000000..764f9e890 --- /dev/null +++ b/components/core/load/model_type/node_type/component-config-generator.json @@ -0,0 +1,72 @@ +{ + "description": "This is Generate Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": { + "operations": { + "process": { + "inputs": { + "template-data": { + "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", + "required": false, + "type": "string" + }, + "template-content": { + "description": "Conditional : Dynamic Template used to generate Configuration.", + "required": false, + "type": "string" + }, + "resource-type": { + "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", + "required": false, + "type": "string" + }, + "action-name": { + "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "template-name": { + "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", + "required": true, + "type": "string" + } + }, + "outputs": { + "generated-config": { + "description": "Generated Configuration for the Template adn Resource Data", + "required": true, + "type": "string" + }, + "mask-info": { + "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.apps.controllerblueprints.core.data.custom.MaskInfo ", + "required": false, + "type": "string" + }, + "status": { + "description": "Status of the Component Execution ( success or failure )", + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/component-netconf-executor.json b/components/core/load/model_type/node_type/component-netconf-executor.json new file mode 100644 index 000000000..aed667aaf --- /dev/null +++ b/components/core/load/model_type/node_type/component-netconf-executor.json @@ -0,0 +1,79 @@ +{ + "description": "This is Netconf Transaction Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "vnf-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { + "operations": { + "process": { + "inputs": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "service-template-name": { + "description": "Service Template Name", + "required": true, + "type": "string" + }, + "service-template-version": { + "description": "Service Template Version", + "required": true, + "type": "string" + }, + "action-name": { + "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-id": { + "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "reservation-id": { + "description": "Reservation Id used to send to NPM", + "required": false, + "type": "string" + }, + "execution-script": { + "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.", + "required": true, + "type": "string" + } + }, + "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" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json new file mode 100644 index 000000000..34c028482 --- /dev/null +++ b/components/core/load/model_type/node_type/component-resource-assignment.json @@ -0,0 +1,68 @@ +{ + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": { + "operations": { + "process": { + "inputs": { + "service-template-name": { + "description": "Service Template Name.", + "required": true, + "type": "string" + }, + "service-template-version": { + "description": "Service Template Version.", + "required": true, + "type": "string" + }, + "resource-type": { + "description": "Request type.", + "required": true, + "type": "string" + }, + "template-names": { + "description": "Name of the artifact Node Templates, to get the template Content.", + "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": true, + "type": "string" + }, + "action-name": { + "description": "Action Name of the process", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-activate-netconf.json b/components/core/load/model_type/node_type/dg-activate-netconf.json new file mode 100644 index 000000000..c638df00c --- /dev/null +++ b/components/core/load/model_type/node_type/dg-activate-netconf.json @@ -0,0 +1,66 @@ +{ + "description": "This is Download Netconf Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": "false" + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + }, + "content": { + "type": "tosca.capability.Content", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "json" + }, + "content": { + "required": true, + "type": "string" + } + } + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-netconf-executor", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ActivateNetconf": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-config-generator.json b/components/core/load/model_type/node_type/dg-config-generator.json new file mode 100644 index 000000000..28bace0f0 --- /dev/null +++ b/components/core/load/model_type/node_type/dg-config-generator.json @@ -0,0 +1,65 @@ +{ + "description": "This is Activate DG for Config Generator Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": "false" + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + }, + "content": { + "type": "tosca.capability.Content", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "json" + }, + "content": { + "required": true, + "type": "string" + } + } + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-config-generator", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "GenerateConfiguration": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-resource-assign-activate.json b/components/core/load/model_type/node_type/dg-resource-assign-activate.json new file mode 100644 index 000000000..e98fa5a67 --- /dev/null +++ b/components/core/load/model_type/node_type/dg-resource-assign-activate.json @@ -0,0 +1,70 @@ +{ + "description": "This is Resource Assign and Activate Netconf Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": "false" + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + }, + "content": { + "type": "tosca.capability.Content", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "json" + }, + "content": { + "required": false, + "type": "string" + } + } + } + }, + "requirements": { + "ra-component": { + "capability": "component-node", + "node": "component-resource-assignment", + "relationship": "tosca.relationships.DependsOn" + }, + "netconf-component": { + "capability": "component-node", + "node": "component-netconf-executor", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignAndActivate": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-resource-assignment.json b/components/core/load/model_type/node_type/dg-resource-assignment.json new file mode 100644 index 000000000..36fbb6861 --- /dev/null +++ b/components/core/load/model_type/node_type/dg-resource-assignment.json @@ -0,0 +1,65 @@ +{ + "description": "This is Resource Assignment Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": "false" + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + }, + "content": { + "type": "tosca.capability.Content", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "json" + }, + "content": { + "required": false, + "type": "string" + } + } + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-resource-assignment", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignment": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/vnf-netconf-device.json b/components/core/load/model_type/node_type/vnf-netconf-device.json new file mode 100644 index 000000000..54573bade --- /dev/null +++ b/components/core/load/model_type/node_type/vnf-netconf-device.json @@ -0,0 +1,42 @@ +{ + "description": "This is VNF Device with Netconf Capability", + "version": "1.0.0", + "capabilities": { + "netconf": { + "type": "tosca.capability.Netconf", + "properties": { + "login-key": { + "required": true, + "type": "string", + "default": "sdnc" + }, + "login-account": { + "required": true, + "type": "string", + "default": "sdnc-tacacs" + }, + "source": { + "required": true, + "type": "string", + "default": "npm" + }, + "target-ip-address": { + "required": true, + "type": "string" + }, + "port-number": { + "required": true, + "type": "integer", + "default": 830 + }, + "connection-time-out": { + "required": false, + "type": "integer", + "default": 30 + } + } + } + }, + "derived_from": "tosca.nodes.Vnf" + +} diff --git a/components/core/pom.xml b/components/core/pom.xml new file mode 100644 index 000000000..fc6624e72 --- /dev/null +++ b/components/core/pom.xml @@ -0,0 +1,68 @@ + + + + + 4.0.0 + + org.onap.ccsdk.apps.components + parent + 0.3.0-SNAPSHOT + ../parent + + org.onap.ccsdk.apps.controllerblueprints + core + Controller Blueprints Core + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.module + jackson-module-jsonSchema + + + io.projectreactor + reactor-core + + + org.yaml + snakeyaml + + + org.jetbrains.kotlin + kotlin-test + test + + + junit + junit + + + + + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt new file mode 100644 index 000000000..4ae1f4d5d --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -0,0 +1,142 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core +/** + * BluePrintConstants + * + * @author Brinda Santh + */ +object BluePrintConstants { + + const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" + const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" + const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + + const val TYPE_DEFAULT: String = "default" + + const val DATA_TYPE_STRING: String = "string" + const val DATA_TYPE_INTEGER: String = "integer" + const val DATA_TYPE_FLOAT: String = "float" + const val DATA_TYPE_BOOLEAN: String = "boolean" + const val DATA_TYPE_TIMESTAMP: String = "timestamp" + const val DATA_TYPE_NULL: String = "null" + const val DATA_TYPE_LIST: String = "list" + const val DATA_TYPE_MAP: String = "map" + + const val USER_SYSTEM: String = "System" + + const val MODEL_CONTENT_TYPE_JSON: String = "JSON" + const val MODEL_CONTENT_TYPE_YAML: String = "YAML" + const val MODEL_CONTENT_TYPE_YANG: String = "YANG" + const val MODEL_CONTENT_TYPE_SCHEMA: String = "SCHEMA" + + const val PATH_DIVIDER: String = "/" + const val PATH_INPUTS: String = "inputs" + const val PATH_NODE_WORKFLOWS: String = "workflows" + const val PATH_NODE_TEMPLATES: String = "node_templates" + const val PATH_CAPABILITIES: String = "capabilities" + const val PATH_REQUIREMENTS: String = "requirements" + const val PATH_INTERFACES: String = "interfaces" + const val PATH_OPERATIONS: String = "operations" + const val PATH_OUTPUTS: String = "outputs" + const val PATH_PROPERTIES: String = "properties" + const val PATH_ATTRIBUTES: String = "attributes" + const val PATH_ARTIFACTS: String = "artifacts" + + const val MODEL_DIR_MODEL_TYPE: String = "model_type" + + const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" + const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" + const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" + const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" + const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" + + const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" + const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" + const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" + const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" + const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" + const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" + const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" + + const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" + const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" + const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" + const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" + const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" + + const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" + const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" + const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" + @Deprecated("Artifacts will be attached to Node Template") + const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" + const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" + + const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" + const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" + const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" + const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" + const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" + + const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" + + const val EXPRESSION_GET_INPUT: String = "get_input" + const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" + const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" + const val EXPRESSION_GET_PROPERTY: String = "get_property" + const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" + const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" + + const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" + const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" + const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" + const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" + const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" + const val PROPERTY_BLUEPRINT_NAME: String = "template_name" + const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" + + const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" + const val TOSCA_PLANS_DIR: String = "Plans" + const val TOSCA_SCRIPTS_DIR: String = "Scripts" + const val TOSCA_MAPPINGS_DIR: String = "Mappings" + const val TOSCA_TEMPLATES_DIR: String = "Templates" + + const val METADATA_USER_GROUPS = "user-groups" + const val METADATA_TEMPLATE_NAME = "template_name" + const val METADATA_TEMPLATE_VERSION = "template_version" + const val METADATA_TEMPLATE_AUTHOR = "template_author" + const val METADATA_TEMPLATE_TAGS = "template_tags" + + const val PAYLOAD_CONTENT = "payload-content" + const val PAYLOAD_DATA = "payload-data" + const val SELECTOR = "selector" + const val PROPERTY_CURRENT_INTERFACE = "current-interface" + const val PROPERTY_CURRENT_OPERATION = "current-operation" + const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" + + const val PROPERTY_ACTION_NAME = "action" + + const val OPERATION_PROCESS = "process" + const val OPERATION_PREPARE = "prepare" + + const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" + const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" + const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt new file mode 100644 index 000000000..5c386c214 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt @@ -0,0 +1,49 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core +/** + * + * + * @author Brinda Santh + */ +class BluePrintException : Exception { + + var code: Int = 100 + + constructor(cause: Throwable) : super(cause) + constructor(message: String) : super(message) + constructor(message: String, cause: Throwable) : super(message, cause) + constructor(cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause) + + constructor(code: Int, cause: Throwable) : super(cause) { + this.code = code + } + + constructor(code: Int, message: String) : super(message) { + this.code = code + } + + constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { + this.code = code + } + + constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) + : super(String.format(message, *args), cause) { + this.code = code + } +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt new file mode 100644 index 000000000..50717031d --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt @@ -0,0 +1,49 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core +/** + * + * + * @author Brinda Santh + */ +class BluePrintProcessorException : Exception { + var code: Int = 100 + + constructor(message: String, cause: Throwable) : super(message, cause) + constructor(message: String) : super(message) + constructor(cause: Throwable) : super(cause) + constructor(cause: Throwable, message: String, vararg args: Any?) : super(format(message, *args), cause) + + constructor(code: Int, cause: Throwable) : super(cause) { + this.code = code + } + + constructor(code: Int, message: String) : super(message) { + this.code = code + } + + constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { + this.code = code + } + + constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) + : super(String.format(message, *args), cause) { + this.code = code + } +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt new file mode 100644 index 000000000..33c811f4a --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -0,0 +1,91 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +/** + * + * + * @author Brinda Santh + */ +object BluePrintTypes { + + @JvmStatic + fun validModelTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + return validTypes + } + + @JvmStatic + fun validPropertyTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_STRING) + validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) + validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) + validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) + validTypes.add(BluePrintConstants.DATA_TYPE_NULL) + validTypes.add(BluePrintConstants.DATA_TYPE_LIST) + return validTypes + } + + @JvmStatic + fun validPrimitiveTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_STRING) + validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) + validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) + validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) + validTypes.add(BluePrintConstants.DATA_TYPE_NULL) + return validTypes + } + + @JvmStatic + fun validCollectionTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_LIST) + validTypes.add(BluePrintConstants.DATA_TYPE_MAP) + return validTypes + } + + @JvmStatic + fun validCommands(): List { + return listOf(BluePrintConstants.EXPRESSION_GET_INPUT, + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE, + BluePrintConstants.EXPRESSION_GET_PROPERTY, + BluePrintConstants.EXPRESSION_GET_ARTIFACT, + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT, + BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE) + } + + @JvmStatic + fun rootNodeTypes(): List { + return listOf(BluePrintConstants.MODEL_TYPE_NODES_ROOT) + } + + @JvmStatic + fun rootDataTypes(): List { + return listOf(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT) + } + + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt new file mode 100644 index 000000000..845922040 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +/** + * + * + * @author Brinda Santh + */ +object ConfigModelConstant { + + const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON" + const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE" + + const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" + + const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" + + const val MODEL_TYPE_CAPABILITY_NETCONF = "tosca.capability.Netconf" + const val MODEL_TYPE_CAPABILITY_SSH = "tosca.capability.Ssh" + const val MODEL_TYPE_CAPABILITY_SFTP = "tosca.capability.Sftp" + const val MODEL_TYPE_CAPABILITY_CHEF = "tosca.capability.Chef" + const val MODEL_TYPE_CAPABILITY_ANSIBLEF = "tosca.capability.Ansible" + + const val CAPABILITY_PROPERTY_MAPPING = "mapping" + + const val PROPERTY_RECIPE_NAMES = "action-names" + +} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt new file mode 100644 index 000000000..7302f2b96 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -0,0 +1,75 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +import org.slf4j.helpers.MessageFormatter +import java.io.File +import java.io.InputStream +import kotlin.reflect.KClass + +/** + * + * + * @author Brinda Santh + */ + +fun format(message: String, vararg args: Any?) : String{ + if(args != null && args.isNotEmpty()){ + return MessageFormatter.arrayFormat(message, args).message + } + return message +} + +fun MutableMap.getCastOptionalValue(key: String, valueType: KClass): T? { + if (containsKey(key)) { + return get(key) as? T + } else { + return null + } +} + +fun MutableMap.getCastValue(key: String, valueType: KClass): T { + if (containsKey(key)) { + return get(key) as T + } else { + throw BluePrintException("couldn't find the key " + key) + } +} + +fun checkNotEmpty(value : String?) : Boolean{ + return value != null && value.isNotEmpty() +} + +fun checkNotEmptyNThrow(value : String?, message : String? = value.plus(" is null/empty ")) : Boolean{ + val notEmpty = value != null && value.isNotEmpty() + if(!notEmpty){ + throw BluePrintException(message!!) + } + return notEmpty +} + +fun InputStream.toFile(path: String) : File { + val file = File(path) + file.outputStream().use { this.copyTo(it) } + return file +} + + + + + + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt new file mode 100644 index 000000000..c0eb13f92 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt @@ -0,0 +1,70 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.data + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ObjectNode +/** + * + * + * @author Brinda Santh + */ +data class ExpressionData( + var isExpression: Boolean = false, + var valueNode: JsonNode, + var expressionNode: ObjectNode? = null, + var inputExpression: InputExpression? = null, + var propertyExpression: PropertyExpression? = null, + var attributeExpression: AttributeExpression? = null, + var artifactExpression: ArtifactExpression? = null, + var operationOutputExpression: OperationOutputExpression? = null, + var command: String? = null +) + +data class InputExpression( + var propertyName: String +) + +data class PropertyExpression( + var modelableEntityName: String = "SELF", + var reqOrCapEntityName: String? = null, + var propertyName: String, + var subPropertyName: String? = null +) + +data class AttributeExpression( + var modelableEntityName: String = "SELF", + var reqOrCapEntityName: String? = null, + var attributeName: String, + var subAttributeName: String? = null +) + +data class ArtifactExpression( + val modelableEntityName: String = "SELF", + val artifactName: String, + val location: String? = "LOCAL_FILE", + val remove: Boolean? = false +) + +data class OperationOutputExpression( + val modelableEntityName: String = "SELF", + val interfaceName: String, + val operationName: String, + val propertyName: String +) + + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt new file mode 100644 index 000000000..ef8bbf2d6 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -0,0 +1,612 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.data + +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.JsonNode +import io.swagger.annotations.ApiModelProperty + +/** + * + * + * @author Brinda Santh + */ +open class EntityType { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var version: String = "1.0.0" + var metadata: MutableMap? = null + @get:JsonProperty("derived_from") + lateinit var derivedFrom: String + var attributes: MutableMap? = null + var properties: MutableMap? = null +} + +/* + 5.3.2 tosca.datatypes.Credential + The Credential type is a complex TOSCA data Type used when describing + authorization credentials used to access network accessible resources. + */ +class Credential { + @get:JsonIgnore + var id: String? = null + var protocol: String? = null + @get:JsonProperty("token_type") + lateinit var tokenType: String + lateinit var token: String + var keys: MutableMap? = null + lateinit var user: String +} + +/* +3.5.2 Constraint clause +A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities. + */ +class ConstraintClause { + @get:JsonProperty("equal") + var equal: JsonNode? = null + @get:JsonProperty("greater_than") + var greaterThan: Any? = null + @get:JsonProperty("greater_or_equal") + var greaterOrEqual: Any? = null + @get:JsonProperty("less_than") + var lessThan: Any? = null + @get:JsonProperty("less_or_equal") + var lessOrEqual: Any? = null + @get:JsonProperty("in_range") + var inRange: Any? = null + @get:JsonProperty("valid_values") + var validValues: MutableList? = null + @get:JsonProperty("length") + var length: Any? = null + @get:JsonProperty("min_length") + var minLength: Any? = null + @get:JsonProperty("max_length") + var maxLength: Any? = null + var pattern: String? = null + var schema: String? = null +} + +/* +3.5.4 Node Filter definition +A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties. + */ + +class NodeFilterDefinition { + var properties: MutableMap? = null + var capabilities : MutableList? = null +} + +/* +3.5.5 Repository definition + A repository definition defines a named external repository which contains deployment + and implementation artifacts that are referenced within the TOSCA Service Template. +*/ +class RepositoryDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + lateinit var url: String + var credential: Credential? = null +} + + +/* +3.5.6 Artifact definition +An artifact definition defines a named, typed file that can be associated with Node Type +or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations. + */ +class ArtifactDefinition { + @get:JsonIgnore + var id: String? = null + var type: String? = null + var file: String? = null + var repository: String? = null + var description: String? = null + @get:JsonProperty("deploy_Path") + var deployPath: String? = null + var properties: MutableMap? = null + var content: String? = null + @Deprecated("Mapping content is define by the Type") + var mappingContent: String? = null +} + + +/* +3.5.7 Import definition +An import definition is used within a TOSCA Service Template to locate and uniquely name +another TOSCA Service Template file which has type and template definitions to be imported (included) +and referenced within another Service Template. + */ +class ImportDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var file: String + var repository: String? = null + @get:JsonProperty("namespace_uri") + var namespaceUri: String? = null + @get:JsonProperty("namespace_prefix") + var namespacePrefix: String? = null +} + +/* +3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an +entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.). +Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are +instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates. + */ +class PropertyDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var required: Boolean? = null + lateinit var type: String + @get:JsonProperty("default") + var defaultValue: JsonNode? = null + var status: String? = null + var constraints: MutableList? = null + @get:JsonProperty("entry_schema") + var entrySchema: EntrySchema? = null + @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values") + var value: JsonNode? = null +} + + +/* +3.5.10 Attribute definition + +An attribute definition defines a named, typed value that can be associated with an entity defined in this +specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the +“actual state” of some property of a TOSCA entity after it has been deployed and instantiated +(as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function +from the instance model and used as values to other entities within TOSCA Service Templates. + */ + +class AttributeDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + lateinit var type: String + @JsonProperty("default") + var defaultValue: JsonNode? = null + var status: String? = null + @JsonProperty("entry_schema") + var entrySchema: String? = null +} + +/* +3.5.13 Operation definition +An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script). + */ +class OperationDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var implementation: Implementation? = null + var inputs: MutableMap? = null + var outputs: MutableMap? = null +} + +class Implementation { + lateinit var primary: String + var dependencies: MutableList? = null +} + +/* +3.5.14 Interface definition +An interface definition defines a named interface that can be associated with a Node or Relationship Type + */ +class InterfaceDefinition { + @get:JsonIgnore + var id: String? = null + var type: String? = null + var operations: MutableMap? = null + var inputs: MutableMap? = null +} + +/* +3.5.15 Event Filter definition +An event filter definition defines criteria for selection of an attribute, for the purpose of monitoring it, within a TOSCA entity, or one its capabilities. + */ +class EventFilterDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var node: String + var requirement: String? = null + var capability: String? = null +} + +/* +3.5.16 Trigger definition TODO +A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with. + */ +class TriggerDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + @get:JsonProperty("event_type") + lateinit var eventType: String + @get:JsonProperty("target_filter") + var targetFilter: EventFilterDefinition? = null + var condition: ConditionClause? = null + var constraint: ConditionClause? = null + var method: String? = null + lateinit var action: String +} + +/* + 3.5.17 Workflow activity definition + A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to: + · Delegate the workflow for a node expected to be provided by the orchestrator + · Set the state of a node + · Call an operation defined on a TOSCA interface of a node, relationship or group + · Inline another workflow defined in the topology (to allow reusability) + */ +class Activity { + var delegate: String? = null + @get:JsonProperty("set_state") + var setState: String? = null + @get:JsonProperty("call_operation") + var callOperation: String? = null + var inlines: ArrayList? = null +} + +/* +3.5.20 Workflow precondition definition +A workflow condition can be used as a filter or precondition to check if a workflow can be processed or not based on the state of the instances of a TOSCA topology deployment. When not met, the workflow will not be triggered. + */ +class PreConditionDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var target: String + @get:JsonProperty("target_relationship") + lateinit var targetRelationship: String + lateinit var condition: ArrayList +} + +/* +3.5.21 Workflow step definition +A workflow step allows to define one or multiple sequenced activities in a workflow and how they are connected to other steps in the workflow. They are the building blocks of a declarative workflow. + */ +class Step { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var target: String? = null + @JsonProperty("target_relationship") + var targetRelationship: String? = null + @JsonProperty("operation_host") + var operationHost: String? = null + var activities: ArrayList? = null + @get:JsonProperty("on_success") + var onSuccess: ArrayList? = null + @get:JsonProperty("on_failure") + var onFailure: ArrayList? = null +} + +/* +3.6.2 Capability definition +A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes. + */ + +class CapabilityDefinition { + @get:JsonIgnore + var id: String? = null + var type: String? = null + var description: String? = null + var properties: MutableMap? = null + @get:JsonProperty("valid_source_types") + var validSourceTypes: MutableList? = null + var occurrences: MutableList? = null +} + +/* +3.6.3 Requirement definition +The Requirement definition describes a named requirement (dependencies) of a TOSCA Node Type or Node template which needs to be fulfilled by a matching Capability definition declared by another TOSCA modelable entity. The requirement definition may itself include the specific name of the fulfilling entity (explicitly) or provide an abstract type, along with additional filtering characteristics, that a TOSCA orchestrator can use to fulfill the capability at runtime (implicitly). + */ +class RequirementDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var capability: String? = null + var node: String? = null + var relationship: String? = null + var occurrences: MutableList? = null +} + +/* +3.6.4 Artifact Type +An Artifact Type is a reusable entity that defines the type of one or more files that are used to define implementation or deployment artifacts that are referenced by nodes or relationships on their operations. + */ +class ArtifactType : EntityType() { + @get:JsonProperty("mime_type") + var mimeType: String? = null + @get:JsonProperty("file_ext") + var fileExt: MutableList? = null + +} + +/* +3.6.6 Data Type +A Data Type definition defines the schema for new named datatypes in TOSCA. + */ + +class DataType : EntityType(){ + var constraints: MutableList? = null +} + +/* +3.6.9 Node Type +A Node Type is a reusable entity that defines the type of one or more Node Templates. As such, a Node Type defines the structure of observable properties via a Properties Definition, the Requirements and Capabilities of the node as well as its supported interfaces. + + */ + +class NodeType : EntityType() { + var capabilities: MutableMap? = null + var requirements: MutableMap? = null + var interfaces: MutableMap? = null + var artifacts: MutableMap? = null +} + +/* +3.6.8 Requirement Type +A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose. The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types along with a named Feature notation. + */ + +class RequirementType : EntityType() { + var requirements: MutableMap? = null + var capabilities: MutableMap? = null + var interfaces: MutableMap? = null + var artifacts: MutableMap? = null +} + +/* +3.6.10 Relationship Type +A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates. +*/ + +class RelationshipType : EntityType() { + var interfaces: MutableMap? = null + @get:JsonProperty("valid_target_types") + var validTargetTypes: ArrayList? = null +} + +/* +3.6.11 Group Type +A Group Type defines logical grouping types for nodes, typically for different management purposes. +Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology + of an application, yet can have capabilities and the ability to attach policies and interfaces + that can be applied (depending on the group type) to its member nodes. + */ + +class GroupType : EntityType() { + var members: MutableList? = null + var requirements: ArrayList? = null + var capabilities: MutableMap? = null + var interfaces: MutableMap? = null + +} + +/* + 3.6.12 Policy Type + A Policy Type defines a type of requirement that affects or governs an application or service’s + topology at some stage of its lifecycle, but is not explicitly part of the topology itself + (i.e., it does not prevent the application or service from being deployed or run if it did not exist). + */ +class PolicyType : EntityType(){ + lateinit var targets: MutableList +} + +/* +3.7.1 Capability assignment +A capability assignment allows node template authors to assign values to properties and attributes for a named capability definition that is part of a Node Template’s type definition. + */ +class CapabilityAssignment { + @get:JsonIgnore + var id: String? = null + var attributes: MutableMap? = null + var properties: MutableMap? = null +} + +/* +3.7.4 Relationship Template +A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations. + */ +class GroupDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var type: String + var description: String? = null + var metadata : MutableMap? = null + var properties : MutableMap? = null + var members = ArrayList() + var interfaces : MutableMap?= null +} + +/* +3.7.6 Policy definition +A policy definition defines a policy that can be associated with a TOSCA topology or top-level entity definition (e.g., group definition, node template, etc.). + */ +class PolicyDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var type: String + var description: String? = null + var metadata: MutableMap? = null + var properties: MutableMap? = null + var targets: MutableList? = null +} + + +/* +3.8 Topology Template definition +This section defines the topology template of a cloud application. The main ingredients of the topology template are node templates representing components of the application and relationship templates representing links between the components. These elements are defined in the nested node_templates section and the nested relationship_templates sections, respectively. Furthermore, a topology template allows for defining input parameters, output parameters as well as grouping of node templates. + */ +class TopologyTemplate { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var inputs: MutableMap? = null + @get:JsonProperty("node_templates") + var nodeTemplates: MutableMap? = null + @get:JsonProperty("relationship_templates") + var relationshipTemplates: MutableMap? = null + var policies: MutableMap? = null + var outputs: MutableMap? = null + @get:JsonProperty("substitution_mappings") + var substitutionMappings: Any? = null + var workflows: MutableMap? = null +} + +class SubstitutionMapping { + @get:JsonProperty("node_type") + lateinit var nodeType: String + lateinit var capabilities: ArrayList + lateinit var requirements: ArrayList +} + +class EntrySchema { + lateinit var type: String + var constraints: MutableList? = null +} + +class InterfaceAssignment { + @get:JsonIgnore + var id: String? = null + var operations: MutableMap? = null + var inputs: MutableMap? = null +} + +/* +3.7.3 Node Template +A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations. + */ + +class NodeTemplate { + @get:JsonIgnore + var id: String? = null + var description: String? = null + lateinit var type: String + var metadata: MutableMap? = null + var directives: MutableList? = null + //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class) + var properties: MutableMap? = null + var attributes: MutableMap? = null + var capabilities: MutableMap? = null + var requirements: MutableMap? = null + var interfaces: MutableMap? = null + var artifacts: MutableMap? = null + @get:JsonProperty("node_filter") + var nodeFilter: NodeFilterDefinition? = null + var copy: String? = null +} + +class OperationAssignment { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var implementation: Implementation? = null + var inputs: MutableMap? = null + var outputs: MutableMap? = null +} + +/* +3.7.4 Relationship Template +A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations. + */ + +class RelationshipTemplate { + var type: String? = null + var description: String? = null + var metadata: MutableMap? = null + var properties: MutableMap? = null + var attributes: MutableMap? = null + var interfaces: MutableMap? = null + var copy: String? = null +} + +/* +3.7.2 Requirement assignment +A Requirement assignment allows template authors to provide either concrete names of TOSCA templates or provide abstract selection criteria for providers to use to find matching TOSCA templates that are used to fulfill a named requirement’s declared TOSCA Node Type. + */ + +class RequirementAssignment { + @get:JsonIgnore + var id: String? = null + var capability: String? = null + var node: String? = null + //Relationship Type or Relationship Template + var relationship: String? = null +} + + +class Workflow { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var steps: MutableMap? = null + var preconditions: ArrayList? = null + var inputs: MutableMap? = null +} + + +class ConditionClause { + var and: ArrayList>? = null + var or: ArrayList>? = null + @get:JsonProperty("assert") + var assertConditions: ArrayList>? = null +} + +/* +3.9 Service Template definition +A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document. + */ + +class ServiceTemplate { + @get:JsonIgnore + var id: String? = null + @get:JsonProperty("tosca_definitions_version") + var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0" + var metadata: MutableMap? = null + var description: String? = null + @get:JsonProperty("dsl_definitions") + var dslDefinitions: MutableMap? = null + var repositories: MutableMap? = null + var imports: MutableList? = null + @get:JsonProperty("artifact_types") + var artifactTypes: MutableMap? = null + @get:JsonProperty("data_types") + var dataTypes: MutableMap? = null + @get:JsonProperty("node_types") + var nodeTypes: MutableMap? = null + @get:JsonProperty("policy_types") + var policyTypes: PolicyType? = null + @get:JsonProperty("topology_template") + var topologyTemplate: TopologyTemplate? = null +} + +class ToscaMetaData { + lateinit var toscaMetaFileVersion: String + lateinit var csarVersion: String + lateinit var createdBy: String + lateinit var entityDefinitions: String + var templateTags: String? = null +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt new file mode 100644 index 000000000..d796597be --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt @@ -0,0 +1,45 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.factory + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager + + +/** + * BluePrintEnhancerFactory + * @author Brinda Santh + * + */ + +object BluePrintEnhancerFactory { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + var bluePrintEnhancerServices: MutableMap = HashMap() + + fun register(key: String, bluePrintEnhancerService: BluePrintEnhancerService) { + bluePrintEnhancerServices[key] = bluePrintEnhancerService + } + + /** + * Called by clients to get a Blueprint Parser for the Blueprint parser type + */ + fun instance(key: String): BluePrintEnhancerService? { + return bluePrintEnhancerServices.get(key) + } +} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt new file mode 100644 index 000000000..83233abc1 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt @@ -0,0 +1,51 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.factory + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintParserDefaultService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintParserService +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager + +/** + * + * BluePrintParserFactory + * @author Brinda Santh + */ + +object BluePrintParserFactory { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + var bluePrintParserServices: MutableMap = HashMap() + + init { + log.info("Initialised default BluePrintParser Service ") + bluePrintParserServices.put(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT, BluePrintParserDefaultService()) + } + + fun register(key:String, bluePrintParserService: BluePrintParserService){ + bluePrintParserServices.put(key, bluePrintParserService) + } + + /** + * Called by clients to get a Blueprint Parser for the Blueprint parser type + */ + fun instance(key : String) : BluePrintParserService? { + return bluePrintParserServices.get(key) + } +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt new file mode 100644 index 000000000..63f788a2f --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt @@ -0,0 +1,45 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.factory + + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorService + +/** + * + * + * @author Brinda Santh + */ + +object BluePrintValidatorFactory { + + var bluePrintValidatorServices: MutableMap = HashMap() + + init { + bluePrintValidatorServices[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT] = BluePrintValidatorDefaultService() + } + + fun register(key:String, bluePrintValidatorService: BluePrintValidatorService){ + bluePrintValidatorServices[key] = bluePrintValidatorService + } + + fun instance(key : String) : BluePrintValidatorService?{ + return bluePrintValidatorServices[key] + } + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt new file mode 100644 index 000000000..065176342 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt @@ -0,0 +1,117 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +/** + * + * + * @author Brinda Santh + */ +class BluePrintChainedService { + var bpc : BluePrintContext + + constructor(bpc : BluePrintContext){ + this.bpc = bpc + } + + fun nodeTypeChained(nodeTypeName: String): NodeType { + + val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) + val attributes = hashMapOf() + val properties = hashMapOf() + val requirements = hashMapOf() + val capabilities = hashMapOf() + val interfaces = hashMapOf() + val artifacts = hashMapOf() + + recNodeTypesChained(nodeTypeName).forEach { nodeType -> + + val subAttributes = bpc.nodeTypeByName(nodeType.id!!).attributes + if (subAttributes != null) { + attributes.putAll(subAttributes) + } + + val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties + if (subProperties != null) { + properties.putAll(subProperties) + } + + val subRequirements = bpc.nodeTypeByName(nodeType.id!!).requirements + if (subRequirements != null) { + requirements.putAll(subRequirements) + } + val subCapabilities = bpc.nodeTypeByName(nodeType.id!!).capabilities + if (subCapabilities != null) { + capabilities.putAll(subCapabilities) + } + val subInterfaces = bpc.nodeTypeByName(nodeType.id!!).interfaces + if (subInterfaces != null) { + interfaces.putAll(subInterfaces) + } + + val subArtifacts = bpc.nodeTypeByName(nodeType.id!!).artifacts + if (subArtifacts != null) { + artifacts.putAll(subArtifacts) + } + } + nodeType.attributes = attributes + nodeType.properties = properties + nodeType.requirements = requirements + nodeType.capabilities = capabilities + nodeType.interfaces = interfaces + nodeType.artifacts = artifacts + return nodeType + } + + fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap? { + val nodeType = bpc.nodeTypeByName(nodeTypeName) + val properties = hashMapOf() + + recNodeTypesChained(nodeTypeName).forEach { nodeType -> + val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties + if (subProperties != null) { + properties.putAll(subProperties) + } + } + return properties + } + + private fun recNodeTypesChained(nodeTypeName: String, nodeTypes: MutableList? = arrayListOf()): MutableList { + val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) + nodeType.id = nodeTypeName + val derivedFrom: String = nodeType.derivedFrom + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + recNodeTypesChained(derivedFrom, nodeTypes) + } + nodeTypes!!.add(nodeType) + return nodeTypes + } + + private fun recDataTypesChained(dataTypeName: String, dataTypes: MutableList? = arrayListOf()): MutableList { + val dataType: DataType = bpc.dataTypeByName(dataTypeName)!! + dataType.id = dataTypeName + val derivedFrom: String = dataType.derivedFrom + if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) { + recDataTypesChained(derivedFrom, dataTypes) + } + dataTypes!!.add(dataType) + return dataTypes + } + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt new file mode 100644 index 000000000..875cbea61 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -0,0 +1,177 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +/** + * + * + * @author Brinda Santh + */ +class BluePrintContext(serviceTemplate: ServiceTemplate) { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + val serviceTemplate: ServiceTemplate = serviceTemplate + + val imports: List? = serviceTemplate.imports + + val metadata: MutableMap? = serviceTemplate.metadata + + val dataTypes: MutableMap? = serviceTemplate.dataTypes + + val inputs: MutableMap? = serviceTemplate.topologyTemplate?.inputs + + val workflows: MutableMap? = serviceTemplate.topologyTemplate?.workflows + + fun blueprintJson(pretty: Boolean = false): String = print("json", pretty) + + fun blueprintYaml(pretty: Boolean = false): String = print("yaml", pretty) + + private fun print(type: String? = "json", pretty: Boolean = false): String { + return JacksonUtils.getJson(serviceTemplate, pretty) + } + + // Workflow + fun workflowByName(name: String): Workflow? = workflows?.get(name) + + // Data Type + fun dataTypeByName(name: String): DataType? = dataTypes?.get(name) + + // Artifact Type + val artifactTypes: MutableMap? = serviceTemplate.artifactTypes + + // Node Type Methods + val nodeTypes: MutableMap? = serviceTemplate.nodeTypes + + fun nodeTypeByName(name: String): NodeType = + nodeTypes?.get(name) ?: throw BluePrintException(String.format("Failed to get node type for the name : %s", name)) + + fun nodeTypeDerivedFrom(name: String): MutableMap? { + return nodeTypes?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap() + } + + fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition? { + return nodeTypeByName(nodeTypeName).interfaces?.values?.first() + } + + fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition? { + return nodeTypeInterface(nodeTypeName, interfaceName)?.operations?.get(operationName) + } + + fun interfaceNameForNodeType(nodeTypeName: String): String? { + return nodeTypeByName(nodeTypeName).interfaces?.keys?.first() + } + + fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.inputs + } + + fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.outputs + } + + // Node Template Methods + val nodeTemplates: MutableMap? = serviceTemplate.topologyTemplate?.nodeTemplates + + fun nodeTemplateByName(name: String): NodeTemplate = + nodeTemplates?.get(name) ?: throw BluePrintException("Failed to get node template for the name " + name) + + fun nodeTemplateForNodeType(name: String): MutableMap? { + return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() + } + + fun nodeTemplateNodeType(nodeTemplateName: String): NodeType { + val nodeTemplateType: String = nodeTemplateByName(nodeTemplateName).type + return nodeTypeByName(nodeTemplateType) + } + + fun nodeTemplateProperty(nodeTemplateName: String, propertyName: String): Any? { + return nodeTemplateByName(nodeTemplateName).properties?.get(propertyName) + } + + fun nodeTemplateArtifacts(nodeTemplateName: String): MutableMap? { + return nodeTemplateByName(nodeTemplateName).artifacts + } + + fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition? { + return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName) + } + + fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment? { + return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first() + } + + fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String? { + return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first() + } + + fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String? { + return nodeTemplateFirstInterface(nodeTemplateName)?.operations?.keys?.first() + } + + fun nodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.inputs + } + + fun nodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.outputs + } + + fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment? { + return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName) + } + + + fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment? { + return nodeTemplateInterface(nodeTemplateName, interfaceName)?.operations?.get(operationName) + } + + fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment? { + return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName) + } + + fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment? { + return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName) + } + + fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate { + val nodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node + ?: throw BluePrintException(String.format("failed to get node name for node template's (%s) requirement's (%s) " + nodeTemplateName, requirementName)) + return nodeTemplateByName(nodeTemplateName) + } + + fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? { + return nodeTemplateCapability(nodeTemplateName, capabilityName)?.properties?.get(propertyName) + } + + // Chained Functions + + fun nodeTypeChained(nodeTypeName: String): NodeType { + return BluePrintChainedService(this).nodeTypeChained(nodeTypeName) + } + + fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap? { + return BluePrintChainedService(this).nodeTypeChainedProperties(nodeTypeName) + } + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt new file mode 100644 index 000000000..f38c317e7 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt @@ -0,0 +1,259 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.format +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import java.io.Serializable + +/** + * BluePrintEnhancerService + * @author Brinda Santh + * + */ +interface BluePrintEnhancerService : Serializable { + + @Throws(BluePrintException::class) + fun enhance(content: String): ServiceTemplate + + /** + * Read Blueprint from CSAR structure Directory + */ + @Throws(BluePrintException::class) + fun enhance(fileName: String, basePath: String): ServiceTemplate + + @Throws(BluePrintException::class) + fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate + + @Throws(BluePrintException::class) + fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) + + @Throws(BluePrintException::class) + fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) + + @Throws(BluePrintException::class) + fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) +} + +open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString()) + + lateinit var serviceTemplate: ServiceTemplate + + @Throws(BluePrintException::class) + override fun enhance(content: String): ServiceTemplate { + return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate -> + enhance(serviceTemplate!!) + }.block()!! + } + + @Throws(BluePrintException::class) + override fun enhance(fileName: String, basePath: String): ServiceTemplate { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + @Throws(BluePrintException::class) + override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate { + this.serviceTemplate = serviceTemplate + initialCleanUp() + enrichTopologyTemplate(serviceTemplate) + + // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true)) + return this.serviceTemplate + } + + open fun initialCleanUp() { + serviceTemplate.artifactTypes?.clear() + serviceTemplate.nodeTypes?.clear() + serviceTemplate.dataTypes?.clear() + + serviceTemplate.artifactTypes = HashMap() + serviceTemplate.nodeTypes = HashMap() + serviceTemplate.dataTypes = HashMap() + + } + + @Throws(BluePrintException::class) + open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) { + serviceTemplate.topologyTemplate?.let { topologyTemplate -> + enrichTopologyTemplateInputs(topologyTemplate) + enrichTopologyTemplateNodeTemplates(topologyTemplate) + } + } + + @Throws(BluePrintException::class) + open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) { + topologyTemplate.inputs?.let { inputs -> + enrichPropertyDefinitions(inputs) + } + } + + open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) { + topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate -> + enrichNodeTemplate(nodeTemplateName, nodeTemplate) + } + } + + @Throws(BluePrintException::class) + override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val nodeTypeName = nodeTemplate.type + // Get NodeType from Repo and Update Service Template + val nodeType = populateNodeType(nodeTypeName) + + // Enrich NodeType + enrichNodeType(nodeTypeName, nodeType) + + //Enrich Node Template Artifacts + enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate) + } + + @Throws(BluePrintException::class) + override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) { + + // NodeType Property Definitions + enrichNodeTypeProperties(nodeTypeName, nodeType) + + //NodeType Requirement + enrichNodeTypeRequirements(nodeTypeName, nodeType) + + //NodeType Capability + enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType) + + //NodeType Interface + enrichNodeTypeInterfaces(nodeTypeName, nodeType) + } + + open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) { + nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) } + } + + open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) { + + nodeType.requirements?.forEach { _, requirementDefinition -> + // Populate Requirement Node + requirementDefinition.node?.let { requirementNodeTypeName -> + // Get Requirement NodeType from Repo and Update Service Template + val requirementNodeType = populateNodeType(requirementNodeTypeName) + + enrichNodeType(requirementNodeTypeName, requirementNodeType) + } + } + } + + open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) { + nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition -> + capabilityDefinition.properties?.let { properties -> + enrichPropertyDefinitions(properties) + } + } + } + + open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) { + nodeType.interfaces?.forEach { interfaceName, interfaceObj -> + // Populate Node type Interface Operation + log.info("*** ** Enriching NodeType: {} Interface {}", nodeTypeName, interfaceName) + populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj) + + } + } + + open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) { + + interfaceObj.operations?.forEach { operationName, operation -> + enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation) + enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation) + } + } + + open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) { + operation.inputs?.let { inputs -> + enrichPropertyDefinitions(inputs) + } + } + + open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) { + operation.outputs?.let { inputs -> + enrichPropertyDefinitions(inputs) + } + } + + open fun enrichPropertyDefinitions(properties: MutableMap) { + + properties.forEach { propertyName, propertyDefinition -> + enrichPropertyDefinition(propertyName, propertyDefinition) + } + } + + @Throws(BluePrintException::class) + override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) { + val propertyType = propertyDefinition.type + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + val entrySchema = propertyDefinition.entrySchema + ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName)) + + if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) { + populateDataTypes(entrySchema.type) + } + } else { + populateDataTypes(propertyType) + } + + } + + open fun enrichNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition -> + val artifactTypeName = artifactDefinition.type + ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName)) + + // Populate Artifact Type + populateArtifactType(artifactTypeName) + } + } + + open fun populateNodeType(nodeTypeName: String): NodeType { + val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)?.block() + ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName)) + serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType) + return nodeType + } + + open fun populateArtifactType(artifactTypeName: String): ArtifactType { + val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)?.block() + ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName)) + serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType) + return artifactType + } + + open fun populateDataTypes(dataTypeName: String): DataType { + val dataType = bluePrintRepoService.getDataType(dataTypeName)?.block() + ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName)) + serviceTemplate.dataTypes?.put(dataTypeName, dataType) + return dataType + } + +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt new file mode 100644 index 000000000..19d515e0e --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -0,0 +1,176 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ArrayNode +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +/** + * + * + * @author Brinda Santh + */ +object BluePrintExpressionService { + val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun getExpressionData(propertyAssignment: Any): ExpressionData { + val propertyAssignmentNode: JsonNode = JacksonUtils.jsonNodeFromObject(propertyAssignment) + return getExpressionData(propertyAssignmentNode) + } + + @JvmStatic + fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData { + log.trace("Assignment Data/Expression : {}", propertyAssignmentNode) + val expressionData = ExpressionData(valueNode = propertyAssignmentNode) + if (propertyAssignmentNode is ObjectNode) { + + val commands: Set = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands()) + if (commands.isNotEmpty()) { + expressionData.isExpression = true + expressionData.command = commands.first() + expressionData.expressionNode = propertyAssignmentNode + + when (expressionData.command) { + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT -> { + expressionData.inputExpression = populateInputExpression(propertyAssignmentNode) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { + expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY -> { + expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { + expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode) + } + } + } + } + return expressionData + } + + @JvmStatic + fun populateInputExpression(jsonNode: JsonNode): InputExpression { + return InputExpression(propertyName = jsonNode.first().textValue()) + } + + @JvmStatic + fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + check(arrayNode.size() >= 2) { + throw BluePrintException(String.format("missing property expression, " + + "it should be [ , , , " + + ", ..., ] , but present {}", jsonNode)) + } + var reqOrCapEntityName: String? = null + var propertyName = "" + var subProperty: String? = null + when { + arrayNode.size() == 2 -> propertyName = arrayNode[1].textValue() + arrayNode.size() == 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + propertyName = arrayNode[2].textValue() + } + arrayNode.size() > 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + propertyName = arrayNode[2].textValue() + val propertyPaths: List = arrayNode.filterIndexed { index, obj -> + index >= 3 + }.map { it.textValue() } + subProperty = propertyPaths.joinToString("/") + } + } + + return PropertyExpression(modelableEntityName = arrayNode[0].asText(), + reqOrCapEntityName = reqOrCapEntityName, + propertyName = propertyName, + subPropertyName = subProperty + ) + } + + @JvmStatic + fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + check(arrayNode.size() >= 3) { + throw BluePrintException(String.format("missing attribute expression, " + + "it should be [ , , ," + + " , ..., ] , but present {}", jsonNode)) + } + + var reqOrCapEntityName: String? = null + var propertyName = "" + var subProperty: String? = null + if (arrayNode.size() == 2) { + propertyName = arrayNode[1].textValue() + } else if (arrayNode.size() == 3) { + reqOrCapEntityName = arrayNode[1].textValue() + propertyName = arrayNode[2].textValue() + } else if (arrayNode.size() > 3) { + reqOrCapEntityName = arrayNode[1].textValue() + propertyName = arrayNode[2].textValue() + val propertyPaths: List = arrayNode.filterIndexed { index, obj -> + index >= 3 + }.map { it.textValue() } + subProperty = propertyPaths.joinToString("/") + } + return AttributeExpression(modelableEntityName = arrayNode[0].asText(), + reqOrCapEntityName = reqOrCapEntityName, + attributeName = propertyName, + subAttributeName = subProperty + ) + } + + @JvmStatic + fun populateOperationOutputExpression(jsonNode: JsonNode): OperationOutputExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + + check(arrayNode.size() >= 4) { + throw BluePrintException(String.format("missing operation output expression, " + + "it should be (, , , ) , but present {}", jsonNode)) + } + return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(), + interfaceName = arrayNode[1].asText(), + operationName = arrayNode[2].asText(), + propertyName = arrayNode[3].asText() + ) + } + + @JvmStatic + fun populateArtifactExpression(jsonNode: JsonNode): ArtifactExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + + check(arrayNode.size() >= 2) { + throw BluePrintException(String.format("missing artifact expression, " + + "it should be [ , , , ] , but present {}", jsonNode)) + } + return ArtifactExpression(modelableEntityName = arrayNode[0].asText(), + artifactName = arrayNode[1].asText(), + location = arrayNode[2]?.asText() ?: "LOCAL_FILE", + remove = arrayNode[3]?.asBoolean() ?: false + ) + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt new file mode 100644 index 000000000..43267ff1b --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt @@ -0,0 +1,62 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.File +import java.io.Serializable + +/** + * + * + * @author Brinda Santh + */ +interface BluePrintParserService : Serializable { + fun readBlueprint(content: String) : BluePrintContext + fun readBlueprintFile(fileName: String) : BluePrintContext + /** + * Read Blueprint from CSAR structure Directory + */ + fun readBlueprintFile(fileName: String, basePath : String) : BluePrintContext +} + +class BluePrintParserDefaultService : BluePrintParserService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + var basePath : String = javaClass.classLoader.getResource(".").path + + override fun readBlueprint(content: String): BluePrintContext { + return BluePrintContext(ServiceTemplateUtils.getServiceTemplateFromContent(content)) + } + + override fun readBlueprintFile(fileName: String): BluePrintContext { + return readBlueprintFile(fileName, basePath ) + } + + override fun readBlueprintFile(fileName: String, basePath : String): BluePrintContext { + val rootFilePath: String = StringBuilder().append(basePath).append(File.separator).append(fileName).toString() + val rootServiceTemplate : ServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + // TODO("Nested Lookup Implementation based on Import files") + return BluePrintContext(rootServiceTemplate) + } + + +} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt new file mode 100644 index 000000000..a7c14adfe --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt @@ -0,0 +1,98 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import reactor.core.publisher.Mono +import java.io.Serializable + +/** + * BluePrintRepoFileService + * @author Brinda Santh + * + */ + +interface BluePrintRepoService : Serializable { + + @Throws(BluePrintException::class) + fun getNodeType(nodeTypeName: String): Mono? + + @Throws(BluePrintException::class) + fun getDataType(dataTypeName: String): Mono? + + @Throws(BluePrintException::class) + fun getArtifactType(artifactTypeName: String): Mono? + + @Throws(BluePrintException::class) + fun getRelationshipType(relationshipTypeName: String): Mono? + + @Throws(BluePrintException::class) + fun getCapabilityDefinition(capabilityDefinitionName: String): Mono? + +} + + +open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) + + private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + private val extension = ".json" + + override fun getDataType(dataTypeName: String): Mono? { + val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(dataTypeName).plus(extension) + return getModelType(fileName, DataType::class.java) + } + + override fun getNodeType(nodeTypeName: String): Mono? { + val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) + return getModelType(fileName, NodeType::class.java) + } + + override fun getArtifactType(artifactTypeName: String): Mono? { + val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(artifactTypeName).plus(extension) + return getModelType(fileName, ArtifactType::class.java) + } + + override fun getRelationshipType(relationshipTypeName: String): Mono? { + val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(relationshipTypeName).plus(extension) + return getModelType(fileName, RelationshipType::class.java) + } + + override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono? { + val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(capabilityDefinitionName).plus(extension) + return getModelType(fileName, CapabilityDefinition::class.java) + } + + private fun getModelType(fileName: String, valueType: Class): Mono { + return JacksonReactorUtils.readValueFromFile(fileName, valueType) + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt new file mode 100644 index 000000000..ce0bceeea --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -0,0 +1,278 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +/** + * + * + * @author Brinda Santh + */ +open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var context: MutableMap = hashMapOf()) { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString()) + + /* + Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing + */ + open fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { + log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) + val propertyAssignmentValue: MutableMap = hashMapOf() + + val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + val propertyAssignments: MutableMap = + nodeTemplate.properties as MutableMap + + // Get the Node Type Definitions + val nodeTypeProperties: MutableMap = + bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!! + + // Iterate Node Type Properties + nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty -> + // Get the Express or Value for the Node Template + val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + + var resolvedValue: JsonNode = NullNode.getInstance() + if (propertyAssignment != null) { + // Resolve the Expressing + val propertyAssignmentExpression = PropertyAssignmentService(context, this) + resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) + } else { + // Assign default value to the Operation + nodeTypeProperty.defaultValue?.let { defaultValue -> + resolvedValue = defaultValue + } + } + // Set for Return of method + propertyAssignmentValue[nodeTypePropertyName] = resolvedValue + } + log.info("resolved property definition for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue) + return propertyAssignmentValue + } + + open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, + interfaceName: String, operationName: String): MutableMap { + log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " + + "operationName({})", nodeTemplateName, interfaceName, operationName) + + val propertyAssignmentValue: MutableMap = hashMapOf() + + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap + ?: throw BluePrintException(String.format("failed to get input definitions for node template (%s), " + + "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName)) + + val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type + + val nodeTypeInterfaceOperationInputs: MutableMap = + bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName) + ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " + + "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName)) + + log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments) + + // Iterate Node Type Properties + nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty -> + // Get the Express or Value for the Node Template + val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + + var resolvedValue: JsonNode = NullNode.getInstance() + if (propertyAssignment != null) { + // Resolve the Expressing + val propertyAssignmentExpression = PropertyAssignmentService(context, this) + resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) + } else { + // Assign default value to the Operation + nodeTypeProperty.defaultValue?.let { + resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) + } + } + // Set for Return of method + propertyAssignmentValue[nodeTypePropertyName] = resolvedValue + } + log.info("resolved input assignments for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue) + + return propertyAssignmentValue + } + + + open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, + interfaceName: String, operationName: String, componentContext: MutableMap) { + log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " + + "operationName({})", nodeTemplateName, interfaceName, operationName) + + val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type + + val nodeTypeInterfaceOperationOutputs: MutableMap = + bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName) + ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " + + "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName)) + + // Iterate Node Type Properties + nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty -> + + val operationOutputPropertyName: String = StringBuilder().append(nodeTemplateName) + .append(".").append(interfaceName) + .append(".").append(operationName) + .append(".").append(nodeTypePropertyName).toString() + // Get the Value from component context + val resolvedValue: JsonNode = componentContext[operationOutputPropertyName] as? JsonNode + ?: NullNode.getInstance() + // Store operation output values into context + setNodeTemplateOperationPropertyValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue) + log.debug("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue) + } + } + + open fun resolveNodeTemplateArtifact(nodeTemplateName: String, + artifactName: String): String { + val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName) + ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template" + , artifactName)) + val propertyAssignmentExpression = PropertyAssignmentService(context, this) + return propertyAssignmentExpression.artifactContent(artifactDefinition) + } + + + open fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { + val path = StringBuilder(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + log.trace("setting input path ({}), values ({})", path, value) + context[path] = value + } + + open fun setWorkflowInputValue(workflowName: String, propertyName: String, value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS).append(BluePrintConstants.PATH_DIVIDER).append(workflowName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + context[path] = value + } + + open fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { + + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + context[path] = value + } + + open fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + log.trace("setting operation property path ({}), values ({})", path, value) + context[path] = value + } + + open fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + context[path] = value + } + + open fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + context[path] = value + } + + + open fun getInputValue(propertyName: String): JsonNode { + val path = StringBuilder(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return context[path] as? JsonNode ?: NullNode.instance + } + + open fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return context[path] as JsonNode + } + + open fun getPropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return context[path] as JsonNode + } + + open fun getRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return context[path] as JsonNode + } + + open fun getCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return context[path] as JsonNode + } + + open fun assignInputs(jsonNode: JsonNode) { + log.info("assignInputs from input JSON ({})", jsonNode.toString()) + bluePrintContext.inputs?.forEach { propertyName, property -> + val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setInputValue(propertyName, property, valueNode) + } + } + + open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { + log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString()) + bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, property -> + val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setWorkflowInputValue(workflowName, propertyName, valueNode) + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt new file mode 100644 index 000000000..34399fdd2 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -0,0 +1,360 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.fasterxml.jackson.databind.JsonNode +import com.google.common.base.Preconditions +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.* +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.Serializable + +/** + * + * + * @author Brinda Santh + */ +interface BluePrintValidatorService : Serializable { + + @Throws(BluePrintException::class) + fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) + + @Throws(BluePrintException::class) + fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap) +} + +open class BluePrintValidatorDefaultService : BluePrintValidatorService { + + val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString()) + + lateinit var bluePrintContext: BluePrintContext + lateinit var serviceTemplate: ServiceTemplate + lateinit var properties: MutableMap + var message: StringBuilder = StringBuilder() + private val separator: String = BluePrintConstants.PATH_DIVIDER + var paths: MutableList = arrayListOf() + + @Throws(BluePrintException::class) + override fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) { + validateBlueprint(bluePrintContext.serviceTemplate,properties) + } + + @Throws(BluePrintException::class) + override fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap) { + this.bluePrintContext = BluePrintContext(serviceTemplate) + this.serviceTemplate = serviceTemplate + this.properties = properties + try { + message.appendln("-> Config Blueprint") + serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } + serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) } + serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } + serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } + serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } + } catch (e: Exception) { + log.error("validation failed in the path : {}", paths.joinToString(separator), e) + log.error("validation trace message :{} ", message) + throw BluePrintException(e, + format("failed to validate blueprint on path ({}) with message {}" + , paths.joinToString(separator), e.message)) + } + } + + @Throws(BluePrintException::class) + open fun validateMetadata(metaDataMap: MutableMap) { + paths.add("metadata") + + val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] + val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] + val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] + val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] + + Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateArtifactTypes(artifactTypes: MutableMap) { + paths.add("artifact_types") + artifactTypes.forEach { artifactName, artifactType -> + paths.add(artifactName) + message.appendln("--> Artifact Type :" + paths.joinToString(separator)) + artifactType.properties?.let { validatePropertyDefinitions(artifactType.properties!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateDataTypes(dataTypes: MutableMap) { + paths.add("dataTypes") + dataTypes.forEach { dataTypeName, dataType -> + paths.add(dataTypeName) + message.appendln("--> Data Type :" + paths.joinToString(separator)) + dataType.properties?.let { validatePropertyDefinitions(dataType.properties!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeTypes(nodeTypes: MutableMap) { + paths.add("nodeTypes") + nodeTypes.forEach { nodeTypeName, nodeType -> + // Validate Single Node Type + validateNodeType(nodeTypeName,nodeType) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeType(nodeTypeName: String, nodeType: NodeType) { + paths.add(nodeTypeName) + message.appendln("--> Node Type :" + paths.joinToString(separator)) + val derivedFrom: String = nodeType.derivedFrom + //Check Derived From + checkValidNodeTypesDerivedFrom(derivedFrom) + + nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) } + nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { + paths.add("topology") + message.appendln("--> Topology Template") + topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } + topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) } + topologyTemplate.workflows?.let { validateWorkFlows(topologyTemplate.workflows!!) } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateInputs(inputs: MutableMap) { + paths.add("inputs") + message.appendln("---> Input :" + paths.joinToString(separator)) + validatePropertyDefinitions(inputs) + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeTemplates(nodeTemplates: MutableMap) { + paths.add("nodeTemplates") + nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> + validateNodeTemplate(nodeTemplateName, nodeTemplate) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeTemplate(nodeTemplateName : String, nodeTemplate: NodeTemplate) { + paths.add(nodeTemplateName) + message.appendln("---> Node Template :" + paths.joinToString(separator)) + val type: String = nodeTemplate.type + + val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type) + ?: throw BluePrintException(format("Failed to get node type definition for node template : {}", nodeTemplateName)) + + nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } + nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } + nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeTemplate.capabilities!!) } + nodeTemplate.requirements?.let { validateRequirementAssignments(nodeTemplate.requirements!!) } + nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeTemplate.interfaces!!) } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateWorkFlows(workflows: MutableMap) { + paths.add("workflows") + workflows.forEach { workflowName, workflow -> + + // Validate Single workflow + validateWorkFlow(workflowName, workflow) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateWorkFlow(workflowName:String, workflow: Workflow) { + paths.add(workflowName) + message.appendln("---> Workflow :" + paths.joinToString(separator)) + // Step Validation Start + paths.add("steps") + workflow.steps?.forEach { stepName, step -> + paths.add(stepName) + message.appendln("----> Steps :" + paths.joinToString(separator)) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + // Step Validation Ends + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validatePropertyDefinitions(properties: MutableMap) { + paths.add("properties") + properties.forEach { propertyName, propertyDefinition -> + paths.add(propertyName) + val dataType: String = propertyDefinition.type + when { + BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { + // Do Nothing + } + BluePrintTypes.validCollectionTypes().contains(dataType) -> { + val entrySchemaType: String = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Entry schema for data type ({}) for the property ({}) not found", dataType, propertyName)) + checkPrimitiveOrComplex(entrySchemaType, propertyName) + } + else -> checkPropertyDataType(dataType, propertyName) + } + message.appendln("property " + paths.joinToString(separator) + " of type " + dataType) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, + properties: MutableMap) { + properties.forEach { propertyName, propertyAssignment -> + val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] + ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyDefinition, propertyAssignment) + } + } + } + + @Throws(BluePrintException::class) + open fun validateArtifactDefinitions(artifacts: MutableMap) { + paths.add("artifacts") + artifacts.forEach { artifactName, artifactDefinition -> + paths.add(artifactName) + message.appendln("Validating artifact " + paths.joinToString(separator)) + val type: String = artifactDefinition.type + ?: throw BluePrintException("type is missing for artifact definition :" + artifactName) + // Check Artifact Type + checkValidArtifactType(type) + + val file: String = artifactDefinition.file + ?: throw BluePrintException(format("file is missing for artifact definition : {}", artifactName)) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignments(capabilities: MutableMap) { + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignments(requirements: MutableMap) { + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignments(interfaces: MutableMap) { + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceDefinitions(interfaces: MutableMap) { + paths.add("interfaces") + interfaces.forEach { interfaceName, interfaceDefinition -> + paths.add(interfaceName) + message.appendln("Validating : " + paths.joinToString(separator)) + interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateOperationDefinitions(operations: MutableMap) { + paths.add("operations") + operations.forEach { opertaionName, operationDefinition -> + paths.add(opertaionName) + message.appendln("Validating : " + paths.joinToString(separator)) + operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } + operationDefinition.inputs?.let { validatePropertyDefinitions(operationDefinition.inputs!!) } + operationDefinition.outputs?.let { validatePropertyDefinitions(operationDefinition.outputs!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateImplementation(implementation: Implementation) { + checkNotEmptyNThrow(implementation.primary) + } + + @Throws(BluePrintException::class) + open fun checkValidNodeType(nodeType : String) { + + } + + @Throws(BluePrintException::class) + open fun checkValidArtifactType(artifactType: String) { + + serviceTemplate.artifactTypes?.containsKey(artifactType) + ?: throw BluePrintException(format("Failed to node type definition for artifact definition : {}", artifactType)) + } + + @Throws(BluePrintException::class) + open fun checkValidNodeTypesDerivedFrom(derivedFrom: String) { + + } + + private fun checkPropertyValue(propertyDefinition: PropertyDefinition, jsonNode: JsonNode) { + //log.info("validating path ({}), Property {}, value ({})", paths, propertyDefinition, jsonNode) + } + + private fun checkPropertyDataType(dataType: String, propertyName: String): Boolean { + if (checkDataType(dataType)) { + return true + } else { + throw BluePrintException(format("Data type ({}) for the property ({}) not found", dataType, propertyName)) + } + } + + private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { + return true + } else { + throw BluePrintException(format("Data type ({}) for the property ({}) is not valid", dataType)) + } + } + + private fun checkDataType(key: String): Boolean { + return serviceTemplate.dataTypes?.containsKey(key) ?: false + } + + private fun checkNodeType(key: String): Boolean { + return serviceTemplate.nodeTypes?.containsKey(key) ?: false + } + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt new file mode 100644 index 000000000..ece09d6e2 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -0,0 +1,200 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +/** + * + * + * @author Brinda Santh + */ +class PropertyAssignmentService(var context: MutableMap, + var bluePrintRuntimeService: BluePrintRuntimeService) { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext + +/* + +If Property Assignment is Expression. + Get the Expression + Recurssely resolve the expression + */ + + fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String, + assignment: Any): JsonNode { + val valueNode: JsonNode + log.trace("Assignment ({})", assignment) + val expressionData = BluePrintExpressionService.getExpressionData(assignment) + + if (expressionData.isExpression) { + valueNode = resolveExpression(nodeTemplateName, assignmentName, expressionData) + } else { + valueNode = expressionData.valueNode + } + return valueNode + } + + fun resolveExpression(nodeTemplateName: String, propName: String, expressionData: ExpressionData): JsonNode { + + var valueNode: JsonNode = NullNode.getInstance() + + if(expressionData.isExpression) { + val command = expressionData.command!! + + when(command){ + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT ->{ + valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE ->{ + valueNode = resolveAttributeExpression(nodeTemplateName, expressionData.attributeExpression!!) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY ->{ + valueNode = resolvePropertyExpression(nodeTemplateName, expressionData.propertyExpression!!) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT ->{ + valueNode = resolveOperationOutputExpression(nodeTemplateName, expressionData.operationOutputExpression!!) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT ->{ + valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!) + } + org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE ->{ + + } + else ->{ + throw BluePrintException(String.format("for property ({}), command ({}) is not supported ", propName, command)) + } + } + } + return valueNode + } + + /* + get_property: [ , , , + , ..., ] + */ + fun resolveAttributeExpression(nodeTemplateName: String, attributeExpression: AttributeExpression): JsonNode { + val valueNode: JsonNode + + val attributeName = attributeExpression.attributeName + val subAttributeName: String? = attributeExpression.subAttributeName + + var attributeNodeTemplateName = nodeTemplateName + if (!attributeExpression.modelableEntityName.equals("SELF", true)) { + attributeNodeTemplateName = attributeExpression.modelableEntityName + } + + val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName) + ?: throw BluePrintException(String.format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, attributeName)) + + var propertyDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!! + + log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) + + // Check it it is a nested expression + valueNode = resolveAssignmentExpression(attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) + +// subPropertyName?.let { +// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) +// } + return valueNode + } + + /* + get_property: [ , , , + , ..., ] + */ + fun resolvePropertyExpression(nodeTemplateName: String, propertyExpression: PropertyExpression): JsonNode { + val valueNode: JsonNode + + val propertyName = propertyExpression.propertyName + val subPropertyName: String? = propertyExpression.subPropertyName + + var propertyNodeTemplateName = nodeTemplateName + if (!propertyExpression.modelableEntityName.equals("SELF", true)) { + propertyNodeTemplateName = propertyExpression.modelableEntityName + } + + val nodeTemplatePropertyExpression = bluePrintContext.nodeTemplateByName(propertyNodeTemplateName).properties?.get(propertyName) + ?: throw BluePrintException(format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, propertyName)) + + var propertyDefinition: PropertyDefinition = bluePrintContext.nodeTemplateNodeType(propertyNodeTemplateName).properties?.get(propertyName)!! + + log.info("node template name ({}), property Name ({}) resolved value ({})", propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) + + // Check it it is a nested expression + valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) + +// subPropertyName?.let { +// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) +// } + return valueNode + } + + /* + get_operation_output: , , , + */ + fun resolveOperationOutputExpression(nodeTemplateName: String, operationOutputExpression: OperationOutputExpression): JsonNode { + var outputNodeTemplateName = nodeTemplateName + if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) { + outputNodeTemplateName = operationOutputExpression.modelableEntityName + } + return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName, + operationOutputExpression.interfaceName, operationOutputExpression.operationName, + operationOutputExpression.propertyName) + } + + /* + get_artifact: [ , , , ] + */ + fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode { + + var artifactNodeTemplateName = nodeTemplateName + if (!artifactExpression.modelableEntityName.equals("SELF", true)) { + artifactNodeTemplateName = artifactExpression.modelableEntityName + } + val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName) + .artifacts?.get(artifactExpression.artifactName) + ?: throw BluePrintException(String.format("failed to get artifact definitions for node template ({})'s " + + "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName)) + + return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition)) + } + + fun artifactContent(artifactDefinition: ArtifactDefinition): String { + val bluePrintBasePath: String = context[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String + ?: throw BluePrintException(String.format("failed to get property (%s) from context", org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)) + + if (artifactDefinition.repository != null) { + TODO() + } else if (artifactDefinition.file != null) { + return ResourceResolverUtils.getFileContent(artifactDefinition.file!!, bluePrintBasePath) + } + return "" + } +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt new file mode 100644 index 000000000..b7f9fc7e6 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -0,0 +1,95 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + + +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.File +import java.nio.charset.Charset + +object BluePrintMetadataUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun toscaMetaData(basePath: String): ToscaMetaData { + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus("TOSCA-Metadata/TOSCA.meta") + return toscaMetaDataFromMetaFile(toscaMetaPath) + } + + @JvmStatic + fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData { + val toscaMetaData = ToscaMetaData() + val lines: MutableList = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset()) + lines.forEach { line -> + if (line.contains(":")) { + val keyValue = line.split(":") + if (keyValue.size == 2) { + val value: String = keyValue[1].trim() + when (keyValue[0]) { + "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value + "CSAR-Version" -> toscaMetaData.csarVersion = value + "Created-By" -> toscaMetaData.createdBy = value + "Entry-Definitions" -> toscaMetaData.entityDefinitions = value + "Template-Tags" -> toscaMetaData.templateTags = value + } + } + } + + } + return toscaMetaData + } + + /* + fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { + + val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator) + .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString() + + val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile) + + log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions) + + return BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath) + } + + fun getBluePrintRuntime(requestId: String, blueprintBasePath: String): BluePrintRuntimeService { + + val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator) + .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString() + + val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile) + + log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions) + + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath) + + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = requestId + + val bluePrintRuntimeService: BluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + + return bluePrintRuntimeService + } + */ +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt new file mode 100644 index 000000000..07b819ffe --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -0,0 +1,55 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager + +/** + * + * + * @author Brinda Santh + */ +object BluePrintRuntimeUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { + val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) + return assignInputs(bluePrintContext, jsonNode, context) + } + + fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap) { + val jsonNode: JsonNode = JacksonUtils.jsonNode(content) + return assignInputs(bluePrintContext, jsonNode, context) + } + + fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap) { + log.info("assignInputs from input JSON ({})", jsonNode.toString()) + bluePrintContext.inputs?.forEach { propertyName, property -> + val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() + + val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName) + log.trace("setting input path ({}), values ({})", path, valueNode) + context[path] = valueNode + } + } + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt new file mode 100644 index 000000000..0ed901702 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt @@ -0,0 +1,108 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import reactor.core.publisher.Mono +import reactor.core.publisher.toMono + +object JacksonReactorUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun getContent(fileName: String): Mono { + return JacksonUtils.getContent(fileName).toMono() + } + + @JvmStatic + fun getClassPathFileContent(fileName: String): Mono { + return JacksonUtils.getClassPathFileContent(fileName).toMono() + } + + @JvmStatic + fun readValue(content: String, valueType: Class): Mono { + return Mono.just(jacksonObjectMapper().readValue(content, valueType)) + } + + @JvmStatic + fun jsonNode(content: String): Mono { + return Mono.just(jacksonObjectMapper().readTree(content)) + } + + @JvmStatic + fun getJson(any: kotlin.Any, pretty: Boolean = false): Mono { + return Mono.just(JacksonUtils.getJson(any, pretty)) + } + + @JvmStatic + fun getListFromJson(content: String, valueType: Class): Mono> { + val objectMapper = jacksonObjectMapper() + val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) + return objectMapper.readValue>(content, javaType).toMono() + } + + @JvmStatic + fun readValueFromFile(fileName: String, valueType: Class): Mono { + return getContent(fileName) + .flatMap { content -> + readValue(content, valueType) + } + } + + @JvmStatic + fun readValueFromClassPathFile(fileName: String, valueType: Class): Mono { + return getClassPathFileContent(fileName) + .flatMap { content -> + readValue(content, valueType) + } + } + + @JvmStatic + fun jsonNodeFromFile(fileName: String): Mono { + return getContent(fileName) + .flatMap { content -> + jsonNode(content) + } + } + + @JvmStatic + fun jsonNodeFromClassPathFile(fileName: String): Mono { + return getClassPathFileContent(fileName) + .flatMap { content -> + jsonNode(content) + } + } + + @JvmStatic + fun getListFromFile(fileName: String, valueType: Class): Mono> { + return getContent(fileName) + .flatMap { content -> + getListFromJson(content, valueType) + } + } + + @JvmStatic + fun getListFromClassPathFile(fileName: String, valueType: Class): Mono> { + return getClassPathFileContent(fileName) + .flatMap { content -> + getListFromJson(content, valueType) + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt new file mode 100644 index 000000000..5075e7261 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -0,0 +1,248 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.apache.commons.io.FileUtils +import org.apache.commons.io.IOUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.format +import java.io.File +import java.nio.charset.Charset + +/** + * + * + * @author Brinda Santh + */ +object JacksonUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + inline fun readValue(content: String): T = + jacksonObjectMapper().readValue(content, T::class.java) + + @JvmStatic + fun readValue(content: String, valueType: Class): T? { + return jacksonObjectMapper().readValue(content, valueType) + } + + @JvmStatic + fun getContent(fileName: String): String { + return File(fileName).readText(Charsets.UTF_8) + } + + @JvmStatic + fun getClassPathFileContent(fileName: String): String { + return IOUtils.toString(JacksonUtils::class.java.classLoader + .getResourceAsStream(fileName), Charset.defaultCharset()) + } + + @JvmStatic + fun readValueFromFile(fileName: String, valueType: Class): T? { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + return readValue(content, valueType) + } + + @JvmStatic + fun readValueFromClassPathFile(fileName: String, valueType: Class): T? { + val content: String = getClassPathFileContent(fileName) + return readValue(content, valueType) + } + + @JvmStatic + fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java) + + @JvmStatic + fun jsonNodeFromClassPathFile(fileName: String): JsonNode { + val content: String = getClassPathFileContent(fileName) + return jsonNode(content) + } + + @JvmStatic + fun jsonNodeFromFile(fileName: String): JsonNode { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + return jsonNode(content) + } + + @JvmStatic + fun jsonNode(content: String): JsonNode { + return jacksonObjectMapper().readTree(content) + } + + @JvmStatic + fun getJson(any: kotlin.Any): String { + return getJson(any, false) + } + + @JvmStatic + fun getJson(any: kotlin.Any, pretty: Boolean = false): String { + val objectMapper = jacksonObjectMapper() + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + if (pretty) { + objectMapper.enable(SerializationFeature.INDENT_OUTPUT) + } + return objectMapper.writeValueAsString(any) + } + + @JvmStatic + fun getListFromJson(content: String, valueType: Class): List? { + val objectMapper = jacksonObjectMapper() + val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) + return objectMapper.readValue>(content, javaType) + } + + @JvmStatic + fun getListFromFile(fileName: String, valueType: Class): List? { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + return getListFromJson(content, valueType) + } + + @JvmStatic + fun getListFromClassPathFile(fileName: String, valueType: Class): List? { + val content: String = getClassPathFileContent(fileName) + return getListFromJson(content, valueType) + } + + @JvmStatic + fun getMapFromJson(content: String, valueType: Class): MutableMap? { + val objectMapper = jacksonObjectMapper() + val typeRef = object : TypeReference>() {} + return objectMapper.readValue(content, typeRef) + } + + @JvmStatic + fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + return checkJsonNodeValueOfPrimitiveType(type, jsonNode) + } else if (BluePrintTypes.validCollectionTypes().contains(type)) { + return checkJsonNodeValueOfCollectionType(type, jsonNode) + } + return false + } + + @JvmStatic + fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { + when (primitiveType) { + BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual + BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean + BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt + BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble + BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual + else -> return false + } + } + + @JvmStatic + fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { + when (type) { + BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray + BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode + else -> return false + } + + } +/* + @JvmStatic + fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) { + if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { + objectNode.put(key, value as Boolean) + } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { + objectNode.put(key, value as Int) + } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { + objectNode.put(key, value as Float) + } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) { + objectNode.put(key, value as String) + } else { + objectNode.put(key, value as String) + } + } + + @JvmStatic + fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) { + if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { + objectNode.add(value as Boolean) + } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { + objectNode.add(value as Int) + } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { + objectNode.add(value as Float) + } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) { + objectNode.add(value as String) + } else { + objectNode.add(value as String) + } + } + + @JvmStatic + fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { + if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { + objectNode.put(key, false) + } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { + objectNode.put(key, 0) + } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { + objectNode.put(key, 0.0) + } else { + objectNode.put(key, "") + } + } + + @JvmStatic + fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { + if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { + arrayNode.add(false) + } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { + arrayNode.add(0) + } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { + arrayNode.add(0.0) + } else { + arrayNode.add("") + } + } + + @JvmStatic + fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { + if (nodeValue == null || nodeValue is NullNode) { + objectNode.set(key, nodeValue) + } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) { + objectNode.put(key, nodeValue.asBoolean()) + } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) { + objectNode.put(key, nodeValue.asInt()) + } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) { + objectNode.put(key, nodeValue.floatValue()) + } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) { + objectNode.put(key, nodeValue.asText()) + } else { + objectNode.put(key, nodeValue.asText()) + } + } else { + objectNode.set(key, nodeValue) + } + } + */ +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt new file mode 100644 index 000000000..bc0d9b4c6 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt @@ -0,0 +1,62 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.File +import java.net.URL +import java.nio.charset.Charset +/** + * + * + * @author Brinda Santh + */ +object ResourceResolverUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun getFileContent(filename : String, basePath : String?): String { + log.trace("file ({}), basePath ({}) ", filename, basePath) + try{ + var resolvedFileName : String = filename + if(filename.startsWith("http", true) + || filename.startsWith("https", true)){ + val givenUrl : String = URL(filename).toString() + val systemUrl : String = File(".").toURI().toURL().toString() + log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl) + if(givenUrl.startsWith(systemUrl)){ + + } + }else{ + if(!filename.startsWith("/")){ + if (checkNotEmpty(basePath)) { + resolvedFileName = basePath.plus(File.separator).plus(filename) + }else{ + resolvedFileName = javaClass.classLoader.getResource(".").path.plus(filename) + } + } + } + return FileUtils.readFileToString(File(resolvedFileName), Charset.defaultCharset()) + }catch (e : Exception){ + throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt new file mode 100644 index 000000000..0d739357c --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import java.io.File +import java.nio.charset.Charset + +/** + * + * + * @author Brinda Santh + */ +object ServiceTemplateUtils { + + @JvmStatic + fun getServiceTemplate(fileName: String): ServiceTemplate { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + return getServiceTemplateFromContent(content) + } + + + @JvmStatic + fun getServiceTemplateFromContent(content: String): ServiceTemplate { + return JacksonUtils.readValue(content) + } + + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt new file mode 100644 index 000000000..dcafa974c --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt @@ -0,0 +1,131 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import java.util.* + +/** + * + * + * @author Brinda Santh + */ +class TopologicalSortingUtils { + + private val neighbors: MutableMap> = hashMapOf() + + val isDag: Boolean + get() = topSort() != null + + override fun toString(): String { + val s = StringBuffer() + for (v in neighbors.keys) + s.append("\n " + v + " -> " + neighbors[v]) + return s.toString() + } + + fun getNeighbors(): Map> { + return neighbors + } + + fun add(vertex: V) { + if (neighbors.containsKey(vertex)) + return + neighbors[vertex] = arrayListOf() + } + + operator fun contains(vertex: V): Boolean { + return neighbors.containsKey(vertex) + } + + fun add(from: V, to: V) { + this.add(from) + this.add(to) + neighbors[from]?.add(to) + } + + fun remove(from: V, to: V) { + if (!(this.contains(from) && this.contains(to))) + throw IllegalArgumentException("Nonexistent vertex") + neighbors[from]?.remove(to) + } + + fun outDegree(): Map { + var result: MutableMap = hashMapOf() + for (v in neighbors.keys) + result[v] = neighbors[v]!!.size + return result + } + + + fun inDegree(): MutableMap { + val result = HashMap() + for (v in neighbors.keys) + result[v] = 0 // All in-degrees are 0 + for (from in neighbors.keys) { + for (to in neighbors[from]!!) { + result[to] = result[to]!! + 1 // Increment in-degree + } + } + return result + } + + fun topSort(): List? { + val degree = inDegree() + // Determine all vertices with zero in-degree + val zeroVerts = Stack() // Stack as good as any here + for (v in degree.keys) { + if (degree[v] == 0) zeroVerts.push(v) + } + // Determine the topological order + val result = ArrayList() + while (!zeroVerts.isEmpty()) { + val v = zeroVerts.pop() // Choose a vertex with zero in-degree + result.add(v) // Vertex v is next in topol order + // "Remove" vertex v by updating its neighbors + for (neighbor in neighbors[v]!!) { + degree[neighbor] = degree[neighbor]!! - 1 + // Remember any vertices that now have zero in-degree + if (degree[neighbor] == 0) zeroVerts.push(neighbor) + } + } + // Check that we have used the entire graph (if not, there was a cycle) + return if (result.size != neighbors.size) null else result + } + + + fun bfsDistance(start: V): Map<*, *> { + var distance: MutableMap = hashMapOf() + // Initially, all distance are infinity, except start node + for (v in neighbors.keys) + distance[v] = -1 + distance[start] = 0 + // Process nodes in queue order + val queue = LinkedList() + queue.offer(start) // Place start node in queue + while (!queue.isEmpty()) { + val v = queue.remove() + val vDist = distance[v]!! + // Update neighbors + for (neighbor in neighbors[v]!!) { + if (distance[neighbor] != null) continue // Ignore if already done + distance[neighbor] = vDist + 1 + queue.offer(neighbor) + } + } + return distance + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt new file mode 100644 index 000000000..128b7f576 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt @@ -0,0 +1,35 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +import org.junit.Test +import kotlin.test.assertEquals +/** + * + * + * @author Brinda Santh + */ +class CustomFunctionsTest { + @Test + fun testFormat(): Unit { + val returnValue : String = format("This is {} for times {}", "test", 2) + assertEquals("This is test for times 2", returnValue, "Failed to format String") + + val returnValue1 : String = format("This is test for times 2") + assertEquals("This is test for times 2", returnValue1, "Failed to format empty args") + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt new file mode 100644 index 000000000..7a74ca476 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt @@ -0,0 +1,70 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + + +import org.apache.commons.io.FileUtils +import org.junit.Before +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.File +import java.nio.charset.Charset +import kotlin.test.assertNotNull +/** + * + * + * @author Brinda Santh + */ +class BluePrintContextTest { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + lateinit var bluePrintContext: BluePrintContext + + @Before + fun setUp() { + + val basepath = "load/blueprints" + + bluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + } + + @Test + fun testBluePrintContextFromContent() { + val fileName = "load/blueprints/baseconfiguration/Definitions/activation-blueprint.json" + val content : String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + val bpContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprint(content) + assertNotNull(bpContext, "Failed to get blueprint content") + assertNotNull(bpContext.serviceTemplate, "Failed to get blueprint content's service template") + } + + @Test + fun testChainedProperty() { + val nodeType = bluePrintContext.nodeTypeChained("component-resource-assignment") + assertNotNull(nodeType, "Failed to get chained node type") + log.trace("Properties {}", JacksonUtils.getJson(nodeType, true)) + } + + +} diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt new file mode 100644 index 000000000..8e6d5efdf --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt @@ -0,0 +1,41 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils + +/** + * BluePrintEnhancerServiceTest + * @author Brinda Santh + * + */ + +class BluePrintEnhancerServiceTest { + val basePath = "load/model_type" + + @Test + fun testEnrichBlueprint() { + val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath) + val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService) + + val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json") + bluePrintEnhancerService.enhance(serviceTemplate) + + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt new file mode 100644 index 000000000..911a891a8 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt @@ -0,0 +1,109 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +/** + * + * + * @author Brinda Santh + */ +class BluePrintExpressionServiceTest { + @Test + fun testInputExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.inputExpression, " Failed to populate input expression data") + assertEquals("input-name", expressionData.inputExpression?.propertyName, "Failed to get propertyName from expression data") + } + + @Test + fun testPropertyExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data") + assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName") + + val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }") + val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) + assertNotNull(expressionData1, " Failed to populate expression data") + assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression") + assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data") + assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName") + assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data") + } + + @Test + fun testAttributeExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data") + assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("attribute-name", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName") + assertEquals("resource/name",expressionData.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data") + } + + + @Test + fun testOutputOperationExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data") + assertEquals("SELF", expressionData.operationOutputExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("interface-name", expressionData.operationOutputExpression?.interfaceName, " Failed to get expected interfaceName") + assertEquals("operation-name", expressionData.operationOutputExpression?.operationName, " Failed to get expected operationName") + assertEquals("output-property-name", expressionData.operationOutputExpression?.propertyName, " Failed to get expected propertyName") + } + + + @Test + fun testArtifactExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data") + assertEquals("SELF", expressionData.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName") + + + val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }") + val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) + assertNotNull(expressionData1, " Failed to populate expression data") + assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data") + assertEquals("SELF", expressionData1.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("artifact-template", expressionData1.artifactExpression?.artifactName, " Failed to get expected artifactName") + assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location") + assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove") + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt new file mode 100644 index 000000000..5a5557d75 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt @@ -0,0 +1,42 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import kotlin.test.assertNotNull + +/** + * + * + * @author Brinda Santh + */ +class BluePrintParserFactoryTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @Test + fun testBluePrintJson() { + val basepath = "load/blueprints" + + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + log.trace("Blue Print {}",bluePrintContext.blueprintJson(true)) + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt new file mode 100644 index 000000000..88aea919e --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -0,0 +1,57 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.junit.Test +import java.io.FileNotFoundException +import kotlin.test.assertNotNull + +/** + * BluePrintRepoFileServiceTest + * @author Brinda Santh + * + */ +class BluePrintRepoFileServiceTest { + + private val basePath = "load/model_type" + private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath) + + @Test + fun testGetDataType() { + val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")?.block() + assertNotNull(dataType, "Failed to get DataType from repo") + } + + @Test + fun testGetNodeType() { + val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")?.block() + assertNotNull(nodeType, "Failed to get NodeType from repo") + } + + @Test + fun testGetArtifactType() { + val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")?.block() + assertNotNull(nodeType, "Failed to get ArtifactType from repo") + } + + @Test(expected = FileNotFoundException::class) + fun testModelNotFound() { + val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")?.block() + assertNotNull(dataType, "Failed to get DataType from repo") + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt new file mode 100644 index 000000000..5d24b072f --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -0,0 +1,131 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.junit.Before +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import kotlin.test.assertEquals +import kotlin.test.assertNotNull + +/** + * + * + * @author Brinda Santh + */ +class BluePrintRuntimeServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + val basepath = "load/blueprints" + + + @Before + fun setUp(): Unit { + + } + + @Test + fun testResolveNodeTemplateProperties() { + log.info("************************ testResolveNodeTemplateProperties **********************") + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + + val inputDataPath = "src/test/resources/data/default-context.json" + + val inputNode: JsonNode = jsonNodeFromFile(inputDataPath) + bluePrintRuntimeService.assignInputs(inputNode) + + val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") + log.info("Context {}" ,bluePrintRuntimeService.context) + + assertNotNull(propContext, "Failed to populate interface property values") + assertEquals(propContext.get("process-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter process-name") + assertEquals(propContext.get("version"), jsonNodeFromObject("sample-action"), "Failed to populate parameter version") + } + + @Test + fun testResolveNodeTemplateInterfaceOperationInputs() { + log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + + val inputDataPath = "src/test/resources/data/default-context.json" + BluePrintRuntimeUtils.assignInputsFromFile(bluePrintContext, inputDataPath, context) + + + val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + + log.info("Prepared Context {}" ,context) + + val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment", + "DefaultComponentNode", "process") + + log.trace("In Context {}" ,inContext) + + assertNotNull(inContext, "Failed to populate interface input property values") + assertEquals(inContext.get("action-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") + assertEquals(inContext.get("request-id"), jsonNodeFromObject("12345"), "Failed to populate parameter action-name") + assertEquals(inContext.get("template-content"), jsonNodeFromObject("This is Sample Velocity Template"), "Failed to populate parameter action-name") + + } + + @Test + fun testResolveNodeTemplateInterfaceOperationOutputs() { + log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************") + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + + val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + + val componentContext: MutableMap = hashMapOf() + val successValue : JsonNode= jsonNodeFromObject("Success") + componentContext["resource-assignment.DefaultComponentNode.process.status"] = successValue + componentContext["resource-assignment.DefaultComponentNode.process.resource-assignment-params"] = null + + bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", + "DefaultComponentNode", "process", componentContext) + + assertEquals(NullNode.instance, + context.get("node_templates/resource-assignment/interfaces/DefaultComponentNode/operations/process/properties/resource-assignment-params"), + "Failed to get operation property resource-assignment-params") + + assertEquals(successValue, + context.get("node_templates/resource-assignment/interfaces/DefaultComponentNode/operations/process/properties/status"), + "Failed to get operation property status") + + + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt new file mode 100644 index 000000000..b05fcb61b --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt @@ -0,0 +1,49 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.junit.Before +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager + +/** + * + * + * @author Brinda Santh + */ +class BluePrintValidatorDefaultServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + val basepath = "load/blueprints" + + @Before + fun setUp(): Unit { + + } + + @Test + fun testValidateBluePrint() { + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + val properties : MutableMap = hashMapOf() + val validatorService = BluePrintValidatorDefaultService() + validatorService.validateBlueprint(bluePrintContext.serviceTemplate,properties) + log.info("Validation Message {}", properties) + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt new file mode 100644 index 000000000..ddb39a2d6 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt @@ -0,0 +1,40 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData +import kotlin.test.assertNotNull + +class BluePrintMetadataUtilsTest { + + @Test + fun testToscaMetaData(){ + + val basePath : String = "load/blueprints/baseconfiguration" + + val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath) + assertNotNull(toscaMetaData, "Missing Tosca Definition Object") + assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version") + assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version") + assertNotNull(toscaMetaData.createdBy, "Missing Created by") + assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition") + assertNotNull(toscaMetaData.templateTags, "Missing Template Tags") + + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt new file mode 100644 index 000000000..d13caa52c --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -0,0 +1,51 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import java.io.FileNotFoundException +import kotlin.test.assertEquals +import kotlin.test.assertNotNull + +class JacksonReactorUtilsTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + @Test + fun testReadValues() { + + val serviceTemplate = JacksonReactorUtils.readValueFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json", + ServiceTemplate::class.java).block() + + assertNotNull(serviceTemplate, "Failed to simple transform Service Template") + assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance") + + val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block() + assertNotNull(jsonContent, "Failed to get json content") + + val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json") + .block() + assertNotNull(jsonContent, "Failed to get json Node") + } + + @Test(expected = FileNotFoundException::class) + fun testReadValuesFailure() { + JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json") + .block() + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt new file mode 100644 index 000000000..a5a630e3c --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -0,0 +1,93 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertTrue + +/** + * JacksonUtilsTest + * @author Brinda Santh + * ${DATA} + */ +class JacksonUtilsTest { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + val basePath = "load/blueprints" + + @Test + fun testReadValues() { + val content = ResourceResolverUtils.getFileContent("baseconfiguration/Definitions/activation-blueprint.json", basePath) + val serviceTemplate = JacksonUtils.readValue(content, ServiceTemplate::class.java) + assertNotNull(serviceTemplate, "Failed to simple transform Service Template") + assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance") + + val jsonContent = JacksonUtils.getJson(serviceTemplate!!, true) + assertNotNull(jsonContent, "Failed to get json content") + } + + @Test + fun testJsonNodeFromClassPathFile() { + val filePath = "data/default-context.json" + JacksonUtils.jsonNodeFromClassPathFile(filePath) + } + + @Test + fun testJsonNodeFromFile() { + val filePath = basePath + "/baseconfiguration/Definitions/activation-blueprint.json" + JacksonUtils.jsonNodeFromFile(filePath) + } + + @Test + fun testGetListFromJson() { + val content = "[\"good\",\"boy\" ]" + val nodeType = JacksonUtils.getListFromJson(content, String::class.java) + assertNotNull(nodeType, "Failed to get String array from content") + } + + + @Test + fun testJsonValue() { + val filePath = "data/alltype-data.json" + val rootJson = JacksonUtils.jsonNodeFromClassPathFile(filePath) + assertNotNull(rootJson, "Failed to get all type data json node") + val intValue = rootJson.get("intValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value") + val floatValue = rootJson.get("floatValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value") + val stringValue = rootJson.get("stringValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value") + val booleanValue = rootJson.get("booleanValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value") + val arrayStringValue = rootJson.get("arrayStringValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value") + val mapValue = rootJson.get("mapValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value") + + assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed") + + + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt new file mode 100644 index 000000000..3fa4f75d9 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt @@ -0,0 +1,36 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import org.junit.Test + +class TopologicalSortingUtilsTest { + + @Test + fun testSorting(): Unit { + val graph: TopologicalSortingUtils = TopologicalSortingUtils() + graph.add("bundle-id", "bundle-mac") + graph.add("bundle-id", "bundle-ip") + graph.add("bundle-mac", "bundle-ip") + graph.add("bundle-ip", "bundle-mac") + + println("The current graph: " + graph) + println("In-degrees: " + graph.inDegree()) + println("Out-degrees: " + graph.outDegree()) + println("A topological sort of the vertices: " + graph.topSort()) + } +} \ No newline at end of file diff --git a/components/core/src/test/resources/componentnode/default.json b/components/core/src/test/resources/componentnode/default.json new file mode 100644 index 000000000..b7265fcd1 --- /dev/null +++ b/components/core/src/test/resources/componentnode/default.json @@ -0,0 +1,100 @@ +{ + "metadata": { + "template_author": "bs2796", + "vendor": "Juniper", + "os": "XXX", + "service-type": "AVPN", + "vnf-type": "VRR", + "action": "Base Configuration", + "sub-action": "Generate Configuration", + "template_name": "VRR-baseconfiguration", + "template_version": "1.0.0" + }, + "topology_template": { + "inputs": { + "service-instance-id": { + "required": true, + "type": "string" + }, + "vnf-id": { + "required": true, + "type": "string" + }, + "service": { + "required": true, + "type": "string" + }, + "region": { + "required": true, + "type": "string" + }, + "bundle-id": { + "required": true, + "type": "string" + }, + "bundle-mac": { + "required": true, + "type": "string" + } + }, + "node_templates": { + "generate-configuration": { + "type": "mock-component-generateConfig", + "interfaces": { + "org-openecomp-sdnc-config-params-service-MockComponentNode": { + "operations": { + "process": { + "inputs": { + "entity-type": "vnf-type", + "template-content": "sample-template", + "entity-id": "{ \"get_input\" : \"vnf-id\" }" + }, + "outputs": { + "mergedData": "merged Data", + "status": "status" + } + } + } + } + } + } + } + }, + "node_types": { + "mock-component-generateConfig": { + "interfaces": { + "org-openecomp-sdnc-config-params-service-MockComponentNode": { + "operations": { + "process": { + "inputs": { + "entity-type": { + "required": false, + "type": "string" + }, + "template-content": { + "required": false, + "type": "string" + }, + "entity-id": { + "required": true, + "type": "string" + } + }, + "outputs": { + "generated-config": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + } + } +} diff --git a/components/core/src/test/resources/data/alltype-data.json b/components/core/src/test/resources/data/alltype-data.json new file mode 100644 index 000000000..055b09658 --- /dev/null +++ b/components/core/src/test/resources/data/alltype-data.json @@ -0,0 +1,10 @@ +{ + "intValue" : 1, + "floatValue" : 1.34, + "booleanValue" : true, + "stringValue" : "sample-String", + "timeValue" : "2018-09-29", + "arrayStringValue" : ["one", "two"], + "mapValue" : {"profile_name1":"profile_name1", + "profile_name2":"profile_name2"} +} \ No newline at end of file diff --git a/components/core/src/test/resources/data/default-context.json b/components/core/src/test/resources/data/default-context.json new file mode 100644 index 000000000..fcd4cbe26 --- /dev/null +++ b/components/core/src/test/resources/data/default-context.json @@ -0,0 +1,5 @@ +{ + "request-id" : "12345", + "hostname" : "localhost", + "action-name" : "sample-action" +} \ No newline at end of file diff --git a/components/core/src/test/resources/dictionary/dictionary_schema.json b/components/core/src/test/resources/dictionary/dictionary_schema.json new file mode 100644 index 000000000..d03170050 --- /dev/null +++ b/components/core/src/test/resources/dictionary/dictionary_schema.json @@ -0,0 +1,261 @@ +{ + "type": "object", + "properties": { + "resource-path": { + "type": "string", + "required": true + }, + "description": { + "type": "string" + }, + "updated-by": { + "type": "string" + }, + "data-type": { + "type": "string", + "required": true + }, + "source": { + "type": "object", + "required": true, + "properties": { + "input": { + "type": "object", + "properties": { + "key": { + "type": "string" + } + } + }, + "component": { + "type": "object", + "properties": { + "name": { + "type": "string", + "required": true + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "default": { + "type": "any" + }, + "aai": { + "type": "any" + }, + "mdsal": { + "type": "object", + "properties": { + "path": { + "type": "string", + "required": true + }, + "url-path": { + "type": "string", + "required": true + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "type": "string", + "required": true + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "base": { + "type": "string", + "required": true + } + } + }, + "network-resource-discovery": { + "type": "object", + "properties": { + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "db": { + "type": "object", + "properties": { + "query": { + "type": "string", + "required": true + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "type": "string", + "required": true + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "base": { + "type": "string", + "required": true + } + } + }, + "policy": { + "type": "object", + "properties": { + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "candidate-dependency": { + "type": "object", + "properties": { + "input": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "component": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "aai": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "mdsal": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "network-resource-discovery": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "db": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "policy": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "tags": { + "type": "string" + }, + "default": { + "type": "any" + }, + "name": { + "type": "string", + "required": true + }, + "valid-values": { + "type": "string" + }, + "resource-type": { + "type": "string", + "required": true + }, + "sample-value": { + "type": "string" + }, + "entry-schema": { + "type": "string" + } + } +} diff --git a/components/core/src/test/resources/properties/convert.json b/components/core/src/test/resources/properties/convert.json new file mode 100644 index 000000000..cb7d08e44 --- /dev/null +++ b/components/core/src/test/resources/properties/convert.json @@ -0,0 +1,33 @@ +{ + "type": "sdnc-component-getResourceAssignment", + "interfaces": { + "ResourceAssignmentService": { + "operations": { + "getResourceAssignment": { + "inputs": { + "assignment-mappings": [ + { + "name": "service-name", + "mapping-field": "service", + "mapping-category": "SDN", + "required": true + }, + { + "name": "region-name", + "mapping-field": "region", + "mapping-category": "SDN", + "required": true + } + ], + "pre-data": "{ \"get_attribute\" : \"get-resource-assignment.config-params\" }", + "prifix": "get-resource-assignment" + }, + "outputs": { + "resource-assignment-status": "success", + "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params\" }" + } + } + } + } + } +} diff --git a/components/core/src/test/resources/properties/default.json b/components/core/src/test/resources/properties/default.json new file mode 100644 index 000000000..0ac97f907 --- /dev/null +++ b/components/core/src/test/resources/properties/default.json @@ -0,0 +1,16 @@ +{ + "default": "{ \"get_input\" : \"loopback-default\" }", + "domain": "ethernet", + "criteria": [ + { + "value": "attga301me1", + "type": "complex", + "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" + }, + { + "value": "{ \"get_input\" : \"host-ip-address\" }", + "type": "simple", + "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" + } + ] +} diff --git a/components/parent/pom.xml b/components/parent/pom.xml new file mode 100644 index 000000000..cbbeeffc1 --- /dev/null +++ b/components/parent/pom.xml @@ -0,0 +1,299 @@ + + + + 4.0.0 + + org.onap.ccsdk.apps + components + 0.3.0-SNAPSHOT + + org.onap.ccsdk.apps.components + parent + App Components Parent + pom + + 2.0.4.RELEASE + 5.0.8.RELEASE + 1.2.60 + 1.0.0 + 26.0-jre + 2.9.2 + 1.4.197 + 1.2.2-SNAPSHOT + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + com.att.eelf + eelf-core + ${eelf.version} + + + org.onap.logging-analytics + logging-slf4j + ${onap.logger.slf4j} + + + + + io.springfox + springfox-swagger2 + ${springfox.swagger2.version} + + + io.springfox + springfox-swagger-ui + ${springfox.swagger2.version} + + + + org.apache.commons + commons-lang3 + 3.2.1 + + + commons-collections + commons-collections + 3.2.2 + + + commons-io + commons-io + 2.6 + + + org.apache.velocity + velocity + 1.7 + + + com.google.guava + guava + ${guava.version} + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + + + + com.h2database + h2 + ${h2database.version} + + + + + + org.onap.ccsdk.apps.controllerblueprints + core + ${project.version} + + + org.onap.ccsdk.apps.controllerblueprints + service + ${project.version} + + + org.onap.ccsdk.apps.controllerblueprints + application + ${project.version} + + + org.onap.ccsdk.apps.controllerblueprints + resource-dict + ${project.version} + + + + + org.powermock + powermock-api-mockito2 + 1.7.4 + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + + + + + com.att.eelf + eelf-core + + + org.onap.logging-analytics + logging-slf4j + + + org.apache.commons + commons-lang3 + + + commons-collections + commons-collections + + + commons-io + commons-io + + + com.jayway.jsonpath + json-path + + + com.google.guava + guava + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + + diff --git a/components/pom.xml b/components/pom.xml new file mode 100644 index 000000000..aada3eb1d --- /dev/null +++ b/components/pom.xml @@ -0,0 +1,45 @@ + + + + + + org.onap.ccsdk.apps + ccsdk-apps + 0.3.0-SNAPSHOT + + 4.0.0 + org.onap.ccsdk.apps + components + App Components Root + pom + + UTF-8 + UTF-8 + yyyyMMdd'T'HHmmss'Z' + ${maven.build.timestamp} + 1.8 + 1.8 + 1.8 + + + parent + core + resource-dict + + + diff --git a/components/resource-dict/load/model_type/node_type/source-component-java.json b/components/resource-dict/load/model_type/node_type/source-component-java.json new file mode 100644 index 000000000..95a9801dc --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/source-component-java.json @@ -0,0 +1,31 @@ +{ + "description": "This is Custom Java Component Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": false, + "type": "string", + "default" : "DYNAMIC", + "constraints": [ + { + "validValues": [ + "DYNAMIC" + ] + } + ] + }, + "class-name": { + "required": true, + "type": "string", + "description" : "Fully Qualified Class Name ( + . + )" + }, + "key-dependencies": { + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} \ No newline at end of file diff --git a/components/resource-dict/load/model_type/node_type/source-db.json b/components/resource-dict/load/model_type/node_type/source-db.json new file mode 100644 index 000000000..661a9503b --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/source-db.json @@ -0,0 +1,44 @@ +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "query": { + "required": true, + "type": "string" + }, + "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" +} \ No newline at end of file diff --git a/components/resource-dict/load/model_type/node_type/source-default.json b/components/resource-dict/load/model_type/node_type/source-default.json new file mode 100644 index 000000000..13e234e1b --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/source-default.json @@ -0,0 +1,18 @@ +{ + "description": "This is Default Resource Source Node Type", + "version": "1.0.0", + "properties": { + "key": { + "required": false, + "type": "string" + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} \ No newline at end of file diff --git a/components/resource-dict/load/model_type/node_type/source-input.json b/components/resource-dict/load/model_type/node_type/source-input.json new file mode 100644 index 000000000..126ea30bd --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/source-input.json @@ -0,0 +1,18 @@ +{ + "description": "This is Input Resource Source Node Type", + "version": "1.0.0", + "properties": { + "key": { + "required": false, + "type": "string" + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} \ No newline at end of file diff --git a/components/resource-dict/load/model_type/node_type/source-rest.json b/components/resource-dict/load/model_type/node_type/source-rest.json new file mode 100644 index 000000000..f8dd8b6fc --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/source-rest.json @@ -0,0 +1,61 @@ +{ + "description": "This is Rest Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "JSON", + "constraints": [ + { + "valid_values": [ + "JSON" + ] + } + ] + }, + "url-path": { + "required": true, + "type": "string" + }, + "path": { + "required": true, + "type": "string" + }, + "expression-type": { + "required": false, + "type": "string", + "default": "JSON_PATH", + "constraints": [ + { + "valid_values": [ + "JSON_PATH", + "JSON_POINTER" + ] + } + ] + }, + "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" +} \ No newline at end of file diff --git a/components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json b/components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json new file mode 100644 index 000000000..2ef553e24 --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json @@ -0,0 +1,5 @@ +{ + "description": "TOSCA base type for Resource Sources", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/db-source.json b/components/resource-dict/load/resource_dictionary/db-source.json new file mode 100644 index 000000000..92b16a212 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/db-source.json @@ -0,0 +1,26 @@ +{ + "name": "db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "resource-type": "ONAP", + "resource-path": "vnf/bundle-id", + "updated-by": "brindasanth@onap.com", + "tags": "bundle-id, brindasanth@onap.com", + "sources": { + "db": { + "type": "source-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/default-source.json b/components/resource-dict/load/resource_dictionary/default-source.json new file mode 100644 index 000000000..1c47f37b2 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/default-source.json @@ -0,0 +1,18 @@ +{ + "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", + "name": "default-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "resource-type": "ONAP", + "resource-path": "vnf/v4-ip-type", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/input-source.json b/components/resource-dict/load/resource_dictionary/input-source.json new file mode 100644 index 000000000..676d92f86 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/input-source.json @@ -0,0 +1,19 @@ +{ + "name": "input-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "resource-path": "action-name", + "resource-type": "ONAP", + "updated-by": "brindasanth@onap.com", + "tags": null, + "sources": { + "input": { + "type": "source-input", + "properties": { + "key": "action-name" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/mdsal-source.json b/components/resource-dict/load/resource_dictionary/mdsal-source.json new file mode 100644 index 000000000..b49146a0e --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/mdsal-source.json @@ -0,0 +1,36 @@ +{ + "tags": "oam-local-ipv4-address", + "name": "mdsal-source", + "property" :{ + "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "resource-type": "ATT", + "resource-path": "vnf/oam-local-ipv4-address", + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", + "path": "/v4-assigned-ip-list/0/v4-ip-prefix", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "network-role": "network-role", + "v4-ip-type": "v4-ip-type", + "vm-type": "vm-type" + }, + "output-key-mapping": { + "oam-local-ipv4-address": "v4-ip-prefix" + }, + "key-dependencies": [ + "service-instance-id", + "network-role", + "v4-ip-type", + "vm-type" + ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml new file mode 100644 index 000000000..7eecb5ee4 --- /dev/null +++ b/components/resource-dict/pom.xml @@ -0,0 +1,49 @@ + + + + + 4.0.0 + + org.onap.ccsdk.apps.components + parent + 0.3.0-SNAPSHOT + ../parent + + org.onap.ccsdk.apps.controllerblueprints + resource-dict + Controller Blueprints Resource Dictionary + + + + org.onap.ccsdk.apps.controllerblueprints + core + + + org.jetbrains.kotlin + kotlin-test + test + + + + + + diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt new file mode 100644 index 000000000..a6802f677 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt @@ -0,0 +1,34 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException + +interface ResourceAssignmentProcessor { + + @Throws(BluePrintProcessorException::class) + fun validate(resourceAssignment: ResourceAssignment, context : MutableMap) + + @Throws(BluePrintProcessorException::class) + fun process(resourceAssignment: ResourceAssignment, context : MutableMap) + + @Throws(BluePrintProcessorException::class) + fun errorHandle(resourceAssignment: ResourceAssignment, context : MutableMap) + + @Throws(BluePrintProcessorException::class) + fun reTrigger(resourceAssignment: ResourceAssignment, context : MutableMap) +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt new file mode 100644 index 000000000..0808073f8 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -0,0 +1,100 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict + +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonProperty +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import java.io.Serializable +import java.util.* + +open class ResourceDefinition { + + @JsonProperty(value = "name", required = true) + lateinit var name: String + + @JsonProperty(value = "property", required = true) + lateinit var property: PropertyDefinition + + var tags: String? = null + + @JsonProperty(value = "updated-by") + lateinit var updatedBy: String + + @JsonProperty(value = "resource-type", required = true) + lateinit var resourceType: String + + @JsonProperty(value = "resource-path", required = true) + lateinit var resourcePath: String + + @JsonProperty(value = "sources", required = true) + lateinit var sources: MutableMap +} + +open class ResourceAssignment { + + @JsonProperty(value = "name", required = true) + lateinit var name: String + + @JsonProperty(value = "property") + var property: PropertyDefinition? = null + + @JsonProperty("input-param") + var inputParameter: Boolean = false + + @JsonProperty("dictionary-name") + var dictionaryName: String? = null + + @JsonProperty("dictionary-source") + var dictionarySource: String? = null + + @JsonProperty("dependencies") + var dependencies: MutableList? = null + + @JsonProperty("version") + var version: Int = 0 + + @JsonProperty("status") + var status: String? = null + + @JsonProperty("message") + var message: String? = null + + @JsonProperty("updated-date") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + var updatedDate: Date? = null + + @JsonProperty("updated-by") + var updatedBy: String? = null + + override fun toString(): String { + return StringBuilder() + .append("[") + .append("name=", name) + .append(", dictionaryName=", dictionaryName) + .append(", dictionarySource=", dictionarySource) + .append("]") + .toString() + } +} + +/** + * Interface for Source Definitions (ex Input Source, + * Default Source, Database Source, Rest Sources, etc) + */ +interface ResourceSource : Serializable diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt new file mode 100644 index 000000000..aa6a9fb65 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -0,0 +1,34 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict +/** + * ResourceDictionaryConstants + * + * @author Brinda Santh + */ +object ResourceDictionaryConstants { + const val SOURCE_INPUT = "input" + const val SOURCE_DEFAULT = "default" + const val SOURCE_DB = "db" + + const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" + + const val PROPERTY_TYPE = "type" + const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" + const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" + const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies" +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt new file mode 100644 index 000000000..c5a78a9c9 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt @@ -0,0 +1,86 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import com.att.eelf.configuration.EELFManager + +/** + * ResourceAssignmentEnhancerService. + * + * @author Brinda Santh + */ +interface ResourceAssignmentEnhancerService { + + @Throws(BluePrintException::class) + fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, + resourceAssignments: List) + + @Throws(BluePrintException::class) + fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate +} + +/** + * ResourceAssignmentEnhancerDefaultService. + * + * @author Brinda Santh + */ +open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) + : ResourceAssignmentEnhancerService { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) + + /** + * Get the defined source instance from the ResourceAssignment, + * then get the NodeType of the Sources assigned + */ + override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, + resourceAssignments: List) { + + // Iterate the Resource Assignment and + resourceAssignments.map { resourceAssignment -> + val dictionaryName = resourceAssignment.dictionaryName!! + val dictionarySource = resourceAssignment.dictionarySource!! + log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name, + dictionaryName, dictionarySource) + // Get the Resource Definition from Repo + val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName) + + val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource) + + // Enrich as NodeTemplate + bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!) + } + } + + override fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate { + val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService) + bluePrintEnhancerService.serviceTemplate = ServiceTemplate() + bluePrintEnhancerService.initialCleanUp() + enhanceBluePrint(bluePrintEnhancerService, resourceAssignments) + return bluePrintEnhancerService.serviceTemplate + } + + private fun getResourceDefinition(name: String): ResourceDefinition { + return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!! + } +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt new file mode 100644 index 000000000..228b39e29 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -0,0 +1,151 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import org.apache.commons.collections.CollectionUtils +import org.apache.commons.lang3.StringUtils +import org.apache.commons.lang3.text.StrBuilder +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import com.att.eelf.configuration.EELFManager +import java.io.Serializable + +/** + * ResourceAssignmentValidationService. + * + * @author Brinda Santh + */ +interface ResourceAssignmentValidationService : Serializable { + + @Throws(BluePrintException::class) + fun validate(resourceAssignments: List): Boolean +} + +/** + * ResourceAssignmentValidationDefaultService. + * + * @author Brinda Santh + */ +open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValidationService { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) + + open var resourceAssignmentMap: Map = hashMapOf() + open val validationMessage = StrBuilder() + + override fun validate(resourceAssignments: List): Boolean { + try { + validateSources(resourceAssignments) + validateTemplateNDictionaryKeys(resourceAssignments) + validateCyclicDependency(resourceAssignments) + if (StringUtils.isNotBlank(validationMessage)) { + throw BluePrintException("Resource Assignment Validation Failure") + } + } catch (e: Exception) { + throw BluePrintException("Resource Assignment Validation :" + validationMessage.toString(), e) + } + return true + } + + open fun validateSources(resourceAssignments: List) { + log.info("validating resource assignment sources") + } + + open fun validateTemplateNDictionaryKeys(resourceAssignments: List) { + + resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap() + + val duplicateKeyNames = resourceAssignments.groupBy { it.name } + .filter { it.value.size > 1 } + .map { it.key } + + if (duplicateKeyNames.isNotEmpty()) { + validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames)) + } + + val duplicateDictionaryKeyNames = resourceAssignments.groupBy { it.dictionaryName } + .filter { it.value.size > 1 } + .map { it.key } + if (duplicateDictionaryKeyNames.isNotEmpty()) { + validationMessage.appendln(String.format("Duplicate Assignment Dictionary Keys (%s) is Present", duplicateDictionaryKeyNames)) + } + + val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten() + + log.info("Resource assignment definitions : {}", resourceAssignmentMap.keys) + log.info("Resource assignment Dictionary dependencies : {}", dependenciesNames) + + val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct() + if (notPresentDictionaries.isNotEmpty()) { + validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries)) + } + + if (StringUtils.isNotBlank(validationMessage)) { + throw BluePrintException("Resource Assignment Validation Failure") + } + } + + open fun validateCyclicDependency(resourceAssignments: List) { + val startResourceAssignment = ResourceAssignment() + startResourceAssignment.name = "*" + + val topologySorting = TopologicalSortingUtils() + + resourceAssignmentMap.map { it.value }.map { resourceAssignment -> + if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { + resourceAssignment.dependencies!!.map { + log.info("Topological Graph link from {} to {}", it, resourceAssignment.name) + topologySorting.add(resourceAssignmentMap[it]!!, resourceAssignment) + } + } else { + topologySorting.add(startResourceAssignment, resourceAssignment) + } + } + + if (!topologySorting.isDag) { + val graph = getTopologicalGraph(topologySorting) + validationMessage.appendln("Cyclic Dependency :$graph") + } + } + + open fun getTopologicalGraph(topologySorting: TopologicalSortingUtils): String { + val s = StringBuilder() + val neighbors = topologySorting.getNeighbors() + + neighbors.forEach { v, vs -> + if (v.name == "*") { + s.append("\n * -> [") + for (resourceAssignment in vs) { + s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + + "),") + } + s.append("]") + } else { + s.append("\n (" + v.dictionaryName + ":" + v.name + ") -> [") + for (resourceAssignment in vs) { + s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + + "),") + } + s.append("]") + } + } + return s.toString() + } + + +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt new file mode 100644 index 000000000..d51338caf --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -0,0 +1,61 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import reactor.core.publisher.Mono +/** + * ResourceDefinitionRepoService. + * + * @author Brinda Santh + */ +interface ResourceDefinitionRepoService : BluePrintRepoService { + + fun getResourceDefinition(resourceDefinitionName: String): Mono? +} + +/** + * ResourceDefinitionFileRepoService. + * + * @author Brinda Santh + */ +open class ResourceDefinitionFileRepoService : BluePrintRepoFileService, + ResourceDefinitionRepoService { + + private var resourceDefinitionPath: String + private val extension = ".json" + + constructor(basePath: String) : this(basePath, + basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE)) + + constructor(basePath: String, modelTypePath: String) : super(modelTypePath) { + resourceDefinitionPath = basePath.plus("/resource_dictionary") + } + + override fun getResourceDefinition(resourceDefinitionName: String): Mono? { + + val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(resourceDefinitionName).plus(extension) + + return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java) + } +} diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt new file mode 100644 index 000000000..14855d4b6 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -0,0 +1,114 @@ +/* + * Copyright © 2018 IBM. + * Modifications Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import com.fasterxml.jackson.databind.JsonNode +import com.google.common.base.Preconditions +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import com.att.eelf.configuration.EELFManager +import java.io.Serializable +/** + * ResourceDefinitionValidationService. + * + * @author Brinda Santh + */ +interface ResourceDefinitionValidationService : Serializable { + + @Throws(BluePrintException::class) + fun validate(resourceDefinition: ResourceDefinition) + +} +/** + * ResourceDefinitionValidationService. + * + * @author Brinda Santh + */ +open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java) + + override fun validate(resourceDefinition: ResourceDefinition) { + Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition") + log.trace("Validating Resource Dictionary Definition {}", resourceDefinition.name) + + resourceDefinition.sources.forEach { (name, nodeTemplate) -> + val sourceType = nodeTemplate.type + + val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)?.block() + ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType)) + + // Validate Property Name, expression, values and Data Type + validateNodeTemplateProperties(nodeTemplate, sourceNodeType) + } + } + + + open fun validateNodeTemplateProperties(nodeTemplate: NodeTemplate, nodeType: NodeType) { + nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } + } + + + open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, + properties: MutableMap) { + properties.forEach { propertyName, propertyAssignment -> + val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] + ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyDefinition, propertyName, propertyAssignment) + } else { + throw BluePrintException(format("property({}) of expression ({}) is not supported", + propertyName, propertyAssignment)) + } + } + } + + open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) { + val propertyType = propertyDefinition.type + val isValid : Boolean + + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) + } else { + bluePrintRepoService.getDataType(propertyType) + ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository", + propertyName, propertyType)) + isValid = true + } + + check(isValid) { + throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})", + propertyName, propertyType, propertyAssignment)) + } + } +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt new file mode 100644 index 000000000..747639c89 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -0,0 +1,109 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils + +import com.att.eelf.configuration.EELFLogger +import org.apache.commons.collections.CollectionUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import com.att.eelf.configuration.EELFManager +import java.util.ArrayList +/** + * BulkResourceSequencingUtils. + * + * @author Brinda Santh + */ +object BulkResourceSequencingUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java) + + @JvmStatic + fun process(resourceAssignments: MutableList): List> { + val resourceAssignmentMap: MutableMap = hashMapOf() + val sequenceBatchResourceAssignment = ArrayList>() + log.info("Assignments ({})", resourceAssignments) + // Prepare Map + resourceAssignments.forEach { resourceAssignment -> + log.trace("Processing Key ({})", resourceAssignment.name) + resourceAssignmentMap.put(resourceAssignment.name, resourceAssignment) + } + + val startResourceAssignment = ResourceAssignment() + startResourceAssignment.name = "*" + + // Preepare Sorting Map + val topologySorting = TopologicalSortingUtils() + resourceAssignmentMap.forEach { _, resourceAssignment -> + if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { + for (dependency in resourceAssignment.dependencies!!) { + topologySorting.add(resourceAssignmentMap[dependency]!!, resourceAssignment) + } + } else { + topologySorting.add(startResourceAssignment, resourceAssignment) + } + } + + val sequencedResourceAssignments: MutableList = topologySorting.topSort()!! as MutableList + log.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments) + + var batchResourceAssignment: MutableList? = null + var batchAssignmentName: MutableList? = null + + // Prepare Sorting + sequencedResourceAssignments.forEachIndexed { index, resourceAssignment -> + + var previousResourceAssignment: ResourceAssignment? = null + + if (index > 0) { + previousResourceAssignment = sequencedResourceAssignments[index - 1] + } + + var dependencyPresence = false + if (batchAssignmentName != null && resourceAssignment.dependencies != null) { + dependencyPresence = CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.dependencies) + } + + log.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name, + batchAssignmentName, resourceAssignment.dependencies, dependencyPresence) + + if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null + && resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true) + && !dependencyPresence) { + batchResourceAssignment!!.add(resourceAssignment) + batchAssignmentName!!.add(resourceAssignment.name) + } else { + if (batchResourceAssignment != null) { + sequenceBatchResourceAssignment.add(batchResourceAssignment!!) + log.trace("Created old Set ({})", batchAssignmentName) + } + batchResourceAssignment = arrayListOf() + batchResourceAssignment!!.add(resourceAssignment) + + batchAssignmentName = arrayListOf() + batchAssignmentName!!.add(resourceAssignment.name) + } + + if (index == sequencedResourceAssignments.size - 1) { + log.trace("Created old Set ({})", batchAssignmentName) + sequenceBatchResourceAssignment.add(batchResourceAssignment!!) + } + } + log.info("Batched Sequence : ({})", sequenceBatchResourceAssignment) + + return sequenceBatchResourceAssignment + } + +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt new file mode 100644 index 000000000..a3456cd43 --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -0,0 +1,78 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils + +import com.att.eelf.configuration.EELFLogger +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.apache.commons.collections.MapUtils +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants +import com.att.eelf.configuration.EELFManager + + +object ResourceDictionaryUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java) + + @JvmStatic + fun populateSourceMapping(resourceAssignment: ResourceAssignment, + resourceDefinition: ResourceDefinition) { + + if (StringUtils.isBlank(resourceAssignment.dictionarySource)) { + + if (MapUtils.isNotEmpty(resourceDefinition.sources)) { + val source = findFirstSource(resourceDefinition.sources) + + // Populate and Assign First Source + if (StringUtils.isNotBlank(source)) { + // Set Dictionary Source + resourceAssignment.dictionarySource = source + } else { + resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT + } + log.info("auto map resourceAssignment : {}", resourceAssignment) + }else { + resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT + } + } + } + + @JvmStatic + fun findFirstSource(sources: Map): String? { + var source: String? = null + if (MapUtils.isNotEmpty(sources)) { + source = sources.keys.stream().findFirst().get() + } + return source + } + + @JvmStatic + fun assignInputs(data: JsonNode, context: MutableMap) { + log.trace("assignInputs from input JSON ({})", data.toString()) + data.fields().forEach { field -> + val valueNode: JsonNode = data.at("/".plus(field.key)) ?: NullNode.getInstance() + + val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(field.key) + log.trace("setting path ({}), values ({})", path, valueNode) + context[path] = valueNode + } + } +} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java new file mode 100644 index 000000000..fde800057 --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class ResourceDefinitionTest { + private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class); + private String basePath = "load/resource_dictionary"; + + @Test + public void testDictionaryDefinitionInputSource(){ + + String fileName = basePath + "/input-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDefaultSource(){ + + String fileName = basePath + "/default-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDBSource(){ + + String fileName = basePath + "/db-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionMDSALSource(){ + String fileName = basePath + "/mdsal-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); + } +} diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java new file mode 100644 index 000000000..57c8509d1 --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; + +import java.util.List; + +/** + * ResourceAssignmentEnhancerService. + * + * @author Brinda Santh + */ +public class ResourceAssignmentEnhancerServiceTest { + + @Test + public void testEnhanceBluePrint() throws BluePrintException { + + List resourceAssignments = JacksonReactorUtils + .getListFromClassPathFile("enrich/simple-enrich.json", ResourceAssignment.class).block(); + Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments); + ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load"); + ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = + new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService); + ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments); + Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate); + } +} + diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt new file mode 100644 index 000000000..6216d5bf0 --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -0,0 +1,57 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import org.junit.Assert +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import com.att.eelf.configuration.EELFManager +/** + * ResourceAssignmentValidationServiceTest. + * + * @author Brinda Santh + */ +class ResourceAssignmentValidationServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) + @Test + fun testValidateSuccess() { + log.info("**************** testValidateSuccess *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService() + val result = resourceAssignmentValidator.validate(assignments!!) + Assert.assertTrue("Failed to Validate", result) + } + + @Test(expected = BluePrintException::class) + fun testValidateDuplicate() { + log.info(" **************** testValidateDuplicate *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService() + resourceAssignmentValidator.validate(assignments!!) + } + + @Test(expected = BluePrintException::class) + fun testValidateCyclic() { + log.info(" **************** testValidateCyclic *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService() + resourceAssignmentValidator.validate(assignments!!) + } +} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java new file mode 100644 index 000000000..1772277df --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; + +public class ResourceDefinitionRepoServiceTest { + + @Test + public void testGetResourceDefinition() throws Exception{ + ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load"); + ResourceDefinition resourceDefinition = resourceDefinitionRepoService + .getResourceDefinition("db-source").block(); + Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition); + + NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block(); + Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition); + } +} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java new file mode 100644 index 000000000..ef305627f --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java @@ -0,0 +1,56 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; + +public class ResourceDefinitionValidationServiceTest { + private String basePath = "load/model_type"; + private String dictionaryPath = "load/resource_dictionary"; + private BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath); + + @Test + public void testValidateSource() throws Exception { + + String inputFileName = dictionaryPath + "/db-source.json"; + testValidate(inputFileName); + + String dbFileName = dictionaryPath + "/db-source.json"; + testValidate(dbFileName); + + String defaultFileName = dictionaryPath + "/default-source.json"; + testValidate(defaultFileName); + + String restFileName = dictionaryPath + "/mdsal-source.json"; + testValidate(restFileName); + } + + private void testValidate(String fileName) throws Exception { + + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition); + + ResourceDefinitionValidationService resourceDictionaryValidationService = + new ResourceDefinitionDefaultValidationService(bluePrintRepoFileService); + resourceDictionaryValidationService.validate(resourceDefinition); + Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition); + } +} diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java new file mode 100644 index 000000000..c7444dbae --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import java.util.List; +/** + * BulkResourceSequencingUtils. + * + * @author Brinda Santh + */ +public class BulkResourceSequencingUtilsTest { + + @Test + public void testProcess(){ + List assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); + Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); + BulkResourceSequencingUtils.process(assignments); + } +} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java new file mode 100644 index 000000000..13bf8195e --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -0,0 +1,99 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils; + + +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.HashMap; +import java.util.Map; +/** + * ResourceDictionaryUtilsTest. + * + * @author Brinda Santh + */ +public class ResourceDictionaryUtilsTest { + private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); + + @Test + public void testPopulateSourceMapping() { + + ResourceAssignment resourceAssignment = new ResourceAssignment(); + resourceAssignment.setName("sample-assignment"); + ResourceDefinition resourceDefinition = new ResourceDefinition(); + Map sources = new HashMap<>(); + resourceDefinition.setSources(sources); + // To Check Empty Source + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource()); + + // To Check First Source + resourceAssignment.setDictionarySource(null); + sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate()); + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); + + // To Check Assigned Source + resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_DB); + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_DB, resourceAssignment.getDictionarySource()); + + } + + @Test + public void testFindFirstSource() { + //To check if Empty Source + Map sources = new HashMap<>(); + String firstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertNull("Source populated, which is not expected.", firstSource); + + // TO check the first Source + sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate()); + String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); + + // TO check the multiple Source + sources.put(ResourceDictionaryConstants.SOURCE_DB, new NodeTemplate()); + String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); + + } + + @Test + public void testAssignInputs() { + JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); + Map context = new HashMap<>(); + ResourceDictionaryUtils.assignInputs(data, context); + String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue"); + log.info("populated context {}", context); + Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path)); + + } + + +} diff --git a/components/resource-dict/src/test/resources/data/resource-assignment-input.json b/components/resource-dict/src/test/resources/data/resource-assignment-input.json new file mode 100644 index 000000000..d79c90682 --- /dev/null +++ b/components/resource-dict/src/test/resources/data/resource-assignment-input.json @@ -0,0 +1,10 @@ +{ + "intValue" : 1, + "floatValue" : 1.34, + "booleanValue" : true, + "stringValue" : "sample-String", + "timeValue" : "2018-09-29", + "arrayStringValue" : ["one", "two"], + "mapValue" : {"profile_name1":"profile_name1", + "profile_name2":"profile_name2"} +} \ No newline at end of file diff --git a/components/resource-dict/src/test/resources/enrich/simple-enrich.json b/components/resource-dict/src/test/resources/enrich/simple-enrich.json new file mode 100644 index 000000000..641da80a2 --- /dev/null +++ b/components/resource-dict/src/test/resources/enrich/simple-enrich.json @@ -0,0 +1,37 @@ +[ + { + "name": "rs-db-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "db-source", + "dictionary-source": "db", + "dependencies": [ + "input-source" + ] + }, + { + "name": "ra-default-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "default-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "ra-input-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + } +] diff --git a/components/resource-dict/src/test/resources/validation/cyclic.json b/components/resource-dict/src/test/resources/validation/cyclic.json new file mode 100644 index 000000000..d837dc5d8 --- /dev/null +++ b/components/resource-dict/src/test/resources/validation/cyclic.json @@ -0,0 +1,111 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "bundle-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-id", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-ip", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-ip", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id", + "bundle-id" + ] + }, + { + "name": "managed-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip", + "dictionary-source": "mdsal", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "vnf-name", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-name", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "managed-ip1", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip1", + "dictionary-source": "mdsal", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "loopback-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "loopback-ip", + "dictionary-source": "db", + "dependencies": [ + "bundle-mac", + "managed-ip1" + ] + } +] diff --git a/components/resource-dict/src/test/resources/validation/duplicate.json b/components/resource-dict/src/test/resources/validation/duplicate.json new file mode 100644 index 000000000..330324cda --- /dev/null +++ b/components/resource-dict/src/test/resources/validation/duplicate.json @@ -0,0 +1,110 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "bundle-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-id", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-ip", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-ip", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id", + "bundle-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "mdsal", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "vnf-name", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-name", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "managed-ip1", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip1", + "dictionary-source": "mdsal", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "loopback-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "loopback-ip", + "dictionary-source": "db", + "dependencies": [ + "bundle-mac" + ] + } +] diff --git a/components/resource-dict/src/test/resources/validation/success.json b/components/resource-dict/src/test/resources/validation/success.json new file mode 100644 index 000000000..3215d06d7 --- /dev/null +++ b/components/resource-dict/src/test/resources/validation/success.json @@ -0,0 +1,110 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "bundle-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-id", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-ip", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-ip", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "mdsal", + "dependencies": [ + "vnf-id", + "bundle-id" + ] + }, + { + "name": "managed-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip", + "dictionary-source": "mdsal", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "vnf-name", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-name", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "managed-ip1", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip1", + "dictionary-source": "mdsal", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "loopback-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "loopback-ip", + "dictionary-source": "db", + "dependencies": [ + "bundle-mac" + ] + } +] -- cgit 1.2.3-korg From 5996f186c7c195bf2d4e1b1874c7784cdaa00e39 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 5 Sep 2018 01:22:04 -0400 Subject: Controller Blueprints Microservice Add Resource Dictionary reactive repository service for dictionary validation and automap functions. Change-Id: I7cc6d7d976cfe9370f9a74cd8f2e4256de8e8995 Issue-ID: CCSDK-484 Signed-off-by: Brinda Santh --- .../resource/dict/service/ResourceDefinitionRepoService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt index d51338caf..370e1ec8c 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +30,7 @@ import reactor.core.publisher.Mono */ interface ResourceDefinitionRepoService : BluePrintRepoService { - fun getResourceDefinition(resourceDefinitionName: String): Mono? + fun getResourceDefinition(resourceDefinitionName: String): Mono } /** @@ -51,7 +52,7 @@ open class ResourceDefinitionFileRepoService : BluePrintRepoFileService, resourceDefinitionPath = basePath.plus("/resource_dictionary") } - override fun getResourceDefinition(resourceDefinitionName: String): Mono? { + override fun getResourceDefinition(resourceDefinitionName: String): Mono { val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER) .plus(resourceDefinitionName).plus(extension) -- cgit 1.2.3-korg From e2ed7eb15fdda46c51f08eeb688fcc75ef45098b Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 5 Sep 2018 17:42:22 +0000 Subject: Controller Blueprints Microservice Modify Model Type and Resource Defintions persistance and access from String to JSON type for easy handling. Change-Id: Icfe7e95abad715b0ccad16c681ed057d289a6229 Issue-ID: CCSDK-431 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 5075e7261..cf5f9e20c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -49,6 +49,11 @@ object JacksonUtils { return jacksonObjectMapper().readValue(content, valueType) } + @JvmStatic + fun readValue(node: JsonNode, valueType: Class): T? { + return jacksonObjectMapper().treeToValue(node, valueType) + } + @JvmStatic fun getContent(fileName: String): String { return File(fileName).readText(Charsets.UTF_8) -- cgit 1.2.3-korg From 7a9879297e324ac0eb08ff5422dce31436bf10f6 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 5 Sep 2018 23:40:46 +0000 Subject: Controller Blueprints Microservice Add Property Assign validation and Data Type Entry schema validation. Change-Id: Ifa40f62f848d06381ab83d7f1c9e7c6526f5edf0 Issue-ID: CCSDK-484 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../Definitions/activation-blueprint.json | 33 +----- .../Definitions/simple-baseconfig.json | 4 +- .../node_type/component-resource-assignment.json | 2 +- .../model_type/node_type/dg-activate-netconf.json | 2 +- .../model_type/node_type/dg-config-generator.json | 2 +- .../node_type/dg-resource-assign-activate.json | 2 +- .../node_type/dg-resource-assignment.json | 2 +- .../node_type/tosca.nodes.Component.json | 5 + .../load/model_type/node_type/tosca.nodes.DG.json | 5 + .../load/model_type/node_type/tosca.nodes.Vnf.json | 5 + .../node_type/tosca.nodes.component.Python.json | 5 + .../core/BluePrintConstants.kt | 2 + .../controllerblueprints/core/BluePrintTypes.kt | 27 +++++ .../core/service/BluePrintValidatorService.kt | 129 ++++++++++++++------- 14 files changed, 144 insertions(+), 81 deletions(-) create mode 100644 components/core/load/model_type/node_type/tosca.nodes.Component.json create mode 100644 components/core/load/model_type/node_type/tosca.nodes.DG.json create mode 100644 components/core/load/model_type/node_type/tosca.nodes.Vnf.json create mode 100644 components/core/load/model_type/node_type/tosca.nodes.component.Python.json diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json index 635e177a1..7b9b7dd71 100644 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -44,7 +44,7 @@ "resource-assignment": { "type": "component-resource-assignment", "properties":{ - "request-id": ["1234", "1234"] + "request-id": "1234" }, "interfaces": { "DefaultComponentNode": { @@ -80,7 +80,7 @@ "resource-assignment-py": { "type": "component-resource-assignment", "properties":{ - "request-id": ["1234", "1234"] + "request-id": "1234" }, "interfaces": { "DefaultComponentNode": { @@ -256,35 +256,6 @@ "tosca.nodes.component.Python": { "description": "This is Resource Assignment Python Component API", "version": "1.0.0", - "properties": { - "type": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": false, - "type": "string" - } - }, - "interfaces": { - "DefaultOperation": { - "operations": { - "validate": { - "inputs": { - "action-name": { - "description": "validate for action", - "required": false, - "type": "string" - } - } - } - } - } - }, - "artifacts" :{ - "component-jar": { - "description": "Component Jar", - "type": "artifact-component-jar", - "file": "Component/basecomponent.jar" - } - }, "derived_from": "tosca.nodes.Root" }, "component-resource-assignment": { diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json index e78f32f02..65028ace0 100644 --- a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json +++ b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json @@ -117,7 +117,7 @@ "properties": { "mode": "sync", "version": "LATEST", - "is-start-flow": "false" + "is-start-flow": false }, "requirements": { "component-dependency": { @@ -151,7 +151,7 @@ "properties": { "mode": "sync", "version": "LATEST", - "is-start-flow": "false" + "is-start-flow": false }, "requirements": { "component-dependency": { diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json index 34c028482..03f3c2845 100644 --- a/components/core/load/model_type/node_type/component-resource-assignment.json +++ b/components/core/load/model_type/node_type/component-resource-assignment.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": { + "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { diff --git a/components/core/load/model_type/node_type/dg-activate-netconf.json b/components/core/load/model_type/node_type/dg-activate-netconf.json index c638df00c..a9d16eddc 100644 --- a/components/core/load/model_type/node_type/dg-activate-netconf.json +++ b/components/core/load/model_type/node_type/dg-activate-netconf.json @@ -15,7 +15,7 @@ "is-start-flow": { "required": false, "type": "boolean", - "default": "false" + "default": false } }, "capabilities": { diff --git a/components/core/load/model_type/node_type/dg-config-generator.json b/components/core/load/model_type/node_type/dg-config-generator.json index 28bace0f0..6794b3c89 100644 --- a/components/core/load/model_type/node_type/dg-config-generator.json +++ b/components/core/load/model_type/node_type/dg-config-generator.json @@ -15,7 +15,7 @@ "is-start-flow": { "required": false, "type": "boolean", - "default": "false" + "default": false } }, "capabilities": { diff --git a/components/core/load/model_type/node_type/dg-resource-assign-activate.json b/components/core/load/model_type/node_type/dg-resource-assign-activate.json index e98fa5a67..22a4d813c 100644 --- a/components/core/load/model_type/node_type/dg-resource-assign-activate.json +++ b/components/core/load/model_type/node_type/dg-resource-assign-activate.json @@ -15,7 +15,7 @@ "is-start-flow": { "required": false, "type": "boolean", - "default": "false" + "default": false } }, "capabilities": { diff --git a/components/core/load/model_type/node_type/dg-resource-assignment.json b/components/core/load/model_type/node_type/dg-resource-assignment.json index 36fbb6861..7c01faa13 100644 --- a/components/core/load/model_type/node_type/dg-resource-assignment.json +++ b/components/core/load/model_type/node_type/dg-resource-assignment.json @@ -15,7 +15,7 @@ "is-start-flow": { "required": false, "type": "boolean", - "default": "false" + "default": false } }, "capabilities": { diff --git a/components/core/load/model_type/node_type/tosca.nodes.Component.json b/components/core/load/model_type/node_type/tosca.nodes.Component.json new file mode 100644 index 000000000..bc4827b8b --- /dev/null +++ b/components/core/load/model_type/node_type/tosca.nodes.Component.json @@ -0,0 +1,5 @@ +{ + "description": "This is default Component Node", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.DG.json b/components/core/load/model_type/node_type/tosca.nodes.DG.json new file mode 100644 index 000000000..86728cf2f --- /dev/null +++ b/components/core/load/model_type/node_type/tosca.nodes.DG.json @@ -0,0 +1,5 @@ +{ + "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/core/load/model_type/node_type/tosca.nodes.Vnf.json b/components/core/load/model_type/node_type/tosca.nodes.Vnf.json new file mode 100644 index 000000000..acb1f2f31 --- /dev/null +++ b/components/core/load/model_type/node_type/tosca.nodes.Vnf.json @@ -0,0 +1,5 @@ +{ + "description": "This is VNF Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.component.Python.json b/components/core/load/model_type/node_type/tosca.nodes.component.Python.json new file mode 100644 index 000000000..7b67c8cb2 --- /dev/null +++ b/components/core/load/model_type/node_type/tosca.nodes.component.Python.json @@ -0,0 +1,5 @@ +{ + "description": "This is Python Component", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 4ae1f4d5d..ffad8e561 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -94,6 +94,8 @@ object BluePrintConstants { const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" + const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION ="tosca.artifacts.Implementation" + const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" const val EXPRESSION_GET_INPUT: String = "get_input" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index 33c811f4a..af3966aad 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -23,6 +23,33 @@ package org.onap.ccsdk.apps.controllerblueprints.core */ object BluePrintTypes { + @JvmStatic + val validNodeTypeDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_NODES_ROOT, + BluePrintConstants.MODEL_TYPE_NODE_DG, + BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, + BluePrintConstants.MODEL_TYPE_NODE_VNF, + BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT, + BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT + ) + + @JvmStatic + val validArtifactTypeDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_ARTIFACTS_ROOT, + BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION + ) + + @JvmStatic + val validDataTypeDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, + BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC + ) + @JvmStatic fun validModelTypes(): List { val validTypes: MutableList = arrayListOf() diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 34399fdd2..a3b68e0dd 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.* import org.onap.ccsdk.apps.controllerblueprints.core.data.* import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import java.io.Serializable /** @@ -52,7 +53,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class) override fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) { - validateBlueprint(bluePrintContext.serviceTemplate,properties) + validateBlueprint(bluePrintContext.serviceTemplate, properties) } @Throws(BluePrintException::class) @@ -121,7 +122,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { paths.add("nodeTypes") nodeTypes.forEach { nodeTypeName, nodeType -> // Validate Single Node Type - validateNodeType(nodeTypeName,nodeType) + validateNodeType(nodeTypeName, nodeType) } paths.removeAt(paths.lastIndex) } @@ -132,13 +133,20 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { message.appendln("--> Node Type :" + paths.joinToString(separator)) val derivedFrom: String = nodeType.derivedFrom //Check Derived From - checkValidNodeTypesDerivedFrom(derivedFrom) + checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) } nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } paths.removeAt(paths.lastIndex) } + @Throws(BluePrintException::class) + open fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get node type ({})'s derived from({}) definition ", nodeTypeName, derivedFrom)) + } + } + @Throws(BluePrintException::class) open fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { paths.add("topology") @@ -167,7 +175,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } @Throws(BluePrintException::class) - open fun validateNodeTemplate(nodeTemplateName : String, nodeTemplate: NodeTemplate) { + open fun validateNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { paths.add(nodeTemplateName) message.appendln("---> Node Template :" + paths.joinToString(separator)) val type: String = nodeTemplate.type @@ -183,6 +191,25 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { paths.removeAt(paths.lastIndex) } + @Throws(BluePrintException::class) + open fun validateArtifactDefinitions(artifacts: MutableMap) { + paths.add("artifacts") + artifacts.forEach { artifactDefinitionName, artifactDefinition -> + paths.add(artifactDefinitionName) + message.appendln("Validating artifact " + paths.joinToString(separator)) + val type: String = artifactDefinition.type + ?: throw BluePrintException("type is missing for artifact definition :" + artifactDefinitionName) + // Check Artifact Type + checkValidArtifactType(artifactDefinitionName, type) + + val file: String = artifactDefinition.file + ?: throw BluePrintException(format("file is missing for artifact definition : {}", artifactDefinitionName)) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + @Throws(BluePrintException::class) open fun validateWorkFlows(workflows: MutableMap) { paths.add("workflows") @@ -195,7 +222,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } @Throws(BluePrintException::class) - open fun validateWorkFlow(workflowName:String, workflow: Workflow) { + open fun validateWorkFlow(workflowName: String, workflow: Workflow) { paths.add(workflowName) message.appendln("---> Workflow :" + paths.joinToString(separator)) // Step Validation Start @@ -239,31 +266,20 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { properties.forEach { propertyName, propertyAssignment -> val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) - // Check and Validate if Expression Node - val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) - if (!expressionData.isExpression) { - checkPropertyValue(propertyDefinition, propertyAssignment) - } + + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } } @Throws(BluePrintException::class) - open fun validateArtifactDefinitions(artifacts: MutableMap) { - paths.add("artifacts") - artifacts.forEach { artifactName, artifactDefinition -> - paths.add(artifactName) - message.appendln("Validating artifact " + paths.joinToString(separator)) - val type: String = artifactDefinition.type - ?: throw BluePrintException("type is missing for artifact definition :" + artifactName) - // Check Artifact Type - checkValidArtifactType(type) - - val file: String = artifactDefinition.file - ?: throw BluePrintException(format("file is missing for artifact definition : {}", artifactName)) - - paths.removeAt(paths.lastIndex) + open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition, + propertyAssignment: JsonNode) { + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) } - paths.removeAt(paths.lastIndex) } @Throws(BluePrintException::class) @@ -313,34 +329,65 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } @Throws(BluePrintException::class) - open fun checkValidNodeType(nodeType : String) { + open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { + + val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: throw BluePrintException(format("Failed to artifact type for artifact definition : {}", artifactDefinitionName)) + checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) } @Throws(BluePrintException::class) - open fun checkValidArtifactType(artifactType: String) { - - serviceTemplate.artifactTypes?.containsKey(artifactType) - ?: throw BluePrintException(format("Failed to node type definition for artifact definition : {}", artifactType)) + open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get artifact type ({})'s derived from({}) definition ", artifactTypeName, derivedFrom)) + } } @Throws(BluePrintException::class) - open fun checkValidNodeTypesDerivedFrom(derivedFrom: String) { - + open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get data type ({})'s derived from({}) definition ", dataTypeName, derivedFrom)) + } } - private fun checkPropertyValue(propertyDefinition: PropertyDefinition, jsonNode: JsonNode) { - //log.info("validating path ({}), Property {}, value ({})", paths, propertyDefinition, jsonNode) - } + open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { + val propertyType = propertyDefinition.type + val isValid: Boolean + + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) + val entrySchemaType = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Failed to get Entry Schema type for the collection property ({})", propertyName)) + + if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { + checkPropertyDataType(entrySchemaType, propertyName) + } - private fun checkPropertyDataType(dataType: String, propertyName: String): Boolean { - if (checkDataType(dataType)) { - return true } else { - throw BluePrintException(format("Data type ({}) for the property ({}) not found", dataType, propertyName)) + checkPropertyDataType(propertyType, propertyName) + isValid = true + } + + check(isValid) { + throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})", + propertyName, propertyType, propertyAssignment)) } } + private fun checkPropertyDataType(dataType: String, propertyName: String) { + + val dataType = serviceTemplate.dataTypes?.get(dataType) + ?: throw BluePrintException(format("Data type ({}) for the property ({}) not found", dataType, propertyName)) + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + + } + private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { return true @@ -353,8 +400,4 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { return serviceTemplate.dataTypes?.containsKey(key) ?: false } - private fun checkNodeType(key: String): Boolean { - return serviceTemplate.nodeTypes?.containsKey(key) ?: false - } - } \ No newline at end of file -- cgit 1.2.3-korg From e7f37ab7283160ef1b2a9ea02a8dcdfa0aad22c0 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 5 Sep 2018 21:47:01 -0400 Subject: Controller Blueprints Microservice Add Controller Blueprint NodeTemplate Interface, Operation, Input and Output validation Change-Id: I6fae38cc8a4a36ddacc93bcea4b0061f846c6aba Issue-ID: CCSDK-484 Signed-off-by: Brinda Santh --- .../core/service/BluePrintValidatorService.kt | 69 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index a3b68e0dd..a60f532e0 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -187,7 +188,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeTemplate.capabilities!!) } nodeTemplate.requirements?.let { validateRequirementAssignments(nodeTemplate.requirements!!) } - nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeTemplate.interfaces!!) } + nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } paths.removeAt(paths.lastIndex) } @@ -293,10 +294,71 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } @Throws(BluePrintException::class) - open fun validateInterfaceAssignments(interfaces: MutableMap) { + open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + val interfaces = nodeTemplate.interfaces + paths.add("interfaces") + interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> + paths.add(interfaceAssignmentName) + val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) + ?: throw BluePrintException(format("Failed to get nodeTemplate({}) interface definition ({}) from" + + " node type ({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type)) + + validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + @Throws(BluePrintException::class) + open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + } + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + it.forEach { operationAssignmentName, operationAssignments -> + + val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) + ?: throw BluePrintException(format("Failed to get nodeTemplate({}) operation definition ({}) ", + nodeTemplateName, operationAssignmentName)) + + log.info("Validation Node Template({}) Interface({}) Operation ({})", nodeTemplateName, + interfaceAssignmentName, operationAssignmentName) + + val inputs = operationAssignments.inputs + val outputs = operationAssignments.outputs + + inputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.inputs?.get(propertyName) + ?: throw BluePrintException(format("Failed to get nodeTemplate({}) operation definition ({}) " + + "property definition({})", nodeTemplateName, operationAssignmentName, propertyName)) + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + } + } + + } + + @Throws(BluePrintException::class) open fun validateInterfaceDefinitions(interfaces: MutableMap) { paths.add("interfaces") @@ -360,14 +422,13 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { - isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) val entrySchemaType = propertyDefinition.entrySchema?.type ?: throw BluePrintException(format("Failed to get Entry Schema type for the collection property ({})", propertyName)) if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { checkPropertyDataType(entrySchemaType, propertyName) } - + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) } else { checkPropertyDataType(propertyType, propertyName) isValid = true -- cgit 1.2.3-korg From c8c4cd151732fa6e9be45f403244de307456b923 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 6 Sep 2018 20:18:24 +0000 Subject: Controller Blueprints Microservice Add Blueprint Dervied from NodeType, Requirement Definitions and Assignments validations. Change-Id: I1cc643b5a83c5a707c8e3ae1342a439f122da55e Issue-ID: CCSDK-484 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../Definitions/activation-blueprint.json | 396 ++++++++++++--------- .../model_type/node_type/tosca.nodes.Artifact.json | 5 + .../controllerblueprints/core/BluePrintTypes.kt | 10 + .../core/service/BluePrintEnhancerService.kt | 20 +- .../core/service/BluePrintValidatorService.kt | 130 +++++-- .../core/service/BluePrintRuntimeServiceTest.kt | 38 +- .../src/test/resources/data/default-context.json | 2 + 7 files changed, 382 insertions(+), 219 deletions(-) create mode 100644 components/core/load/model_type/node_type/tosca.nodes.Artifact.json diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json index 7b9b7dd71..3eb4fedcb 100644 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -2,7 +2,7 @@ "metadata": { "template_author": "Brinda Santh Muthuramalingam", "author-email": "brindasanth@gmail.com", - "user-groups" : "ADMIN, OPERATION", + "user-groups": "ADMIN, OPERATION", "template_name": "baseconfiguration", "template_version": "1.0.0", "template_tags": "brinda, tosca" @@ -24,121 +24,125 @@ "hostname": { "required": true, "type": "string" + }, + "template_name": { + "required": true, + "type": "string" + }, + "template_version": { + "required": true, + "type": "string" } }, "node_templates": { - "activate-process": { - "type": "bpmn-activate", - "properties": { - "process-name": { "get_input" : "action-name" }, - "version" : { "get_property" : ["SELF", "process-name"] }, - "content": { "get_artifact" : ["SELF", "activate-process"] } - }, - "artifacts": { - "activate-process": { - "type": "artifact-bpmn-camunda", - "file": "Plans/ActivateProcess.bpmn" - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "properties":{ - "request-id": "1234" + "resource-assignment-ra-component": { + "capabilities": { + "component-node": {} }, "interfaces": { - "DefaultComponentNode": { + "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { - "action-name": { "get_input" : "action-name" }, + "template-names": [ + "base-config-template", + "licence-template" + ], + "action-name": { + "get_input": "action-name" + }, + "template-name": { + "get_input": "template_name" + }, + "template-version": { + "get_input": "template_version" + }, "resource-type": "vnf-type", - "request-id": { "get_input" : "request-id" }, - "resource-id": { "get_input" : "hostname" }, - "template-content": { "get_artifact" : ["SELF", "baseconfig-template"] }, - "mapping-content": { "get_artifact" : ["SELF", "baseconfig-mapping"] } + "request-id": { + "get_input": "request-id" + }, + "resource-id": { + "get_input": "hostname" + } }, "outputs": { - "resource-assignment-params": "", - "status": "" + "resource-assignment-params": "success", + "status": "status" } } } } }, - "artifacts": { - "baseconfig-template": { - "type": "artifact-template-velocity", - "file": "Templates/baseconfig-template.vtl" + "type": "component-resource-assignment" + }, + "resource-assignment-action": { + "properties": { + "mode": "sync", + "version": { + "get_input": "template_version" }, - "baseconfig-mapping": { - "type": "artifact-mapping-resource", - "file": "Mappings/baseconfig-mapping.json" + "is-start-flow": false + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "resource-assignment-ra-component", + "relationship": "tosca.relationships.DependsOn" + } + }, + "capabilities": { + "dg-node": {}, + "content": { + "properties": { + "type": "json" + } } - } - }, - "resource-assignment-py": { - "type": "component-resource-assignment", - "properties":{ - "request-id": "1234" }, "interfaces": { - "DefaultComponentNode": { + "CONFIG": { "operations": { - "process": { - "implementation" :{ - "primary" : "component-script" - }, + "ResourceAssignment": { "inputs": { - "action-name": { "get_input" : "action-name" } - }, - "outputs": { - "resource-assignment-params": "", - "status": "" + "params": [] } } } } }, - "artifacts": { - "component-script": { - "type": "artifact-script-python", - "file": "Scripts/baseconfig-template.vtl" - } - } + "type": "dg-resource-assignment" } }, - "workflows":{ - "activate-process":{ - "steps" : { - "call-resource-assignment" : { - "description" : "Invoke Resource Assignment Component", - "target" : "resource-assignment", - "activities" : [ - { - "call_operation": "ResourceAssignmentNode.process" - } - ], - "on_success" : [ - "download-baseconfig" - ] - }, - "download-baseconfig" : { - "description" : "Call Download Base Config Component", - "target" : "activate-netconf", - "activities" : [ + "workflows": { + "activate-process": { + "steps": { + "call-resource-assignment": { + "description": "Invoke Resource Assignment Component", + "target": "resource-assignment", + "activities": [ + { + "call_operation": "ResourceAssignmentNode.process" + } + ], + "on_success": [ + "download-baseconfig" + ] + }, + "download-baseconfig": { + "description": "Call Download Base Config Component", + "target": "activate-netconf", + "activities": [ { "call_operation": "NetconfTransactionNode.process" } ], - "on_success" : [ + "on_success": [ "download-licence" ] }, - "download-licence" : { - "description" : "Call Download Licence Component", - "target" : "activate-netconf", - "activities" : [ + "download-licence": { + "description": "Call Download Licence Component", + "target": "activate-netconf", + "activities": [ { "call_operation": "NetconfTransactionNode.process" } @@ -199,106 +203,119 @@ } }, "node_types": { - "bpmn-activate": { - "description": "This is BPMN Activate node type", + "dg-resource-assignment": { + "description": "This is Resource Assignment Directed Graph", "version": "1.0.0", "properties": { - "content": { + "mode": { "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" + "type": "string", + "default": "sync" }, "version": { "required": false, "type": "string", - "default" : "LATEST" + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": false } }, - "derived_from": "tosca.nodes.Component" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "type": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": false, - "type": "string" + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + }, + "content": { + "type": "tosca.capability.Content", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "json" + }, + "content": { + "required": false, + "type": "string" + } + } + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-resource-assignment", + "relationship": "tosca.relationships.DependsOn" } }, "interfaces": { - "DefaultOperation": { + "CONFIG": { "operations": { - "validate": { + "ResourceAssignment": { "inputs": { - "action-name": { - "description": "validate for action", + "params": { "required": false, - "type": "string" + "type": "list", + "entry_schema": { + "type": "datatype-property" + } } } } } } }, - "artifacts" :{ - "component-jar": { - "description": "Component Jar", - "type": "artifact-component-jar", - "file": "Component/basecomponent.jar" - } - }, - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.component.Python": { - "description": "This is Resource Assignment Python Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" + "derived_from": "tosca.nodes.DG" }, "component-resource-assignment": { "description": "This is Resource Assignment Component API", "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" } }, "interfaces": { - "DefaultComponentNode": { + "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, + "description": "Action Name of the process", + "required": true, "type": "string" }, - "resource-type": { - "required": false, + "template-name": { + "description": "Service Template Name.", + "required": true, "type": "string" }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "template-version": { + "description": "Service Template Version.", "required": true, "type": "string" }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "resource-type": { + "description": "Request type.", "required": true, "type": "string" }, - "template-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "template-names": { + "description": "Name of the artifact Node Templates, to get the template Content.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "request-id": { + "description": "Request Id, Unique Id for the request.", "required": true, "type": "string" }, - "mapping-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "resource-id": { + "description": "Resource Id.", "required": true, "type": "string" } @@ -319,64 +336,95 @@ }, "derived_from": "tosca.nodes.Component" }, - "component-resource-assignment-python": { + "tosca.nodes.DG": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.Component": { "description": "This is Resource Assignment Component API", "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Python": { + "description": "This is Resource Assignment Python Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + } + }, + "data_types": { + "datatype-resource-assignment": { + "version": "1.0.0", + "description": "This is Resource Assignment Data Type", "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "property": { "required": true, + "type": "datatype-property" + }, + "input-param": { + "required": true, + "type": "boolean" + }, + "dictionary-name": { + "required": false, "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } + }, + "dictionary-source": { + "required": false, + "type": "string" + }, + "dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" } + }, + "status": { + "required": false, + "type": "string" + }, + "message": { + "required": false, + "type": "string" + }, + "updated-date": { + "required": false, + "type": "string" + }, + "updated-by": { + "required": false, + "type": "string" } }, - "derived_from": "tosca.nodes.component.Python" - } - }, - "data_types": { - "sample-property" : { - "description": "This is sample data type", + "derived_from": "tosca.datatypes.Root" + }, + "datatype-property": { "version": "1.0.0", + "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", "properties": { - "content": { + "type": { + "required": true, + "type": "string" + }, + "description": { "required": false, "type": "string" }, - "process-name": { + "required": { + "required": false, + "type": "boolean" + }, + "default": { "required": false, "type": "string" }, - "version": { + "entry_schema": { "required": false, - "type": "string", - "default" : "LATEST" + "type": "string" } }, - "derived_from" : "tosca.datatypes.Root" + "derived_from": "tosca.datatypes.Root" } } } \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.Artifact.json b/components/core/load/model_type/node_type/tosca.nodes.Artifact.json new file mode 100644 index 000000000..814105277 --- /dev/null +++ b/components/core/load/model_type/node_type/tosca.nodes.Artifact.json @@ -0,0 +1,5 @@ +{ + "description": "This is Deprecated Artifact Node Type.", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index af3966aad..24514db50 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -50,6 +50,16 @@ object BluePrintTypes { BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC ) + @JvmStatic + val validRelationShipDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO + ) + @JvmStatic fun validModelTypes(): List { val validTypes: MutableList = arrayListOf() diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt index f38c317e7..b125c594c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt @@ -130,6 +130,14 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe @Throws(BluePrintException::class) override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) { + log.debug("Enriching NodeType({})", nodeTypeName) + val derivedFrom = nodeType.derivedFrom + + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + val derivedFromNodeType = populateNodeType(nodeTypeName) + // Enrich NodeType + enrichNodeType(derivedFrom, derivedFromNodeType) + } // NodeType Property Definitions enrichNodeTypeProperties(nodeTypeName, nodeType) @@ -172,7 +180,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) { nodeType.interfaces?.forEach { interfaceName, interfaceObj -> // Populate Node type Interface Operation - log.info("*** ** Enriching NodeType: {} Interface {}", nodeTypeName, interfaceName) + log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName) populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj) } @@ -235,21 +243,25 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe } open fun populateNodeType(nodeTypeName: String): NodeType { - val nodeType = bluePrintRepoService.getNodeType(nodeTypeName)?.block() + + val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName) + ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block() ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName)) serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType) return nodeType } open fun populateArtifactType(artifactTypeName: String): ArtifactType { - val artifactType = bluePrintRepoService.getArtifactType(artifactTypeName)?.block() + val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block() ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName)) serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType) return artifactType } open fun populateDataTypes(dataTypeName: String): DataType { - val dataType = bluePrintRepoService.getDataType(dataTypeName)?.block() + val dataType = serviceTemplate.dataTypes?.get(dataTypeName) + ?: bluePrintRepoService.getDataType(dataTypeName)?.block() ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName)) serviceTemplate.dataTypes?.put(dataTypeName, dataType) return dataType diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index a60f532e0..2b11589d4 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -111,7 +111,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { paths.add("dataTypes") dataTypes.forEach { dataTypeName, dataType -> paths.add(dataTypeName) - message.appendln("--> Data Type :" + paths.joinToString(separator)) + message.appendln("--> DataType :" + paths.joinToString(separator)) dataType.properties?.let { validatePropertyDefinitions(dataType.properties!!) } paths.removeAt(paths.lastIndex) } @@ -136,7 +136,14 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { //Check Derived From checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) + if(!BluePrintTypes.rootNodeTypes().contains(derivedFrom)){ + serviceTemplate.nodeTypes?.get(derivedFrom) + ?: throw BluePrintException(format("Failed to get derivedFrom NodeType({})'s for NodeType({}) ", + derivedFrom, nodeTypeName)) + } + nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) } + nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } paths.removeAt(paths.lastIndex) } @@ -144,7 +151,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class) open fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get node type ({})'s derived from({}) definition ", nodeTypeName, derivedFrom)) + throw BluePrintException(format("Failed to get node type ({})'s derivedFrom({}) definition ", nodeTypeName, derivedFrom)) } } @@ -178,16 +185,16 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class) open fun validateNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { paths.add(nodeTemplateName) - message.appendln("---> Node Template :" + paths.joinToString(separator)) + message.appendln("---> NodeTemplate :" + paths.joinToString(separator)) val type: String = nodeTemplate.type val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type) - ?: throw BluePrintException(format("Failed to get node type definition for node template : {}", nodeTemplateName)) + ?: throw BluePrintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName)) nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeTemplate.capabilities!!) } - nodeTemplate.requirements?.let { validateRequirementAssignments(nodeTemplate.requirements!!) } + nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } paths.removeAt(paths.lastIndex) } @@ -199,12 +206,12 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { paths.add(artifactDefinitionName) message.appendln("Validating artifact " + paths.joinToString(separator)) val type: String = artifactDefinition.type - ?: throw BluePrintException("type is missing for artifact definition :" + artifactDefinitionName) + ?: throw BluePrintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName)) // Check Artifact Type checkValidArtifactType(artifactDefinitionName, type) val file: String = artifactDefinition.file - ?: throw BluePrintException(format("file is missing for artifact definition : {}", artifactDefinitionName)) + ?: throw BluePrintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName)) paths.removeAt(paths.lastIndex) } @@ -250,7 +257,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } BluePrintTypes.validCollectionTypes().contains(dataType) -> { val entrySchemaType: String = propertyDefinition.entrySchema?.type - ?: throw BluePrintException(format("Entry schema for data type ({}) for the property ({}) not found", dataType, propertyName)) + ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName)) checkPrimitiveOrComplex(entrySchemaType, propertyName) } else -> checkPropertyDataType(dataType, propertyName) @@ -289,7 +296,43 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } @Throws(BluePrintException::class) - open fun validateRequirementAssignments(requirements: MutableMap) { + open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val requirements = nodeTemplate.requirements + paths.add("requirements") + requirements?.forEach { requirementName, requirementAssignment -> + paths.add(requirementName) + val requirementDefinition = nodeType.requirements?.get(requirementName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) requirement definition ({}) from" + + " NodeType({}) ", nodeTemplateName, requirementName, nodeTemplate.type)) + // Validate Requirement Assignment + validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, + requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { + log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) + val requirementNodeTemplateName = requirementAssignment.node!! + val capabilityName = requirementAssignment.capability + val relationship = requirementAssignment.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException(format("Failed to get relationship type ({}) for NodeTemplate({})'s requirement({}) ", + relationship, nodeTemplateName, requirementAssignmentName)) + } + + val relationShipNodeTemplate = serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) + ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s for NodeTemplate({}) requirement({}) ", + requirementNodeTemplateName, nodeTemplateName, requirementAssignmentName)) + + relationShipNodeTemplate.capabilities?.get(capabilityName) + ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s capability({}) for NodeTemplate ({})'s requirement({}) ", + requirementNodeTemplateName, capabilityName, nodeTemplateName, requirementAssignmentName)) + } @@ -301,8 +344,8 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> paths.add(interfaceAssignmentName) val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) - ?: throw BluePrintException(format("Failed to get nodeTemplate({}) interface definition ({}) from" + - " node type ({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type)) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) interface definition ({}) from" + + " NodeType({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type)) validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, interfaceAssignment) @@ -336,10 +379,10 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { it.forEach { operationAssignmentName, operationAssignments -> val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) - ?: throw BluePrintException(format("Failed to get nodeTemplate({}) operation definition ({}) ", + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) ", nodeTemplateName, operationAssignmentName)) - log.info("Validation Node Template({}) Interface({}) Operation ({})", nodeTemplateName, + log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName, interfaceAssignmentName, operationAssignmentName) val inputs = operationAssignments.inputs @@ -347,7 +390,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { inputs?.forEach { propertyName, propertyAssignment -> val propertyDefinition = operationDefinition.inputs?.get(propertyName) - ?: throw BluePrintException(format("Failed to get nodeTemplate({}) operation definition ({}) " + + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " + "property definition({})", nodeTemplateName, operationAssignmentName, propertyName)) // Check the property values with property definition validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) @@ -358,6 +401,44 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } + @Throws(BluePrintException::class) + open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { + paths.add("requirements") + val requirements = nodeType.requirements + + requirements?.forEach { requirementDefinitionName, requirementDefinition -> + paths.add(requirementDefinitionName) + message.appendln("Validating : " + paths.joinToString(separator)) + validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String, + requirementDefinition: RequirementDefinition) { + + log.info("Validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName) + val requirementNodeTypeName = requirementDefinition.node!! + val capabilityName = requirementDefinition.capability + val relationship = requirementDefinition.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException(format("Failed to get relationship({}) for NodeType({})'s requirement({}) ", + relationship, nodeTypeName, requirementDefinitionName)) + } + + val relationShipNodeType = serviceTemplate.nodeTypes?.get(requirementNodeTypeName) + ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s for requirement({}) ", + requirementNodeTypeName, requirementDefinitionName)) + + relationShipNodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s capability({}) for NodeType ({})'s requirement({}) ", + requirementNodeTypeName, capabilityName, nodeTypeName, requirementDefinitionName)) + + } + @Throws(BluePrintException::class) open fun validateInterfaceDefinitions(interfaces: MutableMap) { @@ -394,7 +475,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BluePrintException(format("Failed to artifact type for artifact definition : {}", artifactDefinitionName)) + ?: throw BluePrintException(format("Failed to ArtifactType for ArtifactDefinition : {}", artifactDefinitionName)) checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) } @@ -402,14 +483,21 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class) open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get artifact type ({})'s derived from({}) definition ", artifactTypeName, derivedFrom)) + throw BluePrintException(format("Failed to get ArtifactType ({})'s derivedFrom({}) definition ", artifactTypeName, derivedFrom)) } } @Throws(BluePrintException::class) open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get data type ({})'s derived from({}) definition ", dataTypeName, derivedFrom)) + throw BluePrintException(format("Failed to get DataType ({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) + } + } + + @Throws(BluePrintException::class) + open fun checkValidRelationshipTypeDerivedFrom(relationshipTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validRelationShipDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get relationship type ({})'s derivedFrom({}) definition ", relationshipTypeName, derivedFrom)) } } @@ -423,7 +511,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { val entrySchemaType = propertyDefinition.entrySchema?.type - ?: throw BluePrintException(format("Failed to get Entry Schema type for the collection property ({})", propertyName)) + ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { checkPropertyDataType(entrySchemaType, propertyName) @@ -435,7 +523,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } check(isValid) { - throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})", + throw BluePrintException(format("property({}) defined of type({}) is not comptable with the value ({})", propertyName, propertyType, propertyAssignment)) } } @@ -443,7 +531,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { private fun checkPropertyDataType(dataType: String, propertyName: String) { val dataType = serviceTemplate.dataTypes?.get(dataType) - ?: throw BluePrintException(format("Data type ({}) for the property ({}) not found", dataType, propertyName)) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataType, propertyName)) checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) @@ -453,7 +541,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { return true } else { - throw BluePrintException(format("Data type ({}) for the property ({}) is not valid", dataType)) + throw BluePrintException(format("DataType ({}) for the property ({}) is not valid", dataType)) } } diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 5d24b072f..919dc564e 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -55,17 +55,17 @@ class BluePrintRuntimeServiceTest { context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) - val inputDataPath = "src/test/resources/data/default-context.json" + val inputDataPath = "src/test/resources/data/default-context.json" val inputNode: JsonNode = jsonNodeFromFile(inputDataPath) bluePrintRuntimeService.assignInputs(inputNode) - val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") - log.info("Context {}" ,bluePrintRuntimeService.context) + val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action") + log.info("Context {}", bluePrintRuntimeService.context) assertNotNull(propContext, "Failed to populate interface property values") - assertEquals(propContext.get("process-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter process-name") - assertEquals(propContext.get("version"), jsonNodeFromObject("sample-action"), "Failed to populate parameter version") + assertEquals(propContext.get("mode"), jsonNodeFromObject("sync"), "Failed to populate parameter process-name") + assertEquals(propContext.get("version"), jsonNodeFromObject("1.0.0"), "Failed to populate parameter version") } @Test @@ -78,24 +78,22 @@ class BluePrintRuntimeServiceTest { val context: MutableMap = hashMapOf() context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") - val inputDataPath = "src/test/resources/data/default-context.json" + val inputDataPath = "src/test/resources/data/default-context.json" BluePrintRuntimeUtils.assignInputsFromFile(bluePrintContext, inputDataPath, context) val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) - log.info("Prepared Context {}" ,context) + log.info("Prepared Context {}", context) - val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment", - "DefaultComponentNode", "process") + val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component", + "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode", "process") - log.trace("In Context {}" ,inContext) + log.info("In Context {}", inContext) assertNotNull(inContext, "Failed to populate interface input property values") assertEquals(inContext.get("action-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") assertEquals(inContext.get("request-id"), jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - assertEquals(inContext.get("template-content"), jsonNodeFromObject("This is Sample Velocity Template"), "Failed to populate parameter action-name") - } @Test @@ -106,24 +104,24 @@ class BluePrintRuntimeServiceTest { assertNotNull(bluePrintContext, "Failed to populate Blueprint context") val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) val componentContext: MutableMap = hashMapOf() - val successValue : JsonNode= jsonNodeFromObject("Success") - componentContext["resource-assignment.DefaultComponentNode.process.status"] = successValue - componentContext["resource-assignment.DefaultComponentNode.process.resource-assignment-params"] = null + val successValue: JsonNode = jsonNodeFromObject("Success") + componentContext["resource-assignment-ra-component.org-onap-sdnc-config-assignment-service-ConfigAssignmentNode.process.status"] = successValue + componentContext["resource-assignment-ra-component.org-onap-sdnc-config-assignment-service-ConfigAssignmentNode.process.resource-assignment-params"] = null - bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", - "DefaultComponentNode", "process", componentContext) + bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component", + "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode", "process", componentContext) assertEquals(NullNode.instance, - context.get("node_templates/resource-assignment/interfaces/DefaultComponentNode/operations/process/properties/resource-assignment-params"), + context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-sdnc-config-assignment-service-ConfigAssignmentNode/operations/process/properties/resource-assignment-params"), "Failed to get operation property resource-assignment-params") assertEquals(successValue, - context.get("node_templates/resource-assignment/interfaces/DefaultComponentNode/operations/process/properties/status"), + context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-sdnc-config-assignment-service-ConfigAssignmentNode/operations/process/properties/status"), "Failed to get operation property status") diff --git a/components/core/src/test/resources/data/default-context.json b/components/core/src/test/resources/data/default-context.json index fcd4cbe26..e033f6f57 100644 --- a/components/core/src/test/resources/data/default-context.json +++ b/components/core/src/test/resources/data/default-context.json @@ -1,5 +1,7 @@ { "request-id" : "12345", "hostname" : "localhost", + "template_name": "baseconfiguration", + "template_version": "1.0.0", "action-name" : "sample-action" } \ No newline at end of file -- cgit 1.2.3-korg From 7f52a96672beabb6b1f8ccfa1417307ccdbb40e8 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Fri, 7 Sep 2018 09:00:40 -0400 Subject: Controller Blueprints Microservice Add Controller Blueprint Capabily Assignment and their properies validation. Change-Id: I845fec3d307414b2caeb1d577308a17656ff194a Issue-ID: CCSDK-484 Signed-off-by: Brinda Santh --- .../core/service/BluePrintValidatorService.kt | 36 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 2b11589d4..8c00e0a15 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -136,7 +136,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { //Check Derived From checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) - if(!BluePrintTypes.rootNodeTypes().contains(derivedFrom)){ + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { serviceTemplate.nodeTypes?.get(derivedFrom) ?: throw BluePrintException(format("Failed to get derivedFrom NodeType({})'s for NodeType({}) ", derivedFrom, nodeTypeName)) @@ -193,7 +193,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } - nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeTemplate.capabilities!!) } + nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } paths.removeAt(paths.lastIndex) @@ -291,7 +291,28 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } @Throws(BluePrintException::class) - open fun validateCapabilityAssignments(capabilities: MutableMap) { + open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val capabilities = nodeTemplate.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityAssignment -> + paths.add(capabilityName) + + val capabilityDefinition = nodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) capability definition ({}) " + + "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type)) + + validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String, + capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) { + + capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } } @@ -396,6 +417,15 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) } + outputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.outputs?.get(propertyName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " + + "output property definition({})", nodeTemplateName, operationAssignmentName, + propertyName)) + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + } } -- cgit 1.2.3-korg From c3610634e6db49fc7ce03d99afbbc7df4fa6884d Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 7 Sep 2018 15:24:07 +0000 Subject: Controller Blueprints Microservice Add Capability Definition validations and add custom capabilities Types for content, mapping, netconf, ssh and sftp Change-Id: I6a89d20280852034ce6ee56d2a9e97d3aab9c2db Issue-ID: CCSDK-484 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../Definitions/activation-blueprint.json | 21 +----------------- .../node_type/artifact-config-template.json | 4 ++-- .../model_type/node_type/dg-activate-netconf.json | 14 ------------ .../model_type/node_type/dg-config-generator.json | 14 ------------ .../node_type/dg-resource-assign-activate.json | 14 ------------ .../node_type/dg-resource-assignment.json | 14 ------------ .../core/BluePrintConstants.kt | 21 +++++++++++++++++- .../controllerblueprints/core/BluePrintTypes.kt | 23 ++++++++++++++++++++ .../core/data/BluePrintModel.kt | 2 +- .../core/service/BluePrintValidatorService.kt | 25 ++++++++++++++++++++++ 10 files changed, 72 insertions(+), 80 deletions(-) diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json index 3eb4fedcb..714195f3f 100644 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -91,12 +91,7 @@ } }, "capabilities": { - "dg-node": {}, - "content": { - "properties": { - "type": "json" - } - } + "dg-node": {} }, "interfaces": { "CONFIG": { @@ -226,20 +221,6 @@ "capabilities": { "dg-node": { "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": false, - "type": "string" - } - } } }, "requirements": { diff --git a/components/core/load/model_type/node_type/artifact-config-template.json b/components/core/load/model_type/node_type/artifact-config-template.json index be9bbfc0e..af99d75b8 100644 --- a/components/core/load/model_type/node_type/artifact-config-template.json +++ b/components/core/load/model_type/node_type/artifact-config-template.json @@ -12,7 +12,7 @@ }, "capabilities": { "content": { - "type": "tosca.capability.Content", + "type": "tosca.capabilities.Content", "properties": { "content": { "required": true, @@ -21,7 +21,7 @@ } }, "mapping": { - "type": "tosca.capability.Mapping", + "type": "tosca.capabilities.Mapping", "properties": { "mapping": { "required": false, diff --git a/components/core/load/model_type/node_type/dg-activate-netconf.json b/components/core/load/model_type/node_type/dg-activate-netconf.json index a9d16eddc..57667de98 100644 --- a/components/core/load/model_type/node_type/dg-activate-netconf.json +++ b/components/core/load/model_type/node_type/dg-activate-netconf.json @@ -21,20 +21,6 @@ "capabilities": { "dg-node": { "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } } }, "requirements": { diff --git a/components/core/load/model_type/node_type/dg-config-generator.json b/components/core/load/model_type/node_type/dg-config-generator.json index 6794b3c89..e59c34b6e 100644 --- a/components/core/load/model_type/node_type/dg-config-generator.json +++ b/components/core/load/model_type/node_type/dg-config-generator.json @@ -21,20 +21,6 @@ "capabilities": { "dg-node": { "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } } }, "requirements": { diff --git a/components/core/load/model_type/node_type/dg-resource-assign-activate.json b/components/core/load/model_type/node_type/dg-resource-assign-activate.json index 22a4d813c..ca703a793 100644 --- a/components/core/load/model_type/node_type/dg-resource-assign-activate.json +++ b/components/core/load/model_type/node_type/dg-resource-assign-activate.json @@ -21,20 +21,6 @@ "capabilities": { "dg-node": { "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": false, - "type": "string" - } - } } }, "requirements": { diff --git a/components/core/load/model_type/node_type/dg-resource-assignment.json b/components/core/load/model_type/node_type/dg-resource-assignment.json index 7c01faa13..9cce82a9e 100644 --- a/components/core/load/model_type/node_type/dg-resource-assignment.json +++ b/components/core/load/model_type/node_type/dg-resource-assignment.json @@ -21,20 +21,6 @@ "capabilities": { "dg-node": { "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": false, - "type": "string" - } - } } }, "requirements": { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index ffad8e561..d4bd20a60 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -16,6 +16,7 @@ */ package org.onap.ccsdk.apps.controllerblueprints.core + /** * BluePrintConstants * @@ -94,10 +95,28 @@ object BluePrintConstants { const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" - const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION ="tosca.artifacts.Implementation" + const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" + const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" + const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" + const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" + const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" + const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" + const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" + const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" + // Custom capabilities + const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" + const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" + const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" + const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" + const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" + const val EXPRESSION_GET_INPUT: String = "get_input" const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index 24514db50..e25b3eea9 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -50,6 +50,7 @@ object BluePrintTypes { BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC ) + @Deprecated("This has to move to Relationship Types Model Drive") @JvmStatic val validRelationShipDerivedFroms: MutableList = arrayListOf( BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, @@ -60,6 +61,28 @@ object BluePrintTypes { BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO ) + @Deprecated("This has to move to Capability Types Model Drive") + @JvmStatic + val validCapabilityTypes: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP + ) + @JvmStatic fun validModelTypes(): List { val validTypes: MutableList = arrayListOf() diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index ef8bbf2d6..70f3c5569 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -309,7 +309,7 @@ A capability definition defines a named, typed set of data that can be associate class CapabilityDefinition { @get:JsonIgnore var id: String? = null - var type: String? = null + lateinit var type: String var description: String? = null var properties: MutableMap? = null @get:JsonProperty("valid_source_types") diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 8c00e0a15..3bea59f9d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -143,6 +143,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) } + nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } paths.removeAt(paths.lastIndex) @@ -431,6 +432,30 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } + @Throws(BluePrintException::class) + open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { + val capabilities = nodeType.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityDefinition -> + paths.add(capabilityName) + + validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String, + capabilityDefinition: CapabilityDefinition) { + val capabilityType = capabilityDefinition.type + check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { + throw BluePrintException(format("Failed to get CapabilityType({}) for NodeType({})", + capabilityType, nodeTypeName)) + } + } + @Throws(BluePrintException::class) open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { paths.add("requirements") -- cgit 1.2.3-korg From c53090478a32638f99a4e30468663fb3a2606740 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 7 Sep 2018 19:20:59 +0000 Subject: Controller Blueprints Microservice Remove Resource Dictionary resource_type, resource_path, sample_values and valid_values parameters. Change-Id: I7ec899e30aaef64130f35eb754a79f9dfc54f71f Issue-ID: CCSDK-488 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/resource-dict/load/resource_dictionary/db-source.json | 2 -- .../resource-dict/load/resource_dictionary/default-source.json | 2 -- components/resource-dict/load/resource_dictionary/input-source.json | 2 -- components/resource-dict/load/resource_dictionary/mdsal-source.json | 2 -- .../apps/controllerblueprints/resource/dict/ResourceDefinition.kt | 6 ------ 5 files changed, 14 deletions(-) diff --git a/components/resource-dict/load/resource_dictionary/db-source.json b/components/resource-dict/load/resource_dictionary/db-source.json index 92b16a212..b96dc63f7 100644 --- a/components/resource-dict/load/resource_dictionary/db-source.json +++ b/components/resource-dict/load/resource_dictionary/db-source.json @@ -4,8 +4,6 @@ "description": "name of the ", "type": "string" }, - "resource-type": "ONAP", - "resource-path": "vnf/bundle-id", "updated-by": "brindasanth@onap.com", "tags": "bundle-id, brindasanth@onap.com", "sources": { diff --git a/components/resource-dict/load/resource_dictionary/default-source.json b/components/resource-dict/load/resource_dictionary/default-source.json index 1c47f37b2..64bfa0ccd 100644 --- a/components/resource-dict/load/resource_dictionary/default-source.json +++ b/components/resource-dict/load/resource_dictionary/default-source.json @@ -6,8 +6,6 @@ "type": "string" }, "updated-by": "brindasanth@onap.com", - "resource-type": "ONAP", - "resource-path": "vnf/v4-ip-type", "sources": { "default": { "type": "source-default", diff --git a/components/resource-dict/load/resource_dictionary/input-source.json b/components/resource-dict/load/resource_dictionary/input-source.json index 676d92f86..152a5eefc 100644 --- a/components/resource-dict/load/resource_dictionary/input-source.json +++ b/components/resource-dict/load/resource_dictionary/input-source.json @@ -4,8 +4,6 @@ "description": "name of the ", "type": "string" }, - "resource-path": "action-name", - "resource-type": "ONAP", "updated-by": "brindasanth@onap.com", "tags": null, "sources": { diff --git a/components/resource-dict/load/resource_dictionary/mdsal-source.json b/components/resource-dict/load/resource_dictionary/mdsal-source.json index b49146a0e..b38986a4b 100644 --- a/components/resource-dict/load/resource_dictionary/mdsal-source.json +++ b/components/resource-dict/load/resource_dictionary/mdsal-source.json @@ -6,8 +6,6 @@ "type": "string" }, "updated-by": "brindasanth@onap.com", - "resource-type": "ATT", - "resource-path": "vnf/oam-local-ipv4-address", "sources": { "mdsal": { "type": "source-rest", diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt index 0808073f8..ff2608711 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -36,12 +36,6 @@ open class ResourceDefinition { @JsonProperty(value = "updated-by") lateinit var updatedBy: String - @JsonProperty(value = "resource-type", required = true) - lateinit var resourceType: String - - @JsonProperty(value = "resource-path", required = true) - lateinit var resourcePath: String - @JsonProperty(value = "sources", required = true) lateinit var sources: MutableMap } -- cgit 1.2.3-korg From 768123992afdcd3997bb8c57b2210a4bcf88b29c Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 7 Sep 2018 22:43:20 +0000 Subject: Controller Blueprints Microservice Modify get_input, get_attribute, get_property and get_artifact functions string implementation to Json Implementation. Change-Id: I6d4aadd370dc23127a176964f84fc9bb5e7ab5ee Issue-ID: CCSDK-432 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../Definitions/activation-blueprint.json | 4 +-- .../Definitions/sample-nodetype.json | 31 +----------------- .../Definitions/simple-baseconfig.json | 37 ++++++++++------------ .../node_type/component-config-generator.json | 2 +- .../node_type/component-netconf-executor.json | 2 +- .../node_type/component-resource-assignment.json | 2 +- .../core/ConfigModelConstant.kt | 6 ---- .../core/service/BluePrintExpressionService.kt | 37 ++++++++++++---------- .../core/service/BluePrintExpressionServiceTest.kt | 14 ++++++-- .../core/service/BluePrintRuntimeServiceTest.kt | 12 +++---- .../src/test/resources/componentnode/default.json | 6 ++-- .../src/test/resources/properties/convert.json | 4 +-- .../src/test/resources/properties/default.json | 4 +-- 13 files changed, 66 insertions(+), 95 deletions(-) diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json index 714195f3f..9c70d6eac 100644 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -40,7 +40,7 @@ "component-node": {} }, "interfaces": { - "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { @@ -258,7 +258,7 @@ } }, "interfaces": { - "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json b/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json index 6d469ea84..207fcc415 100644 --- a/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json +++ b/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json @@ -1,34 +1,5 @@ { "description": "This is Resource Assignment Component API", "version": "1.0.0", - "properties": { - "type": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": false, - "type": "string" - } - }, - "interfaces": { - "DefaultOperation": { - "operations": { - "validate": { - "inputs": { - "action-name": { - "description": "validate for action", - "required": false, - "type": "string" - } - } - } - } - } - }, - "artifacts" :{ - "component-jar": { - "description": "Component Jar", - "type": "artifact-component-jar", - "file": "Component/basecomponent.jar" - } - }, - "derived_from": "tosca.nodes.Root" + "derived_from": "tosca.nodes.Root" } \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json index 65028ace0..cb091da0f 100644 --- a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json +++ b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json @@ -38,7 +38,7 @@ "login-key": "sdnc", "login-account": "sndc-local", "source": "local", - "target-ip-address": "{\"get_attribute\":\"lo0-local-ipv4-address\"}", + "target-ip-address": { "get_attribute": ["SELF", "lo0-local-ipv4-address"]}, "port-number": 22, "connection-time-out": 30 } @@ -58,21 +58,21 @@ } }, "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { + "org-onap-ccsdk-netconf-adaptor-service-NetconfExecutorNode": { "operations": { "process": { "inputs": { - "action-name": "{ \"get_input\" : \"action-name\" }", - "service-template-name": "{ \"get_attribute\" : \"template_name\" }", - "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }", + "action-name": { "get_input" : "action-name" }, + "service-template-name": { "get_input" : "template_name" }, + "service-template-version": { "get_input" : "service-template-version" }, "resource-type": "vnf-type", - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"hostname\" }", + "request-id": { "get_input" : "request-id" }, + "resource-id": { "get_input" : "hostname" }, "execution-script": "execution-script" }, "outputs": { - "response-data": "{ \"get_attribute\" : \"netconf-executor-baseconfig.response-data\" }", - "status": "{ \"get_attribute\" : \"netconf-executor-baseconfig.status\" }" + "response-data": { "get_input" : ["SELF", "netconf-executor-baseconfig.response-data"] }, + "status": { "get_input" : ["SELF", "netconf-executor-baseconfig.status"] } }, "implementation" : { "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py" @@ -88,7 +88,7 @@ "component-node": {} }, "interfaces": { - "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { @@ -96,12 +96,12 @@ "base-config-template", "licence-template" ], - "action-name": "{ \"get_input\" : \"action-name\" }", - "service-template-name": "{ \"get_attribute\" : \"template_name\" }", - "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }", + "action-name": { "get_input" : "action-name" }, + "service-template-name": { "get_input" : "template_name" }, + "service-template-version": { "get_input" : "service-template-version" }, "resource-type": "vnf-type", - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"hostname\" }" + "request-id": { "get_input" : "request-id" }, + "resource-id": { "get_input" : "hostname" } }, "outputs": { "resource-assignment-params": "success", @@ -127,12 +127,7 @@ } }, "capabilities": { - "dg-node": {}, - "content": { - "properties": { - "type": "json" - } - } + "dg-node": {} }, "interfaces": { "CONFIG": { diff --git a/components/core/load/model_type/node_type/component-config-generator.json b/components/core/load/model_type/node_type/component-config-generator.json index 764f9e890..9e86b8aed 100644 --- a/components/core/load/model_type/node_type/component-config-generator.json +++ b/components/core/load/model_type/node_type/component-config-generator.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": { + "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": { "operations": { "process": { "inputs": { diff --git a/components/core/load/model_type/node_type/component-netconf-executor.json b/components/core/load/model_type/node_type/component-netconf-executor.json index aed667aaf..7dcff5839 100644 --- a/components/core/load/model_type/node_type/component-netconf-executor.json +++ b/components/core/load/model_type/node_type/component-netconf-executor.json @@ -14,7 +14,7 @@ } }, "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { + "org-onap-ccsdk-netconf-adaptor-service-NetconfExecutorNode": { "operations": { "process": { "inputs": { diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json index 03f3c2845..1389bc328 100644 --- a/components/core/load/model_type/node_type/component-resource-assignment.json +++ b/components/core/load/model_type/node_type/component-resource-assignment.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { "operations": { "process": { "inputs": { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt index 845922040..8bfa2db7e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt @@ -31,12 +31,6 @@ object ConfigModelConstant { const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" - const val MODEL_TYPE_CAPABILITY_NETCONF = "tosca.capability.Netconf" - const val MODEL_TYPE_CAPABILITY_SSH = "tosca.capability.Ssh" - const val MODEL_TYPE_CAPABILITY_SFTP = "tosca.capability.Sftp" - const val MODEL_TYPE_CAPABILITY_CHEF = "tosca.capability.Chef" - const val MODEL_TYPE_CAPABILITY_ANSIBLEF = "tosca.capability.Ansible" - const val CAPABILITY_PROPERTY_MAPPING = "mapping" const val PROPERTY_RECIPE_NAMES = "action-names" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt index 19d515e0e..82e232d0e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -25,6 +25,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager + /** * * @@ -115,32 +116,34 @@ object BluePrintExpressionService { @JvmStatic fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression { val arrayNode: ArrayNode = jsonNode.first() as ArrayNode - check(arrayNode.size() >= 3) { + check(arrayNode.size() >= 2) { throw BluePrintException(String.format("missing attribute expression, " + "it should be [ , , ," + " , ..., ] , but present {}", jsonNode)) } var reqOrCapEntityName: String? = null - var propertyName = "" - var subProperty: String? = null - if (arrayNode.size() == 2) { - propertyName = arrayNode[1].textValue() - } else if (arrayNode.size() == 3) { - reqOrCapEntityName = arrayNode[1].textValue() - propertyName = arrayNode[2].textValue() - } else if (arrayNode.size() > 3) { - reqOrCapEntityName = arrayNode[1].textValue() - propertyName = arrayNode[2].textValue() - val propertyPaths: List = arrayNode.filterIndexed { index, obj -> - index >= 3 - }.map { it.textValue() } - subProperty = propertyPaths.joinToString("/") + var attributeName = "" + var subAttributeName: String? = null + when { + arrayNode.size() == 2 -> attributeName = arrayNode[1].textValue() + arrayNode.size() == 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + attributeName = arrayNode[2].textValue() + } + arrayNode.size() > 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + attributeName = arrayNode[2].textValue() + val propertyPaths: List = arrayNode.filterIndexed { index, _ -> + index >= 3 + }.map { it.textValue() } + subAttributeName = propertyPaths.joinToString("/") + } } return AttributeExpression(modelableEntityName = arrayNode[0].asText(), reqOrCapEntityName = reqOrCapEntityName, - attributeName = propertyName, - subAttributeName = subProperty + attributeName = attributeName, + subAttributeName = subAttributeName ) } diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt index 911a891a8..a0214023e 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt @@ -60,14 +60,22 @@ class BluePrintExpressionServiceTest { @Test fun testAttributeExpression() { - val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }") + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }") val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) assertNotNull(expressionData, " Failed to populate expression data") assertEquals(expressionData.isExpression, true, "Failed to identify as expression") assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data") assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("attribute-name", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName") - assertEquals("resource/name",expressionData.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data") + assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName") + + val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }") + val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) + assertNotNull(expressionData1, " Failed to populate expression data") + assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data") + assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName") + assertEquals("resource/name",expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data") } diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 919dc564e..277ec3ac9 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -87,7 +87,7 @@ class BluePrintRuntimeServiceTest { log.info("Prepared Context {}", context) val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component", - "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode", "process") + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process") log.info("In Context {}", inContext) @@ -110,18 +110,18 @@ class BluePrintRuntimeServiceTest { val componentContext: MutableMap = hashMapOf() val successValue: JsonNode = jsonNodeFromObject("Success") - componentContext["resource-assignment-ra-component.org-onap-sdnc-config-assignment-service-ConfigAssignmentNode.process.status"] = successValue - componentContext["resource-assignment-ra-component.org-onap-sdnc-config-assignment-service-ConfigAssignmentNode.process.resource-assignment-params"] = null + componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.status"] = successValue + componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.resource-assignment-params"] = null bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component", - "org-onap-sdnc-config-assignment-service-ConfigAssignmentNode", "process", componentContext) + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", componentContext) assertEquals(NullNode.instance, - context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-sdnc-config-assignment-service-ConfigAssignmentNode/operations/process/properties/resource-assignment-params"), + context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/resource-assignment-params"), "Failed to get operation property resource-assignment-params") assertEquals(successValue, - context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-sdnc-config-assignment-service-ConfigAssignmentNode/operations/process/properties/status"), + context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/status"), "Failed to get operation property status") diff --git a/components/core/src/test/resources/componentnode/default.json b/components/core/src/test/resources/componentnode/default.json index b7265fcd1..184b59881 100644 --- a/components/core/src/test/resources/componentnode/default.json +++ b/components/core/src/test/resources/componentnode/default.json @@ -41,13 +41,13 @@ "generate-configuration": { "type": "mock-component-generateConfig", "interfaces": { - "org-openecomp-sdnc-config-params-service-MockComponentNode": { + "org-onap-ccsdk-config-params-service-MockComponentNode": { "operations": { "process": { "inputs": { "entity-type": "vnf-type", "template-content": "sample-template", - "entity-id": "{ \"get_input\" : \"vnf-id\" }" + "entity-id": { "get_input" : "vnf-id" } }, "outputs": { "mergedData": "merged Data", @@ -63,7 +63,7 @@ "node_types": { "mock-component-generateConfig": { "interfaces": { - "org-openecomp-sdnc-config-params-service-MockComponentNode": { + "org-onap-ccsdk-config-params-service-MockComponentNode": { "operations": { "process": { "inputs": { diff --git a/components/core/src/test/resources/properties/convert.json b/components/core/src/test/resources/properties/convert.json index cb7d08e44..af79915fa 100644 --- a/components/core/src/test/resources/properties/convert.json +++ b/components/core/src/test/resources/properties/convert.json @@ -19,12 +19,12 @@ "required": true } ], - "pre-data": "{ \"get_attribute\" : \"get-resource-assignment.config-params\" }", + "pre-data": { "get_input" : "get-resource-assignment.config-params" }, "prifix": "get-resource-assignment" }, "outputs": { "resource-assignment-status": "success", - "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params\" }" + "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" } } } } diff --git a/components/core/src/test/resources/properties/default.json b/components/core/src/test/resources/properties/default.json index 0ac97f907..ec416dc95 100644 --- a/components/core/src/test/resources/properties/default.json +++ b/components/core/src/test/resources/properties/default.json @@ -1,5 +1,5 @@ { - "default": "{ \"get_input\" : \"loopback-default\" }", + "default": { "get_input" : "loopback-default" }, "domain": "ethernet", "criteria": [ { @@ -8,7 +8,7 @@ "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" }, { - "value": "{ \"get_input\" : \"host-ip-address\" }", + "value": { "get_input" : "host-ip-address" }, "type": "simple", "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" } -- cgit 1.2.3-korg From ab1c5333d46c022fa02429337d8c646a2e5a72ef Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Sun, 9 Sep 2018 22:00:59 -0400 Subject: Controller Blueprints Microservice Add ModelType and Resource Dictionary reactor repository service and junit test cases for reactor repositories. Change-Id: Id358082739f81d18b534c224dc7472355e21f026 Issue-ID: CCSDK-491 Signed-off-by: Brinda Santh --- .../resource/dict/service/ResourceAssignmentValidationService.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 228b39e29..fae509d25 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,9 +88,6 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten() - log.info("Resource assignment definitions : {}", resourceAssignmentMap.keys) - log.info("Resource assignment Dictionary dependencies : {}", dependenciesNames) - val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct() if (notPresentDictionaries.isNotEmpty()) { validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries)) -- cgit 1.2.3-korg From b21540f1211a039aa6907f60d7621c8d331ec94f Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Mon, 10 Sep 2018 23:15:31 -0400 Subject: Controller Blueprints Microservice Add Attribute function implementation for Operation output properties. Change-Id: I8fd116ad7def07d208f9c3c1bfe7b75deae667d4 Issue-ID: CCSDK-524 Signed-off-by: Brinda Santh --- .../Definitions/activation-blueprint.json | 4 +- .../core/service/BluePrintRuntimeService.kt | 111 ++++++++++++++++----- .../core/service/PropertyAssignmentService.kt | 64 +++++++----- .../core/service/BluePrintRuntimeServiceTest.kt | 70 ++++++++----- 4 files changed, 172 insertions(+), 77 deletions(-) diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json index 9c70d6eac..bc10f7673 100644 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json @@ -66,8 +66,8 @@ } }, "outputs": { - "resource-assignment-params": "success", - "status": "status" + "resource-assignment-params": { "get_attribute" : ["SELF", "params"] }, + "status": "Success" } } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index ce0bceeea..1fdb6c3ce 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -29,6 +29,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper + /** * * @@ -78,8 +81,8 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c } open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, - interfaceName: String, operationName: String): MutableMap { - log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " + + interfaceName: String, operationName: String): MutableMap { + log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " + "operationName({})", nodeTemplateName, interfaceName, operationName) val propertyAssignmentValue: MutableMap = hashMapOf() @@ -117,17 +120,25 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c // Set for Return of method propertyAssignmentValue[nodeTypePropertyName] = resolvedValue } - log.info("resolved input assignments for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue) + log.trace("resolved input assignments for node template ({}), values ({})", nodeTemplateName, + propertyAssignmentValue) return propertyAssignmentValue } open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, - interfaceName: String, operationName: String, componentContext: MutableMap) { - log.info("nodeTemplateInterfaceOperationInputsResolvedExpression for node template ({}),interface name ({}), " + + interfaceName: String, operationName: String): MutableMap { + log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ({}),interface name ({}), " + "operationName({})", nodeTemplateName, interfaceName, operationName) + val propertyAssignmentValue: MutableMap = hashMapOf() + + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap + ?: throw BluePrintException(String.format("failed to get output definitions for node template (%s), " + + "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName)) + val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type val nodeTypeInterfaceOperationOutputs: MutableMap = @@ -138,21 +149,32 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c // Iterate Node Type Properties nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty -> - val operationOutputPropertyName: String = StringBuilder().append(nodeTemplateName) - .append(".").append(interfaceName) - .append(".").append(operationName) - .append(".").append(nodeTypePropertyName).toString() - // Get the Value from component context - val resolvedValue: JsonNode = componentContext[operationOutputPropertyName] as? JsonNode - ?: NullNode.getInstance() + // Get the Express or Value for the Node Template + val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + + var resolvedValue: JsonNode = NullNode.getInstance() + if (propertyAssignment != null) { + // Resolve the Expressing + val propertyAssignmentExpression = PropertyAssignmentService(context, this) + resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) + } else { + // Assign default value to the Operation + nodeTypeProperty.defaultValue?.let { + resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) + } + } + // Set for Return of method + propertyAssignmentValue[nodeTypePropertyName] = resolvedValue + // Store operation output values into context - setNodeTemplateOperationPropertyValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue) - log.debug("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue) + setNodeTemplateOperationOutputValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue) + log.trace("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue) } + return propertyAssignmentValue } open fun resolveNodeTemplateArtifact(nodeTemplateName: String, - artifactName: String): String { + artifactName: String): String { val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName) @@ -186,8 +208,16 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c context[path] = value } + open fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { + + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() + context[path] = value + } + open fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { + value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) @@ -198,10 +228,10 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c } open fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { + value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() @@ -209,10 +239,10 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c } open fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { + value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() @@ -230,19 +260,27 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS).append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return context[path] as JsonNode } - open fun getPropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? { + open fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return context[path] as JsonNode } - open fun getRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? { + open fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() + return context[path] as JsonNode + } + + open fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: + String): JsonNode? { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) @@ -250,7 +288,8 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c return context[path] as JsonNode } - open fun getCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? { + open fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: + String): JsonNode? { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) @@ -275,4 +314,24 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c setWorkflowInputValue(workflowName, propertyName, valueNode) } } + + open fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode { + + val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).toString() + context.keys.filter { + it.startsWith(path) + }.map { + val key = it.replace(path, "") + if (keys.contains(key)) { + val value = context[it] as JsonNode + jsonNode.set(key, value) + } + } + return jsonNode + } + + } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index ece09d6e2..131bb30ae 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -20,6 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format @@ -27,6 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager + /** * * @@ -42,11 +44,11 @@ class PropertyAssignmentService(var context: MutableMap, If Property Assignment is Expression. Get the Expression - Recurssely resolve the expression + Recursively resolve the expression */ fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String, - assignment: Any): JsonNode { + assignment: Any): JsonNode { val valueNode: JsonNode log.trace("Assignment ({})", assignment) val expressionData = BluePrintExpressionService.getExpressionData(assignment) @@ -63,30 +65,30 @@ If Property Assignment is Expression. var valueNode: JsonNode = NullNode.getInstance() - if(expressionData.isExpression) { + if (expressionData.isExpression) { val command = expressionData.command!! - when(command){ - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT ->{ + when (command) { + BluePrintConstants.EXPRESSION_GET_INPUT -> { valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE ->{ + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { valueNode = resolveAttributeExpression(nodeTemplateName, expressionData.attributeExpression!!) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY ->{ + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { valueNode = resolvePropertyExpression(nodeTemplateName, expressionData.propertyExpression!!) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT ->{ + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { valueNode = resolveOperationOutputExpression(nodeTemplateName, expressionData.operationOutputExpression!!) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT ->{ + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE ->{ + BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> { } - else ->{ - throw BluePrintException(String.format("for property ({}), command ({}) is not supported ", propName, command)) + else -> { + throw BluePrintException(format("for property ({}), command ({}) is not supported ", propName, command)) } } } @@ -104,20 +106,30 @@ If Property Assignment is Expression. val subAttributeName: String? = attributeExpression.subAttributeName var attributeNodeTemplateName = nodeTemplateName - if (!attributeExpression.modelableEntityName.equals("SELF", true)) { - attributeNodeTemplateName = attributeExpression.modelableEntityName - } - - val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName) - ?: throw BluePrintException(String.format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, attributeName)) + when (attributeExpression.modelableEntityName) { + "ENV" -> { + val environmentValue = System.getProperty(attributeName) + valueNode = JacksonUtils.jsonNode(environmentValue) + } + else -> { + if (!attributeExpression.modelableEntityName.equals("SELF", true)) { + attributeNodeTemplateName = attributeExpression.modelableEntityName + } + /* Enable in ONAP Dublin Release + val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName) + ?: throw BluePrintException(format("failed to get attribute definitions for node template " + + "({})'s property name ({}) ", nodeTemplateName, attributeName)) - var propertyDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!! + var attributeDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!! - log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) + log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) + */ - // Check it it is a nested expression - valueNode = resolveAssignmentExpression(attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) + valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName) + ?: throw BluePrintException(format("failed to get node template ({})'s attribute ({}) ", nodeTemplateName, attributeName)) + } + } // subPropertyName?.let { // valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) // } @@ -171,7 +183,7 @@ If Property Assignment is Expression. /* get_artifact: [ , , , ] */ - fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode { + fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode { var artifactNodeTemplateName = nodeTemplateName if (!artifactExpression.modelableEntityName.equals("SELF", true)) { @@ -179,15 +191,15 @@ If Property Assignment is Expression. } val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName) .artifacts?.get(artifactExpression.artifactName) - ?: throw BluePrintException(String.format("failed to get artifact definitions for node template ({})'s " + + ?: throw BluePrintException(format("failed to get artifact definitions for node template ({})'s " + "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName)) return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition)) } fun artifactContent(artifactDefinition: ArtifactDefinition): String { - val bluePrintBasePath: String = context[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String - ?: throw BluePrintException(String.format("failed to get property (%s) from context", org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)) + val bluePrintBasePath: String = context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String + ?: throw BluePrintException(format("failed to get property (%s) from context", BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)) if (artifactDefinition.repository != null) { TODO() diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 277ec3ac9..f1980d279 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.NullNode import org.junit.Before import org.junit.Test import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants @@ -48,12 +48,8 @@ class BluePrintRuntimeServiceTest { @Test fun testResolveNodeTemplateProperties() { log.info("************************ testResolveNodeTemplateProperties **********************") - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") - val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + val bluePrintRuntimeService = getBluePrintRuntimeService() val inputDataPath = "src/test/resources/data/default-context.json" @@ -99,31 +95,59 @@ class BluePrintRuntimeServiceTest { @Test fun testResolveNodeTemplateInterfaceOperationOutputs() { log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************") - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - assertNotNull(bluePrintContext, "Failed to populate Blueprint context") - - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") - val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + val bluePrintRuntimeService = getBluePrintRuntimeService() - val componentContext: MutableMap = hashMapOf() val successValue: JsonNode = jsonNodeFromObject("Success") - componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.status"] = successValue - componentContext["resource-assignment-ra-component.org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode.process.resource-assignment-params"] = null + val paramValue: JsonNode = jsonNodeFromObject("param-content") + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "params", paramValue) bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component", - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", componentContext) + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process") - assertEquals(NullNode.instance, - context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/resource-assignment-params"), - "Failed to get operation property resource-assignment-params") + val resourceAssignmentParamsNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component", + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "resource-assignment-params") - assertEquals(successValue, - context.get("node_templates/resource-assignment-ra-component/interfaces/org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode/operations/process/properties/status"), - "Failed to get operation property status") + val statusNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component", + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "status") + + assertEquals(paramValue, resourceAssignmentParamsNode, "Failed to get operation property resource-assignment-params") + + assertEquals(successValue, statusNode, "Failed to get operation property status") } + + @Test + fun testNodeTemplateContextProperty() { + log.info("************************ testNodeTemplateContextProperty **********************") + val bluePrintRuntimeService = getBluePrintRuntimeService() + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1", + jsonNodeFromObject("context1-value")) + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2", + jsonNodeFromObject("context2-value")) + + log.info("Context {}", bluePrintRuntimeService.context) + + val keys = listOf("context1", "context2") + + val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys) + assertNotNull(jsonValueNode, "Failed to get Json for Node Template Context Properties") + log.info("JSON Prepared Value Context {}", jsonValueNode) + + } + + private fun getBluePrintRuntimeService(): BluePrintRuntimeService { + val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! + .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + + return BluePrintRuntimeService(bluePrintContext, context) + } + } \ No newline at end of file -- cgit 1.2.3-korg From cb0fe8c1d1ef6962a2e96cea9838454e28adccbe Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 12 Sep 2018 16:26:31 +0000 Subject: Controller Blueprints Microservice Add dynamic resource source mapping rest service. Change-Id: I59274a4c0162bc6718c4248788c0e7f36830a129 Issue-ID: CCSDK-556 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../resource/dict/ResourceDefinition.kt | 6 ++ .../dict/factory/ResourceSourceMappingFactory.kt | 47 ++++++++++++ .../service/ResourceAssignmentEnhancerService.kt | 86 ---------------------- .../factory/ResourceSourceMappingFactoryTest.java | 42 +++++++++++ .../ResourceAssignmentEnhancerServiceTest.java | 48 ------------ .../src/test/resources/enrich/simple-enrich.json | 37 ---------- 6 files changed, 95 insertions(+), 171 deletions(-) create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt create mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java delete mode 100644 components/resource-dict/src/test/resources/enrich/simple-enrich.json diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt index ff2608711..d141ed0cb 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications Copyright © 2017-2018 AT&T Intellectual Property. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,3 +93,8 @@ open class ResourceAssignment { * Default Source, Database Source, Rest Sources, etc) */ interface ResourceSource : Serializable + + +open class ResourceSourceMapping { + lateinit var resourceSourceMappings: MutableMap +} diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt new file mode 100644 index 000000000..2911ab26a --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt @@ -0,0 +1,47 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping + +/** + * ResourceSourceMappingFactory. + * + * @author Brinda Santh + */ +object ResourceSourceMappingFactory { + + private val resourceSourceMappings: MutableMap = hashMapOf() + + fun registerSourceMapping(sourceInstance: String, nodeTypeName: String) { + resourceSourceMappings[sourceInstance] = nodeTypeName + } + + fun getRegisterSourceMapping(sourceInstance: String): String { + return resourceSourceMappings[sourceInstance] + ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance)) + } + + fun getRegisterSourceMapping(): ResourceSourceMapping { + val resourceSourceMapping = ResourceSourceMapping() + resourceSourceMapping.resourceSourceMappings = resourceSourceMappings + return resourceSourceMapping + } +} + diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt deleted file mode 100644 index c5a78a9c9..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service - -import com.att.eelf.configuration.EELFLogger -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import com.att.eelf.configuration.EELFManager - -/** - * ResourceAssignmentEnhancerService. - * - * @author Brinda Santh - */ -interface ResourceAssignmentEnhancerService { - - @Throws(BluePrintException::class) - fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, - resourceAssignments: List) - - @Throws(BluePrintException::class) - fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate -} - -/** - * ResourceAssignmentEnhancerDefaultService. - * - * @author Brinda Santh - */ -open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) - : ResourceAssignmentEnhancerService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) - - /** - * Get the defined source instance from the ResourceAssignment, - * then get the NodeType of the Sources assigned - */ - override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, - resourceAssignments: List) { - - // Iterate the Resource Assignment and - resourceAssignments.map { resourceAssignment -> - val dictionaryName = resourceAssignment.dictionaryName!! - val dictionarySource = resourceAssignment.dictionarySource!! - log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name, - dictionaryName, dictionarySource) - // Get the Resource Definition from Repo - val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName) - - val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource) - - // Enrich as NodeTemplate - bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!) - } - } - - override fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate { - val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService) - bluePrintEnhancerService.serviceTemplate = ServiceTemplate() - bluePrintEnhancerService.initialCleanUp() - enhanceBluePrint(bluePrintEnhancerService, resourceAssignments) - return bluePrintEnhancerService.serviceTemplate - } - - private fun getResourceDefinition(name: String): ResourceDefinition { - return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!! - } -} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java new file mode 100644 index 000000000..b67aa7998 --- /dev/null +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory; + +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; +import org.springframework.util.Assert; + +public class ResourceSourceMappingFactoryTest { + + @Test + public void testRegisterResourceMapping() { + + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); + + String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("db"); + Assert.notNull(nodeTypeName, "Failed to get db mapping"); + + ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); + Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); + Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings"); + + } + +} diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java deleted file mode 100644 index 57c8509d1..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerServiceTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; - -import java.util.List; - -/** - * ResourceAssignmentEnhancerService. - * - * @author Brinda Santh - */ -public class ResourceAssignmentEnhancerServiceTest { - - @Test - public void testEnhanceBluePrint() throws BluePrintException { - - List resourceAssignments = JacksonReactorUtils - .getListFromClassPathFile("enrich/simple-enrich.json", ResourceAssignment.class).block(); - Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments); - ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load"); - ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = - new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService); - ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments); - Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate); - } -} - diff --git a/components/resource-dict/src/test/resources/enrich/simple-enrich.json b/components/resource-dict/src/test/resources/enrich/simple-enrich.json deleted file mode 100644 index 641da80a2..000000000 --- a/components/resource-dict/src/test/resources/enrich/simple-enrich.json +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "name": "rs-db-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "db-source", - "dictionary-source": "db", - "dependencies": [ - "input-source" - ] - }, - { - "name": "ra-default-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "default-source", - "dictionary-source": "default", - "dependencies": [] - }, - { - "name": "ra-input-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "input-source", - "dictionary-source": "input", - "dependencies": [] - } -] -- cgit 1.2.3-korg From d082ba55645cd4765c0189c591db2f2e8f654520 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Sep 2018 00:20:34 +0000 Subject: Controller Blueprints Microservice Add resource assignment enhancement and validation to blueprint validation and enhancement. Change-Id: I547760012e7014cfbb7a1e3a1d8ffb77edc9b6a2 Issue-ID: CCSDK-562 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../controllerblueprints/core/BluePrintTypes.kt | 10 + .../core/factory/BluePrintEnhancerFactory.kt | 45 ---- .../core/service/BluePrintEnhancerService.kt | 271 --------------------- .../core/service/BluePrintRepoService.kt | 20 +- .../core/service/BluePrintEnhancerServiceTest.kt | 41 ---- .../service/ResourceAssignmentValidationService.kt | 9 + .../dict/service/ResourceDefinitionRepoService.kt | 3 + 7 files changed, 32 insertions(+), 367 deletions(-) delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index e25b3eea9..a971898d3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.core +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition + /** * * @@ -104,6 +106,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) validTypes.add(BluePrintConstants.DATA_TYPE_NULL) validTypes.add(BluePrintConstants.DATA_TYPE_LIST) + validTypes.add(BluePrintConstants.DATA_TYPE_MAP) return validTypes } @@ -127,6 +130,13 @@ object BluePrintTypes { return validTypes } + @JvmStatic + fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean { + val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL + return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type) + && BluePrintTypes.validPrimitiveTypes().contains(entrySchema) + } + @JvmStatic fun validCommands(): List { return listOf(BluePrintConstants.EXPRESSION_GET_INPUT, diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt deleted file mode 100644 index d796597be..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.factory - -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager - - -/** - * BluePrintEnhancerFactory - * @author Brinda Santh - * - */ - -object BluePrintEnhancerFactory { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - var bluePrintEnhancerServices: MutableMap = HashMap() - - fun register(key: String, bluePrintEnhancerService: BluePrintEnhancerService) { - bluePrintEnhancerServices[key] = bluePrintEnhancerService - } - - /** - * Called by clients to get a Blueprint Parser for the Blueprint parser type - */ - fun instance(key: String): BluePrintEnhancerService? { - return bluePrintEnhancerServices.get(key) - } -} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt deleted file mode 100644 index b125c594c..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.format -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils -import java.io.Serializable - -/** - * BluePrintEnhancerService - * @author Brinda Santh - * - */ -interface BluePrintEnhancerService : Serializable { - - @Throws(BluePrintException::class) - fun enhance(content: String): ServiceTemplate - - /** - * Read Blueprint from CSAR structure Directory - */ - @Throws(BluePrintException::class) - fun enhance(fileName: String, basePath: String): ServiceTemplate - - @Throws(BluePrintException::class) - fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate - - @Throws(BluePrintException::class) - fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) - - @Throws(BluePrintException::class) - fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) - - @Throws(BluePrintException::class) - fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) -} - -open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString()) - - lateinit var serviceTemplate: ServiceTemplate - - @Throws(BluePrintException::class) - override fun enhance(content: String): ServiceTemplate { - return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate -> - enhance(serviceTemplate!!) - }.block()!! - } - - @Throws(BluePrintException::class) - override fun enhance(fileName: String, basePath: String): ServiceTemplate { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - @Throws(BluePrintException::class) - override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate { - this.serviceTemplate = serviceTemplate - initialCleanUp() - enrichTopologyTemplate(serviceTemplate) - - // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true)) - return this.serviceTemplate - } - - open fun initialCleanUp() { - serviceTemplate.artifactTypes?.clear() - serviceTemplate.nodeTypes?.clear() - serviceTemplate.dataTypes?.clear() - - serviceTemplate.artifactTypes = HashMap() - serviceTemplate.nodeTypes = HashMap() - serviceTemplate.dataTypes = HashMap() - - } - - @Throws(BluePrintException::class) - open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) { - serviceTemplate.topologyTemplate?.let { topologyTemplate -> - enrichTopologyTemplateInputs(topologyTemplate) - enrichTopologyTemplateNodeTemplates(topologyTemplate) - } - } - - @Throws(BluePrintException::class) - open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) { - topologyTemplate.inputs?.let { inputs -> - enrichPropertyDefinitions(inputs) - } - } - - open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) { - topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate -> - enrichNodeTemplate(nodeTemplateName, nodeTemplate) - } - } - - @Throws(BluePrintException::class) - override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { - val nodeTypeName = nodeTemplate.type - // Get NodeType from Repo and Update Service Template - val nodeType = populateNodeType(nodeTypeName) - - // Enrich NodeType - enrichNodeType(nodeTypeName, nodeType) - - //Enrich Node Template Artifacts - enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate) - } - - @Throws(BluePrintException::class) - override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) { - log.debug("Enriching NodeType({})", nodeTypeName) - val derivedFrom = nodeType.derivedFrom - - if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { - val derivedFromNodeType = populateNodeType(nodeTypeName) - // Enrich NodeType - enrichNodeType(derivedFrom, derivedFromNodeType) - } - - // NodeType Property Definitions - enrichNodeTypeProperties(nodeTypeName, nodeType) - - //NodeType Requirement - enrichNodeTypeRequirements(nodeTypeName, nodeType) - - //NodeType Capability - enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType) - - //NodeType Interface - enrichNodeTypeInterfaces(nodeTypeName, nodeType) - } - - open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) { - nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) } - } - - open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) { - - nodeType.requirements?.forEach { _, requirementDefinition -> - // Populate Requirement Node - requirementDefinition.node?.let { requirementNodeTypeName -> - // Get Requirement NodeType from Repo and Update Service Template - val requirementNodeType = populateNodeType(requirementNodeTypeName) - - enrichNodeType(requirementNodeTypeName, requirementNodeType) - } - } - } - - open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) { - nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition -> - capabilityDefinition.properties?.let { properties -> - enrichPropertyDefinitions(properties) - } - } - } - - open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) { - nodeType.interfaces?.forEach { interfaceName, interfaceObj -> - // Populate Node type Interface Operation - log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName) - populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj) - - } - } - - open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) { - - interfaceObj.operations?.forEach { operationName, operation -> - enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation) - enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation) - } - } - - open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) { - operation.inputs?.let { inputs -> - enrichPropertyDefinitions(inputs) - } - } - - open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) { - operation.outputs?.let { inputs -> - enrichPropertyDefinitions(inputs) - } - } - - open fun enrichPropertyDefinitions(properties: MutableMap) { - - properties.forEach { propertyName, propertyDefinition -> - enrichPropertyDefinition(propertyName, propertyDefinition) - } - } - - @Throws(BluePrintException::class) - override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) { - val propertyType = propertyDefinition.type - if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { - - } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { - val entrySchema = propertyDefinition.entrySchema - ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName)) - - if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) { - populateDataTypes(entrySchema.type) - } - } else { - populateDataTypes(propertyType) - } - - } - - open fun enrichNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) { - - nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition -> - val artifactTypeName = artifactDefinition.type - ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName)) - - // Populate Artifact Type - populateArtifactType(artifactTypeName) - } - } - - open fun populateNodeType(nodeTypeName: String): NodeType { - - val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName) - ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block() - ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName)) - serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType) - return nodeType - } - - open fun populateArtifactType(artifactTypeName: String): ArtifactType { - val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block() - ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName)) - serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType) - return artifactType - } - - open fun populateDataTypes(dataTypeName: String): DataType { - val dataType = serviceTemplate.dataTypes?.get(dataTypeName) - ?: bluePrintRepoService.getDataType(dataTypeName)?.block() - ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName)) - serviceTemplate.dataTypes?.put(dataTypeName, dataType) - return dataType - } - -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt index a7c14adfe..dec7a50df 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt @@ -35,19 +35,19 @@ import java.io.Serializable interface BluePrintRepoService : Serializable { @Throws(BluePrintException::class) - fun getNodeType(nodeTypeName: String): Mono? + fun getNodeType(nodeTypeName: String): Mono @Throws(BluePrintException::class) - fun getDataType(dataTypeName: String): Mono? + fun getDataType(dataTypeName: String): Mono @Throws(BluePrintException::class) - fun getArtifactType(artifactTypeName: String): Mono? + fun getArtifactType(artifactTypeName: String): Mono @Throws(BluePrintException::class) - fun getRelationshipType(relationshipTypeName: String): Mono? + fun getRelationshipType(relationshipTypeName: String): Mono @Throws(BluePrintException::class) - fun getCapabilityDefinition(capabilityDefinitionName: String): Mono? + fun getCapabilityDefinition(capabilityDefinitionName: String): Mono } @@ -63,30 +63,30 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) private val extension = ".json" - override fun getDataType(dataTypeName: String): Mono? { + override fun getDataType(dataTypeName: String): Mono { val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(dataTypeName).plus(extension) return getModelType(fileName, DataType::class.java) } - override fun getNodeType(nodeTypeName: String): Mono? { + override fun getNodeType(nodeTypeName: String): Mono { val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) return getModelType(fileName, NodeType::class.java) } - override fun getArtifactType(artifactTypeName: String): Mono? { + override fun getArtifactType(artifactTypeName: String): Mono { val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(artifactTypeName).plus(extension) return getModelType(fileName, ArtifactType::class.java) } - override fun getRelationshipType(relationshipTypeName: String): Mono? { + override fun getRelationshipType(relationshipTypeName: String): Mono { val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(relationshipTypeName).plus(extension) return getModelType(fileName, RelationshipType::class.java) } - override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono? { + override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono { val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(capabilityDefinitionName).plus(extension) return getModelType(fileName, CapabilityDefinition::class.java) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt deleted file mode 100644 index 8e6d5efdf..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils - -/** - * BluePrintEnhancerServiceTest - * @author Brinda Santh - * - */ - -class BluePrintEnhancerServiceTest { - val basePath = "load/model_type" - - @Test - fun testEnrichBlueprint() { - val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath) - val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService) - - val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json") - bluePrintEnhancerService.enhance(serviceTemplate) - - } -} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index fae509d25..089fce0b1 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -25,6 +25,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory import java.io.Serializable /** @@ -65,6 +67,13 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida open fun validateSources(resourceAssignments: List) { log.info("validating resource assignment sources") + resourceAssignments.forEach { resourceAssignment -> + try { + ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!) + } catch (e: BluePrintException) { + validationMessage.appendln(e.message + format(" for resource assignment({})", resourceAssignment.name)) + } + } } open fun validateTemplateNDictionaryKeys(resourceAssignments: List) { diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt index 370e1ec8c..6c83e5f93 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -18,11 +18,13 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import reactor.core.publisher.Mono + /** * ResourceDefinitionRepoService. * @@ -30,6 +32,7 @@ import reactor.core.publisher.Mono */ interface ResourceDefinitionRepoService : BluePrintRepoService { + @Throws(BluePrintException::class) fun getResourceDefinition(resourceDefinitionName: String): Mono } -- cgit 1.2.3-korg From 575d9dc91a7419d03344997b55633d2b3c5cf53b Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Sep 2018 14:25:49 +0000 Subject: Controller Blueprints Microservice Optimise dictionary dummy data creation reusability and property usage optimisation. Change-Id: Ibbd56d514f437f29943cebc0e607becb6798e4b6 Issue-ID: CCSDK-491 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/service/BluePrintContext.kt | 6 ++--- .../core/service/BluePrintExpressionService.kt | 2 +- .../core/service/BluePrintRuntimeService.kt | 2 +- .../core/service/BluePrintValidatorService.kt | 10 ++++---- .../core/utils/BluePrintRuntimeUtils.kt | 2 +- .../core/service/BluePrintRepoFileServiceTest.kt | 8 +++--- .../service/ResourceAssignmentValidationService.kt | 5 ++++ .../service/ResourceDefinitionValidationService.kt | 4 +-- .../dict/utils/ResourceDictionaryTestUtils.kt | 30 ++++++++++++++++++++++ .../ResourceAssignmentValidationServiceTest.kt | 9 +++++++ 10 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 875cbea61..46da9d95a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -71,7 +71,7 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { } fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition? { - return nodeTypeByName(nodeTypeName).interfaces?.values?.first() + return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName) } fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition? { @@ -155,9 +155,9 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { } fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate { - val nodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node + val requirementNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node ?: throw BluePrintException(String.format("failed to get node name for node template's (%s) requirement's (%s) " + nodeTemplateName, requirementName)) - return nodeTemplateByName(nodeTemplateName) + return nodeTemplateByName(requirementNodeTemplateName) } fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt index 82e232d0e..6a50680e6 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -99,7 +99,7 @@ object BluePrintExpressionService { arrayNode.size() > 3 -> { reqOrCapEntityName = arrayNode[1].textValue() propertyName = arrayNode[2].textValue() - val propertyPaths: List = arrayNode.filterIndexed { index, obj -> + val propertyPaths: List = arrayNode.filterIndexed { index, _ -> index >= 3 }.map { it.textValue() } subProperty = propertyPaths.joinToString("/") diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 1fdb6c3ce..2485abdb5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -308,7 +308,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString()) - bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, property -> + bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, _ -> val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) ?: NullNode.getInstance() setWorkflowInputValue(workflowName, propertyName, valueNode) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 3bea59f9d..7ad38332a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -236,7 +236,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { message.appendln("---> Workflow :" + paths.joinToString(separator)) // Step Validation Start paths.add("steps") - workflow.steps?.forEach { stepName, step -> + workflow.steps?.forEach { stepName, _ -> paths.add(stepName) message.appendln("----> Steps :" + paths.joinToString(separator)) paths.removeAt(paths.lastIndex) @@ -583,10 +583,10 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { } } - private fun checkPropertyDataType(dataType: String, propertyName: String) { + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { - val dataType = serviceTemplate.dataTypes?.get(dataType) - ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataType, propertyName)) + val dataType = serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) @@ -596,7 +596,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { return true } else { - throw BluePrintException(format("DataType ({}) for the property ({}) is not valid", dataType)) + throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt index 07b819ffe..0e4c3e3e8 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -43,7 +43,7 @@ object BluePrintRuntimeUtils { fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) - bluePrintContext.inputs?.forEach { propertyName, property -> + bluePrintContext.inputs?.forEach { propertyName, _ -> val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index 88aea919e..b8cfdd408 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -33,25 +33,25 @@ class BluePrintRepoFileServiceTest { @Test fun testGetDataType() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate")?.block() + val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate").block() assertNotNull(dataType, "Failed to get DataType from repo") } @Test fun testGetNodeType() { - val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment")?.block() + val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment").block() assertNotNull(nodeType, "Failed to get NodeType from repo") } @Test fun testGetArtifactType() { - val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity")?.block() + val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity").block() assertNotNull(nodeType, "Failed to get ArtifactType from repo") } @Test(expected = FileNotFoundException::class) fun testModelNotFound() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found")?.block() + val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found").block() assertNotNull(dataType, "Failed to get DataType from repo") } } \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index 089fce0b1..fc7f1092d 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -67,6 +67,7 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida open fun validateSources(resourceAssignments: List) { log.info("validating resource assignment sources") + // Check the Resource Assignment Source(Dynamic Instance) is valid. resourceAssignments.forEach { resourceAssignment -> try { ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!) @@ -80,6 +81,7 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap() + // Check the Resource Assignment has Duplicate Key Names val duplicateKeyNames = resourceAssignments.groupBy { it.name } .filter { it.value.size > 1 } .map { it.key } @@ -88,6 +90,7 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames)) } + // Check the Resource Assignment has Duplicate Dictionary Names val duplicateDictionaryKeyNames = resourceAssignments.groupBy { it.dictionaryName } .filter { it.value.size > 1 } .map { it.key } @@ -95,8 +98,10 @@ open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValida validationMessage.appendln(String.format("Duplicate Assignment Dictionary Keys (%s) is Present", duplicateDictionaryKeyNames)) } + // Collect all the dependencies as a single list val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten() + // Check all the dependencies keys have Resource Assignment mappings. val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct() if (notPresentDictionaries.isNotEmpty()) { validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries)) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 14855d4b6..9f45d1666 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -59,7 +59,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS resourceDefinition.sources.forEach { (name, nodeTemplate) -> val sourceType = nodeTemplate.type - val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)?.block() + val sourceNodeType = bluePrintRepoService.getNodeType(sourceType).block() ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType)) // Validate Property Name, expression, values and Data Type @@ -100,7 +100,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) } else { - bluePrintRepoService.getDataType(propertyType) + bluePrintRepoService.getDataType(propertyType).block() ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository", propertyName, propertyType)) isValid = true diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt new file mode 100644 index 000000000..bebe27d8c --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt @@ -0,0 +1,30 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory + +object ResourceDictionaryTestUtils { + + @JvmStatic + fun setUpResourceSourceMapping() { + ResourceSourceMappingFactory.registerSourceMapping("db", "source-db") + ResourceSourceMappingFactory.registerSourceMapping("input", "source-input") + ResourceSourceMappingFactory.registerSourceMapping("default", "source-default") + ResourceSourceMappingFactory.registerSourceMapping("mdsal", "source-rest") + } +} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index 6216d5bf0..87ebb700b 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -23,6 +23,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import com.att.eelf.configuration.EELFManager +import org.junit.Before +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils + /** * ResourceAssignmentValidationServiceTest. * @@ -30,6 +33,12 @@ import com.att.eelf.configuration.EELFManager */ class ResourceAssignmentValidationServiceTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) + @Before + fun setUp() { + // Setup dummy Source Instance Mapping + ResourceDictionaryTestUtils.setUpResourceSourceMapping() + } + @Test fun testValidateSuccess() { log.info("**************** testValidateSuccess *****************") -- cgit 1.2.3-korg From 67971523c0f7950f76b2a3e2f3c3228763ee7882 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 14 Sep 2018 20:07:46 +0000 Subject: Controller Blueprints Microservice Change database to mariadb in docker compose and spring boot version upgrade Change-Id: Icd73b8110aea2a1b90ab29217b9c5e30817e6c06 Issue-ID: CCSDK-574 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/parent/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index cbbeeffc1..abd979b09 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -28,9 +28,9 @@ App Components Parent pom - 2.0.4.RELEASE + 2.0.5.RELEASE 5.0.8.RELEASE - 1.2.60 + 1.2.70 1.0.0 26.0-jre 2.9.2 -- cgit 1.2.3-korg From 7b533e17764ba9932e31aae498bd6c3447cb8839 Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 21 Sep 2018 15:44:52 +0530 Subject: added version no to google guava plugin dependency to increase code coverage Issue-ID: CCSDK-591 Change-Id: I0599d001c5433ac1c63c160099090eab09bdaffa Signed-off-by: Sandeep J --- components/parent/pom.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index abd979b09..1528f18e7 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -186,10 +186,11 @@ com.jayway.jsonpath json-path - - com.google.guava - guava - + + com.google.guava + guava + 26.0-jre + io.springfox springfox-swagger2 -- cgit 1.2.3-korg From 83c8be70288614aecd64e0fadfaa0b8908a2d0b7 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 21 Sep 2018 14:31:06 -0400 Subject: SDN Controller Blueprints MS Component Adding ONAP Resource Definitions with new schema Change-Id: Ic4e1bd79dd54d12ce12f6e79ae1d738b283f3f0c Issue-ID: CCSDK-490 Signed-off-by: Singal, Kapil (ks220y) --- .../load/resource_dictionary/address.json | 17 +++++++++++ .../load/resource_dictionary/aic-cloud-region.json | 17 +++++++++++ .../load/resource_dictionary/aic_clli.json | 17 +++++++++++ .../resource_dictionary/availability_zone_0.json | 17 +++++++++++ .../load/resource_dictionary/name_0.json | 17 +++++++++++ .../load/resource_dictionary/nf-role.json | 25 ++++++++++++++++ .../load/resource_dictionary/nfc-naming-code.json | 25 ++++++++++++++++ .../resource_dictionary/onap_private_net_cidr.json | 21 +++++++++++++ .../resource_dictionary/onap_private_net_id.json | 17 +++++++++++ .../resource_dictionary/private-prefix-id.json | 21 +++++++++++++ .../resource_dictionary/protected-prefix-id.json | 21 +++++++++++++ .../protected_private_net_cidr.json | 21 +++++++++++++ .../load/resource_dictionary/public_net_id.json | 17 +++++++++++ .../resource_dictionary/service-instance-id.json | 17 +++++++++++ .../resource_dictionary/unprotected-prefix-id.json | 21 +++++++++++++ .../unprotected_private_net_cidr.json | 21 +++++++++++++ .../load/resource_dictionary/vf-module-id.json | 17 +++++++++++ .../load/resource_dictionary/vf-module-label.json | 25 ++++++++++++++++ .../vf-module-model-customization-uuid.json | 17 +++++++++++ .../load/resource_dictionary/vf-module-type.json | 25 ++++++++++++++++ .../load/resource_dictionary/vf-naming-policy.json | 25 ++++++++++++++++ .../load/resource_dictionary/vf-nf-code.json | 25 ++++++++++++++++ .../load/resource_dictionary/vf_module_name.json | 17 +++++++++++ .../resource_dictionary/vfccustomizationuuid.json | 25 ++++++++++++++++ .../load/resource_dictionary/vfw_private_ip_0.json | 35 ++++++++++++++++++++++ .../load/resource_dictionary/vfw_private_ip_1.json | 35 ++++++++++++++++++++++ .../load/resource_dictionary/vfw_private_ip_2.json | 17 +++++++++++ .../load/resource_dictionary/vm-type.json | 25 ++++++++++++++++ .../load/resource_dictionary/vnf-id.json | 17 +++++++++++ .../vnf-model-customization-uuid.json | 17 +++++++++++ .../load/resource_dictionary/vnf-name.json | 28 +++++++++++++++++ .../load/resource_dictionary/vnf_name.json | 28 +++++++++++++++++ .../vnfc-model-invariant-uuid.json | 25 ++++++++++++++++ .../resource_dictionary/vnfc-model-version.json | 25 ++++++++++++++++ .../load/resource_dictionary/vpg_private_ip_0.json | 35 ++++++++++++++++++++++ .../load/resource_dictionary/vpg_private_ip_1.json | 17 +++++++++++ .../load/resource_dictionary/vsn_private_ip_0.json | 35 ++++++++++++++++++++++ .../load/resource_dictionary/vsn_private_ip_1.json | 17 +++++++++++ 38 files changed, 844 insertions(+) create mode 100644 components/resource-dict/load/resource_dictionary/address.json create mode 100644 components/resource-dict/load/resource_dictionary/aic-cloud-region.json create mode 100644 components/resource-dict/load/resource_dictionary/aic_clli.json create mode 100644 components/resource-dict/load/resource_dictionary/availability_zone_0.json create mode 100644 components/resource-dict/load/resource_dictionary/name_0.json create mode 100644 components/resource-dict/load/resource_dictionary/nf-role.json create mode 100644 components/resource-dict/load/resource_dictionary/nfc-naming-code.json create mode 100644 components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json create mode 100644 components/resource-dict/load/resource_dictionary/onap_private_net_id.json create mode 100644 components/resource-dict/load/resource_dictionary/private-prefix-id.json create mode 100644 components/resource-dict/load/resource_dictionary/protected-prefix-id.json create mode 100644 components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json create mode 100644 components/resource-dict/load/resource_dictionary/public_net_id.json create mode 100644 components/resource-dict/load/resource_dictionary/service-instance-id.json create mode 100644 components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json create mode 100644 components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json create mode 100644 components/resource-dict/load/resource_dictionary/vf-module-id.json create mode 100644 components/resource-dict/load/resource_dictionary/vf-module-label.json create mode 100644 components/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json create mode 100644 components/resource-dict/load/resource_dictionary/vf-module-type.json create mode 100644 components/resource-dict/load/resource_dictionary/vf-naming-policy.json create mode 100644 components/resource-dict/load/resource_dictionary/vf-nf-code.json create mode 100644 components/resource-dict/load/resource_dictionary/vf_module_name.json create mode 100644 components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json create mode 100644 components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json create mode 100644 components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json create mode 100644 components/resource-dict/load/resource_dictionary/vfw_private_ip_2.json create mode 100644 components/resource-dict/load/resource_dictionary/vm-type.json create mode 100644 components/resource-dict/load/resource_dictionary/vnf-id.json create mode 100644 components/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json create mode 100644 components/resource-dict/load/resource_dictionary/vnf-name.json create mode 100644 components/resource-dict/load/resource_dictionary/vnf_name.json create mode 100644 components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json create mode 100644 components/resource-dict/load/resource_dictionary/vnfc-model-version.json create mode 100644 components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json create mode 100644 components/resource-dict/load/resource_dictionary/vpg_private_ip_1.json create mode 100644 components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json create mode 100644 components/resource-dict/load/resource_dictionary/vsn_private_ip_1.json diff --git a/components/resource-dict/load/resource_dictionary/address.json b/components/resource-dict/load/resource_dictionary/address.json new file mode 100644 index 000000000..e999938cf --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/address.json @@ -0,0 +1,17 @@ +{ + "name" : "address", + "tags" : "address", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "address", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "address" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/aic-cloud-region.json b/components/resource-dict/load/resource_dictionary/aic-cloud-region.json new file mode 100644 index 000000000..da2c7440a --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/aic-cloud-region.json @@ -0,0 +1,17 @@ +{ + "name" : "aic-cloud-region", + "tags" : "aic-cloud-region", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "aic-cloud-region", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "aic-cloud-region" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/aic_clli.json b/components/resource-dict/load/resource_dictionary/aic_clli.json new file mode 100644 index 000000000..182d70614 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/aic_clli.json @@ -0,0 +1,17 @@ +{ + "name" : "aic_clli", + "tags" : "aic_clli", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "aic_clli", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "aic_clli" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/availability_zone_0.json b/components/resource-dict/load/resource_dictionary/availability_zone_0.json new file mode 100644 index 000000000..f1cebdb77 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/availability_zone_0.json @@ -0,0 +1,17 @@ +{ + "name" : "availability_zone_0", + "tags" : "availability_zone_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "availability_zone_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "availability_zone_0" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/name_0.json b/components/resource-dict/load/resource_dictionary/name_0.json new file mode 100644 index 000000000..2392c3dc7 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/name_0.json @@ -0,0 +1,17 @@ +{ + "name" : "name_0", + "tags" : "name_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "name_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "name_0" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/nf-role.json b/components/resource-dict/load/resource_dictionary/nf-role.json new file mode 100644 index 000000000..0e108c5cb --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/nf-role.json @@ -0,0 +1,25 @@ +{ + "name" : "nf-role", + "tags" : "nf-role", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf/nf-role", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid", + "input-key-mapping" : { + "vnfmodelcustomizationuuid" : "vnf-model-customization-uuid" + }, + "output-key-mapping" : { + "nf-role" : "vf_model_role" + }, + "key-dependencies" : [ "vnf-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/nfc-naming-code.json b/components/resource-dict/load/resource_dictionary/nfc-naming-code.json new file mode 100644 index 000000000..f0f2b7f0f --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/nfc-naming-code.json @@ -0,0 +1,25 @@ +{ + "name" : "nfc-naming-code", + "tags" : "nfc-naming-code", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "nfc-naming-code", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "nfc-naming-code" : "nfc_naming_code" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json new file mode 100644 index 000000000..07c5cbc18 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json @@ -0,0 +1,21 @@ +{ + "name" : "onap_private_net_cidr", + "tags" : "onap_private_net_cidr", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "onap_private_net_cidr", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = private", + "output-key-mapping" : { + "onap_private_net_cidr" : "prefix" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/onap_private_net_id.json b/components/resource-dict/load/resource_dictionary/onap_private_net_id.json new file mode 100644 index 000000000..4e430f465 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/onap_private_net_id.json @@ -0,0 +1,17 @@ +{ + "name" : "onap_private_net_id", + "tags" : "onap_private_net_id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "onap_private_net_id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "onap_private_net_id" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/private-prefix-id.json b/components/resource-dict/load/resource_dictionary/private-prefix-id.json new file mode 100644 index 000000000..a95bae308 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/private-prefix-id.json @@ -0,0 +1,21 @@ +{ + "name" : "private-prefix-id", + "tags" : "private-prefix-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "private-prefix-id", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = private", + "output-key-mapping" : { + "private-prefix-id" : "prefix_id" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/protected-prefix-id.json b/components/resource-dict/load/resource_dictionary/protected-prefix-id.json new file mode 100644 index 000000000..56b0d6d21 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/protected-prefix-id.json @@ -0,0 +1,21 @@ +{ + "name" : "protected-prefix-id", + "tags" : "protected-prefix-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "protected-prefix-id", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = protected", + "output-key-mapping" : { + "protected-prefix-id" : "prefix_id" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json new file mode 100644 index 000000000..db0a43dc5 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json @@ -0,0 +1,21 @@ +{ + "name" : "protected_private_net_cidr", + "tags" : "protected_private_net_cidr", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "protected_private_net_cidr", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = protected", + "output-key-mapping" : { + "protected_private_net_cidr" : "prefix" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/public_net_id.json b/components/resource-dict/load/resource_dictionary/public_net_id.json new file mode 100644 index 000000000..17ad96bdb --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/public_net_id.json @@ -0,0 +1,17 @@ +{ + "name" : "public_net_id", + "tags" : "public_net_id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "public_net_id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "public_net_id" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/service-instance-id.json b/components/resource-dict/load/resource_dictionary/service-instance-id.json new file mode 100644 index 000000000..ed583be73 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/service-instance-id.json @@ -0,0 +1,17 @@ +{ + "name" : "service-instance-id", + "tags" : "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "To be provided", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "service-instance-id" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json b/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json new file mode 100644 index 000000000..a0d966a2c --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json @@ -0,0 +1,21 @@ +{ + "name" : "unprotected-prefix-id", + "tags" : "unprotected-prefix-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "unprotected-prefix-id", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = unprotected", + "output-key-mapping" : { + "unprotected-prefix-id" : "prefix_id" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json new file mode 100644 index 000000000..8f9385d87 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json @@ -0,0 +1,21 @@ +{ + "name" : "unprotected_private_net_cidr", + "tags" : "unprotected_private_net_cidr", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "unprotected_private_net_cidr", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = unprotected", + "output-key-mapping" : { + "unprotected_private_net_cidr" : "prefix" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf-module-id.json b/components/resource-dict/load/resource_dictionary/vf-module-id.json new file mode 100644 index 000000000..0e1d771ff --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf-module-id.json @@ -0,0 +1,17 @@ +{ + "name" : "vf-module-id", + "tags" : "vf-module-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vf-module-id" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf-module-label.json b/components/resource-dict/load/resource_dictionary/vf-module-label.json new file mode 100644 index 000000000..a9543722c --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf-module-label.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-module-label", + "tags" : "vf-module-label", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-label", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", + "input-key-mapping" : { + "customizationid" : "vf-module-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-module-label" : "vf_module_label" + }, + "key-dependencies" : [ "vf-module-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json b/components/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json new file mode 100644 index 000000000..f41c781cf --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json @@ -0,0 +1,17 @@ +{ + "name" : "vf-module-model-customization-uuid", + "tags" : "vf-module-model-customization-uuid", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-model-customization-uuid", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vf-module-model-customization-uuid" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf-module-type.json b/components/resource-dict/load/resource_dictionary/vf-module-type.json new file mode 100644 index 000000000..805d834b5 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf-module-type.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-module-type", + "tags" : "vf-module-type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-type", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", + "input-key-mapping" : { + "customizationid" : "vf-module-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-module-type" : "vf_module_type" + }, + "key-dependencies" : [ "vf-module-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf-naming-policy.json b/components/resource-dict/load/resource_dictionary/vf-naming-policy.json new file mode 100644 index 000000000..ceed3186c --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf-naming-policy.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-naming-policy", + "tags" : "vf-naming-policy", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-naming-policy", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", + "input-key-mapping" : { + "vnf_model_customization_uuid" : "vnf-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-naming-policy" : "vf_naming_policy" + }, + "key-dependencies" : [ "vnf-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf-nf-code.json b/components/resource-dict/load/resource_dictionary/vf-nf-code.json new file mode 100644 index 000000000..0d25d0e94 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf-nf-code.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-nf-code", + "tags" : "vf-nf-code", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-nf-code", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid", + "input-key-mapping" : { + "customizationid" : "vnf-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-nf-code" : "vf_nf_code" + }, + "key-dependencies" : [ "vnf-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vf_module_name.json b/components/resource-dict/load/resource_dictionary/vf_module_name.json new file mode 100644 index 000000000..b416f5295 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vf_module_name.json @@ -0,0 +1,17 @@ +{ + "name" : "vf_module_name", + "tags" : "vf_module_name", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf_module_name", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vf_module_name" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json b/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json new file mode 100644 index 000000000..a34a9a783 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json @@ -0,0 +1,25 @@ +{ + "name" : "vfccustomizationuuid", + "tags" : "vfccustomizationuuid, tosca.datatypes.Root, data_type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfccustomizationuuid", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", + "input-key-mapping" : { + "vfmodulecustomizationuuid" : "vf-module-model-customization-uuid" + }, + "output-key-mapping" : { + "vfccustomizationuuid" : "vnf_customid" + }, + "key-dependencies" : [ "vf-module-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json b/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json new file mode 100644 index 000000000..7c8d4f4e8 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json @@ -0,0 +1,35 @@ +{ + "name" : "vfw_private_ip_0", + "tags" : "vfw_private_ip_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfw_private_ip_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vfw_private_ip_0" + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vfw_private_ip_0", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id", + "vf-module-id" : "vf-module-id" + }, + "output-key-mapping" : { + "vfw_private_ip_0" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json b/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json new file mode 100644 index 000000000..0553b8c37 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json @@ -0,0 +1,35 @@ +{ + "name" : "vfw_private_ip_1", + "tags" : "vfw_private_ip_1", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfw_private_ip_1", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vfw_private_ip_1" + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vfw_private_ip_1", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id", + "vf-module-id" : "vf-module-id" + }, + "output-key-mapping" : { + "vfw_private_ip_1" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vfw_private_ip_2.json b/components/resource-dict/load/resource_dictionary/vfw_private_ip_2.json new file mode 100644 index 000000000..9e5106470 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vfw_private_ip_2.json @@ -0,0 +1,17 @@ +{ + "name" : "vfw_private_ip_2", + "tags" : "vfw_private_ip_2", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfw_private_ip_2", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vfw_private_ip_2" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vm-type.json b/components/resource-dict/load/resource_dictionary/vm-type.json new file mode 100644 index 000000000..7bb5ef1cc --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vm-type.json @@ -0,0 +1,25 @@ +{ + "name" : "vm-type", + "tags" : "vm-type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vm-type", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select vfc_model.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "vm-type" : "vm_type" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vnf-id.json b/components/resource-dict/load/resource_dictionary/vnf-id.json new file mode 100644 index 000000000..55c24b5fa --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vnf-id.json @@ -0,0 +1,17 @@ +{ + "name" : "vnf-id", + "tags" : "vnf-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf-id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vnf-id" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json b/components/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json new file mode 100644 index 000000000..f6c3b8144 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json @@ -0,0 +1,17 @@ +{ + "name" : "vnf-model-customization-uuid", + "tags" : "vnf-model-customization-uuid", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf-model-customization-uuid", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vnf-model-customization-uuid" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vnf-name.json b/components/resource-dict/load/resource_dictionary/vnf-name.json new file mode 100644 index 000000000..47371d184 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vnf-name.json @@ -0,0 +1,28 @@ +{ + "name" : "vnf-name", + "tags" : "vnf-name, tosca.datatypes.Root, data_type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf-name", + "type" : "string" + }, + "sources" : { + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vnf-name" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vnf_name.json b/components/resource-dict/load/resource_dictionary/vnf_name.json new file mode 100644 index 000000000..4617a264e --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vnf_name.json @@ -0,0 +1,28 @@ +{ + "name" : "vnf_name", + "tags" : "vnf_name", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf_name", + "type" : "string" + }, + "sources" : { + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vnf_name" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json b/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json new file mode 100644 index 000000000..b2ccd45da --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json @@ -0,0 +1,25 @@ +{ + "name" : "vnfc-model-invariant-uuid", + "tags" : "vnfc-model-invariant-uuid", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnfc-model-invariant-uuid for vFW template", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select vfc_model.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "vnfc-model-invariant-uuid" : "vfc_invariant_uuid" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vnfc-model-version.json b/components/resource-dict/load/resource_dictionary/vnfc-model-version.json new file mode 100644 index 000000000..fb59eea7f --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vnfc-model-version.json @@ -0,0 +1,25 @@ +{ + "name" : "vnfc-model-version", + "tags" : "vnfc-model-version", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnfc-model-version for vFW template", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select vfc_model.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "vnfc-model-version" : "vnfc_model_version" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json b/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json new file mode 100644 index 000000000..912cfb9ad --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json @@ -0,0 +1,35 @@ +{ + "name" : "vpg_private_ip_0", + "tags" : "vpg_private_ip_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vpg_private_ip_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vpg_private_ip_0" + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vpg_private_ip_0", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id", + "vf-module-id" : "vf-module-id" + }, + "output-key-mapping" : { + "vpg_private_ip_0" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vpg_private_ip_1.json b/components/resource-dict/load/resource_dictionary/vpg_private_ip_1.json new file mode 100644 index 000000000..23c42e0c7 --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vpg_private_ip_1.json @@ -0,0 +1,17 @@ +{ + "name" : "vpg_private_ip_1", + "tags" : "vpg_private_ip_1", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vpg_private_ip_1", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vpg_private_ip_1" + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json b/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json new file mode 100644 index 000000000..bf987382c --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json @@ -0,0 +1,35 @@ +{ + "name" : "vsn_private_ip_0", + "tags" : "vsn_private_ip_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vsn_private_ip_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vsn_private_ip_0" + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vsn_private_ip_0", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id", + "vf-module-id" : "vf-module-id" + }, + "output-key-mapping" : { + "vsn_private_ip_0" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/vsn_private_ip_1.json b/components/resource-dict/load/resource_dictionary/vsn_private_ip_1.json new file mode 100644 index 000000000..88750b25e --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/vsn_private_ip_1.json @@ -0,0 +1,17 @@ +{ + "name" : "vsn_private_ip_1", + "tags" : "vsn_private_ip_1", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vsn_private_ip_1", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + "key" : "vsn_private_ip_1" + } + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From 95ab8b7eb99ca00532bdbd2ad5dc3e78f3f8384a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 27 Sep 2018 16:26:45 -0400 Subject: Roll to next snapshot version Roll to next snapshot version Change-Id: Ifbbe4c890c47001d60117f09a67daa278d57dcd4 Issue-ID: CCSDK-597 Signed-off-by: Timoney, Dan (dt5972) --- components/core/pom.xml | 2 +- components/parent/pom.xml | 2 +- components/pom.xml | 2 +- components/resource-dict/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/core/pom.xml b/components/core/pom.xml index fc6624e72..99778c0b5 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.components parent - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT ../parent org.onap.ccsdk.apps.controllerblueprints diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 1528f18e7..ee1eb7aaf 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps components - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT org.onap.ccsdk.apps.components parent diff --git a/components/pom.xml b/components/pom.xml index aada3eb1d..0da83a38e 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.apps ccsdk-apps - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT 4.0.0 org.onap.ccsdk.apps diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml index 7eecb5ee4..74226e31a 100644 --- a/components/resource-dict/pom.xml +++ b/components/resource-dict/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.components parent - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT ../parent org.onap.ccsdk.apps.controllerblueprints -- cgit 1.2.3-korg From 6f870c292d660c0fa661044c8592ddce049e1600 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 25 Oct 2018 10:34:51 -0400 Subject: Roll to initial Dublin version Roll to initial Dublin release version Change-Id: I9f56f6643bf5850a9958d46f137fa929b1c05e5d Issue-ID: CCSDK-617 Signed-off-by: Timoney, Dan (dt5972) --- components/core/pom.xml | 2 +- components/parent/pom.xml | 4 ++-- components/pom.xml | 2 +- components/resource-dict/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/core/pom.xml b/components/core/pom.xml index 99778c0b5..7c4116564 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.components parent - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT ../parent org.onap.ccsdk.apps.controllerblueprints diff --git a/components/parent/pom.xml b/components/parent/pom.xml index ee1eb7aaf..7377e7658 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps components - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT org.onap.ccsdk.apps.components parent @@ -35,7 +35,7 @@ 26.0-jre 2.9.2 1.4.197 - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/components/pom.xml b/components/pom.xml index 0da83a38e..181a7810f 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.apps ccsdk-apps - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT 4.0.0 org.onap.ccsdk.apps diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml index 74226e31a..508ae96f4 100644 --- a/components/resource-dict/pom.xml +++ b/components/resource-dict/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.components parent - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT ../parent org.onap.ccsdk.apps.controllerblueprints -- cgit 1.2.3-korg From c4dcf1aac48980494d95a5640a7ab7a3c2d345d5 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sat, 10 Nov 2018 11:54:05 -0500 Subject: Controller Design Studio Upgrade Spring Boot and Kotlin versions. Change-Id: If0d7d0f476d8cfd23916013ff1ab554b26bc6b7a Issue-ID: CCSDK-658 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/core/pom.xml | 6 +- .../core/BluePrintConstants.kt | 2 +- .../vFW/Definitions/vFW_spinup.json | 3613 ++++++++++++++++++++ .../vFW/TOSCA-Metadata/TOSCA.meta | 6 + .../vFW/Templates/base_template.vtl | 56 + .../vFW/Templates/vFW_vNF_Artifact.vtl | 203 ++ .../service-blueprint/vFW/Templates/vfw.vtl | 315 ++ .../service-blueprint/vFW/Templates/vpg.vtl | 315 ++ .../service-blueprint/vFW/Templates/vsn.vtl | 311 ++ .../Definitions/activation-blueprint.json | 388 +++ .../Mappings/baseconfig-mapping.json | 3 + .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 + .../Scripts/SamplePythonComponentNode.py | 8 + .../baseconfiguration/Scripts/__init__.py | 0 .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 8 + .../Templates/baseconfig-template.vtl | 1 + .../artifact_type/artifact-bpmn-camunda.json | 8 + .../artifact_type/artifact-directed-graph.json | 9 + .../artifact_type/artifact-mapping-resource.json | 8 + .../artifact_type/artifact-script-python.json | 8 + .../artifact_type/artifact-template-velocity.json | 8 + .../tosca.artifacts.Implementation.json | 5 + .../starter-type/data_type/datatype-property.json | 27 + .../data_type/datatype-resource-assignment.json | 46 + .../starter-type/data_type/dt-license-key.json | 11 + .../starter-type/data_type/dt-v4-aggregate.json | 15 + .../data_type/tosca.datatypes.Credential.json | 31 + .../node_type/artifact-config-template.json | 37 + .../node_type/component-config-generator.json | 72 + .../node_type/component-netconf-executor.json | 79 + .../node_type/component-resource-assignment.json | 68 + .../node_type/dg-activate-netconf.json | 52 + .../node_type/dg-config-generator.json | 51 + .../node_type/dg-resource-assign-activate.json | 56 + .../node_type/dg-resource-assignment.json | 51 + .../starter-type/node_type/source-db.json | 44 + .../starter-type/node_type/source-default.json | 18 + .../starter-type/node_type/source-input.json | 18 + .../starter-type/node_type/source-rest.json | 61 + .../node_type/tosca.nodes.Artifact.json | 5 + .../node_type/tosca.nodes.Component.json | 5 + .../starter-type/node_type/tosca.nodes.DG.json | 5 + .../node_type/tosca.nodes.ResourceSource.json | 5 + .../starter-type/node_type/tosca.nodes.Vnf.json | 5 + .../node_type/tosca.nodes.component.Python.json | 5 + .../starter-type/node_type/vnf-netconf-device.json | 42 + .../starter-dictionary/address.json | 14 + .../starter-dictionary/aic-cloud-region.json | 15 + .../starter-dictionary/aic_clli.json | 15 + .../starter-dictionary/availability_zone_0.json | 15 + .../starter-dictionary/db-source.json | 24 + .../starter-dictionary/default-source.json | 16 + .../starter-dictionary/image_name.json | 33 + .../starter-dictionary/input-source.json | 16 + .../starter-dictionary/key_name.json | 33 + .../starter-dictionary/mdsal-source.json | 34 + .../starter-dictionary/name_0.json | 15 + .../starter-dictionary/nexus_artifact_repo.json | 16 + .../starter-dictionary/nf-role.json | 25 + .../starter-dictionary/nfc-naming-code.json | 25 + .../starter-dictionary/onap_private_net_cidr.json | 21 + .../starter-dictionary/onap_private_net_id.json | 33 + .../starter-dictionary/onap_private_subnet_id.json | 33 + .../starter-dictionary/private-prefix-id.json | 21 + .../starter-dictionary/protected-prefix-id.json | 21 + .../protected_private_net_cidr.json | 21 + .../protected_private_subnet_id.json | 16 + .../starter-dictionary/pub_key.json | 34 + .../starter-dictionary/public_net_id.json | 14 + .../starter-dictionary/sample-db-source.json | 24 + .../starter-dictionary/sample-default-source.json | 16 + .../starter-dictionary/sample-input-source.json | 17 + .../starter-dictionary/sample-licenses.json | 29 + .../starter-dictionary/sample-mdsal-source.json | 25 + .../starter-dictionary/sample-v4-ip-type.json | 17 + .../starter-dictionary/sec_group.json | 16 + .../starter-dictionary/service-instance-id.json | 15 + .../starter-dictionary/status.json | 16 + .../starter-dictionary/unprotected-prefix-id.json | 21 + .../unprotected_private_net_cidr.json | 21 + .../unprotected_private_subnet_id.json | 16 + .../starter-dictionary/vf-module-id.json | 15 + .../starter-dictionary/vf-module-label.json | 25 + .../vf-module-model-customization-uuid.json | 15 + .../starter-dictionary/vf-module-type.json | 25 + .../starter-dictionary/vf-naming-policy.json | 25 + .../starter-dictionary/vf-nf-code.json | 25 + .../starter-dictionary/vf_module_name.json | 15 + .../starter-dictionary/vfccustomizationuuid.json | 25 + .../starter-dictionary/vfw_name_0.json | 15 + .../starter-dictionary/vfw_private_ip_0.json | 33 + .../starter-dictionary/vfw_private_ip_1.json | 33 + .../starter-dictionary/vfw_private_ip_2.json | 14 + .../starter-dictionary/vm-type.json | 25 + .../starter-dictionary/vnf-id.json | 15 + .../vnf-model-customization-uuid.json | 15 + .../starter-dictionary/vnf-name.json | 28 + .../starter-dictionary/vnf_name.json | 27 + .../vnfc-model-invariant-uuid.json | 25 + .../starter-dictionary/vnfc-model-version.json | 25 + .../starter-dictionary/volume-name.json | 15 + .../starter-dictionary/volume_group_name.json | 16 + .../starter-dictionary/vpg_name_0.json | 15 + .../starter-dictionary/vpg_private_ip_0.json | 33 + .../starter-dictionary/vpg_private_ip_1.json | 16 + .../starter-dictionary/vsn_name_0.json | 15 + .../starter-dictionary/vsn_private_ip_0.json | 33 + .../starter-dictionary/vsn_private_ip_1.json | 14 + components/parent/pom.xml | 46 +- components/resource-dict/pom.xml | 2 +- .../dict/service/ResourceDefinitionRepoService.kt | 6 +- .../service/ResourceDefinitionRepoServiceTest.java | 2 +- 112 files changed, 7505 insertions(+), 32 deletions(-) create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/TOSCA-Metadata/TOSCA.meta create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl create mode 100644 components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/__init__.py create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-bpmn-camunda.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-directed-graph.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-template-velocity.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/tosca.artifacts.Implementation.json create mode 100644 components/model-catalog/definition-type/starter-type/data_type/datatype-property.json create mode 100644 components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json create mode 100644 components/model-catalog/definition-type/starter-type/data_type/dt-license-key.json create mode 100644 components/model-catalog/definition-type/starter-type/data_type/dt-v4-aggregate.json create mode 100644 components/model-catalog/definition-type/starter-type/data_type/tosca.datatypes.Credential.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/artifact-config-template.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-db.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-default.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-input.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-rest.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Artifact.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Component.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.DG.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.ResourceSource.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Vnf.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Python.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/address.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/aic-cloud-region.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/aic_clli.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/availability_zone_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/db-source.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/default-source.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/image_name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/input-source.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/key_name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/name_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/nexus_artifact_repo.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/protected_private_subnet_id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/public_net_id.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-default-source.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-input-source.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-v4-ip-type.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/sec_group.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/status.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_subnet_id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf-module-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf-module-model-customization-uuid.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vf_module_name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vfw_name_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_2.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vnf-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vnf-model-customization-uuid.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/volume-name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/volume_group_name.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vpg_name_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_1.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vsn_name_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_1.json diff --git a/components/core/pom.xml b/components/core/pom.xml index 7c4116564..2e0ab54af 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -55,13 +55,9 @@ org.jetbrains.kotlin - kotlin-test + kotlin-test-junit test - - junit - junit - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index d4bd20a60..2590d6dc3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -60,7 +60,7 @@ object BluePrintConstants { const val PATH_ATTRIBUTES: String = "attributes" const val PATH_ARTIFACTS: String = "artifacts" - const val MODEL_DIR_MODEL_TYPE: String = "model_type" + const val MODEL_DIR_MODEL_TYPE: String = "definition-type" const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json new file mode 100644 index 000000000..d5416c0ea --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json @@ -0,0 +1,3613 @@ +{ + "metadata": { + "template_author": "aa0419", + "template_name": "vFW_spinup", + "template_version": "1.0.0", + "service-type": "vFW", + "template_tags": "vFW, ONAP", + "release": "1810", + "vnf-type": "VFW" + }, + "topology_template": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "service-instance-id": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + }, + "resource-assignment-request": { + "description": "This is Dynamic Data type for the receipe resource-assignment-action.", + "required": false, + "type": "dt-resource-assignment-request" + } + }, + "node_templates": { + "resource-assignment-ra-component": { + "type": "component-resource-assignment", + "interfaces": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "operations": { + "process": { + "inputs": { + "action-name": "{ \"get_input\" : \"action-name\" }", + "service-template-name": "{ \"get_attribute\" : \"service-template-name\" }", + "template-names": [ + "vFW_vNF_Artifact", + "base_template", + "vfw", + "vsn", + "vpg" + ], + "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }", + "resource-type": "vnf-type", + "request-id": "{ \"get_input\" : \"request-id\" }", + "resource-id": "{ \"get_input\" : \"hostname\" }" + }, + "outputs": { + "resource-assignment-params": "Success", + "status": "status" + } + } + } + } + }, + "capabilities": { + "component-node": { + + } + } + }, + "resource-assignment-action": { + "type": "dg-resource-assignment", + "properties": { + "mode": "sync", + "version": "LATEST", + "is-start-flow": false + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignment": { + "inputs": { + "params": [ + + ] + } + } + } + } + }, + "capabilities": { + "dg-node": { + + }, + "content": { + "properties": { + "type": "json" + } + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "resource-assignment-ra-component", + "relationship": "tosca.relationships.DependsOn" + } + } + }, + "vFW_vNF_Artifact": { + "type": "artifact-config-template", + "properties": { + "action-names": [ + "resource-assignment-action" + ] + }, + "capabilities": { + "content": { + "properties": { + "content": "vFW_vNF_Artifact" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "aic-cloud-region", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "aic-cloud-region", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "onap_private_net_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "onap_private_subnet_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_subnet_id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "key_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "key_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "image_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "Ubuntu 14.04 LTS Generic" + }, + "input-param": false, + "dictionary-name": "image_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "pub_key", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKXDgoo3+WOqcUG8/5uUbk81+yczgwC4Y8ywTmuQqbNxlY1oQ0YxdMUqUnhitSXs5S/yRuAVOYHwGg2mCs20oAINrP+mxBI544AMIb9itPjCtgqtE2EWo6MmnFGbHB4Sx3XioE7F4VPsh7japsIwzOjbrQe+Mua1TGQ5d4nfEOQaaglXLLPFfuc7WbhbJbK6Q7rHqZfRcOwAMXgDoBqlyqKeiKwnumddo2RyNT8ljYmvB6buz7KnMinzo7qB0uktVT05FH9Rg0CTWH5norlG5qXgP2aukL0gk1ph8iAt7uYLf1ktp+LJI2gaF6L0/qli9EmVCSLr1uJ38Q8CBflhkh" + }, + "input-param": false, + "dictionary-name": "pub_key", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-naming-policy", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "SDNC_Policy.Config_MS_ONAP_VFW_NAMING_TIMESTAMP" + }, + "input-param": false, + "dictionary-name": "vf-naming-policy", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "nf-role", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "nf-role", + "dictionary-source": "db", + "dependencies": [ + "vnf-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vfw_private_ip_1", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfw_private_ip_1", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfw_private_ip_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfw_private_ip_0", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vpg_private_ip_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vpg_private_ip_0", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vsn_private_ip_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vsn_private_ip_0", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "protected-prefix-id", + "property": { + "description": "", + "required": false, + "type": "integer", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "protected-prefix-id", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "unprotected-prefix-id", + "property": { + "description": "", + "required": false, + "type": "integer", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "unprotected-prefix-id", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-nf-code", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-nf-code", + "dictionary-source": "db", + "dependencies": [ + "vnf-model-customization-uuid" + ], + "version": 0 + } + ] + } + } + } + }, + "vfw": { + "type": "artifact-config-template", + "capabilities": { + "content": { + "properties": { + "content": "vfw" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-name", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vnf-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-type", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-type", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vf-module-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfccustomizationuuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfccustomizationuuid", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "aic-cloud-region", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "aic-cloud-region", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vm-type", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vm-type", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnfc-model-invariant-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnfc-model-invariant-uuid", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "vnfc-model-version", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnfc-model-version", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "nf-role", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "vFW" + }, + "input-param": false, + "dictionary-name": "nf-role", + "dictionary-source": "default", + "dependencies": [ + "vnf-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "nfc-naming-code", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "nfc-naming-code", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "public_net_id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "public_net_id" + }, + "input-param": false, + "dictionary-name": "public_net_id", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "image_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "image_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "key_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "key_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "pub_key", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "pub_key", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "onap_private_net_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_id", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "onap_private_subnet_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_subnet_id", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "unprotected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "unprotected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "protected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "protected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "nexus_artifact_repo", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "nexus_artifact_repo" + }, + "input-param": false, + "dictionary-name": "nexus_artifact_repo", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "sec_group", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "onap_sg_PUhf" + }, + "input-param": false, + "dictionary-name": "sec_group", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "onap_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfw_name_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfw_name_0", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-naming-policy", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "SDNC_Policy.Config_MS_ONAP_VFW_NAMING_TIMESTAMP" + }, + "input-param": false, + "dictionary-name": "vf-naming-policy", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf_module_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf_module_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-label", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-label", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "private-prefix-id", + "property": { + "description": "", + "required": false, + "type": "integer", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "private-prefix-id", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfw_private_ip_2", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfw_private_ip_2", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + } + ] + } + } + } + }, + "vpg": { + "type": "artifact-config-template", + "capabilities": { + "content": { + "properties": { + "content": "vpg" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-name", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vnf-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-type", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-type", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vf-module-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfccustomizationuuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfccustomizationuuid", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "aic-cloud-region", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "aic-cloud-region", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vm-type", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vm-type", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnfc-model-invariant-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnfc-model-invariant-uuid", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "vnfc-model-version", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnfc-model-version", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "nf-role", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "vPG" + }, + "input-param": false, + "dictionary-name": "nf-role", + "dictionary-source": "default", + "dependencies": [ + "vnf-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "nfc-naming-code", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "nfc-naming-code", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "public_net_id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "public_net_id" + }, + "input-param": false, + "dictionary-name": "public_net_id", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "image_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "image_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "key_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "key_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "pub_key", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "pub_key", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "onap_private_net_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_id", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "onap_private_subnet_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_subnet_id", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "unprotected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "unprotected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "onap_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfw_private_ip_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfw_private_ip_0", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vsn_private_ip_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vsn_private_ip_0", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "nexus_artifact_repo", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "nexus_artifact_repo" + }, + "input-param": false, + "dictionary-name": "nexus_artifact_repo", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "sec_group", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "onap_sg_PUhf" + }, + "input-param": false, + "dictionary-name": "sec_group", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vpg_private_ip_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vpg_private_ip_0", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vpg_name_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vpg_name_0", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-naming-policy", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "SDNC_Policy.Config_MS_ONAP_VPG_NAMING_TIMESTAMP" + }, + "input-param": false, + "dictionary-name": "vf-naming-policy", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf_module_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf_module_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-label", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-label", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "private-prefix-id", + "property": { + "description": "", + "required": false, + "type": "integer", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "private-prefix-id", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vpg_private_ip_1", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vpg_private_ip_1", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + } + ] + } + } + } + }, + "vsn": { + "type": "artifact-config-template", + "capabilities": { + "content": { + "properties": { + "content": "vsn" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-name", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vnf-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-type", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-type", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vf-module-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfccustomizationuuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfccustomizationuuid", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "aic-cloud-region", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "aic-cloud-region", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vm-type", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vm-type", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnfc-model-invariant-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnfc-model-invariant-uuid", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "vnfc-model-version", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnfc-model-version", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "nf-role", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "vSN" + }, + "input-param": false, + "dictionary-name": "nf-role", + "dictionary-source": "default", + "dependencies": [ + "vnf-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "nfc-naming-code", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "nfc-naming-code", + "dictionary-source": "db", + "dependencies": [ + "vfccustomizationuuid" + ], + "version": 0 + }, + { + "name": "image_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "image_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "public_net_id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "value": "public_net_id", + "default": "public_net_id" + }, + "input-param": false, + "dictionary-name": "public_net_id", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "key_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "key_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "pub_key", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "pub_key", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "onap_private_net_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_id", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "onap_private_subnet_id", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_subnet_id", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "unprotected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "unprotected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "protected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "protected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "onap_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "onap_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "nexus_artifact_repo", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "value": "nexus_artifact_repo", + "default": "nexus_artifact_repo" + }, + "input-param": false, + "dictionary-name": "nexus_artifact_repo", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "sec_group", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "onap_sg_PUhf" + }, + "input-param": false, + "dictionary-name": "sec_group", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vfw_private_ip_1", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vfw_private_ip_1", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "vsn_name_0", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vsn_name_0", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-naming-policy", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + }, + "default": "SDNC_Policy.Config_MS_ONAP_VSN_NAMING_TIMESTAMP" + }, + "input-param": false, + "dictionary-name": "vf-naming-policy", + "dictionary-source": "default", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf_module_name", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf_module_name", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-label", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-label", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "private-prefix-id", + "property": { + "description": "", + "required": false, + "type": "integer", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "private-prefix-id", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vsn_private_ip_1", + "property": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vsn_private_ip_1", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "protected-prefix-id", + "property": { + "description": "", + "required": false, + "type": "integer", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "protected-prefix-id", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + } + ] + } + } + } + }, + "base_template": { + "type": "artifact-config-template", + "capabilities": { + "content": { + "properties": { + "content": "base_template" + } + }, + "mapping": { + "properties": { + "mapping": [ + { + "name": "service-instance-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-type", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-type", + "dictionary-source": "db", + "dependencies": [ + "vf-module-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vf-module-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vf-module-id", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vf-module-id", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "vnf-model-customization-uuid", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-model-customization-uuid", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "aic-cloud-region", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "aic-cloud-region", + "dictionary-source": "input", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "nf-role", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "nf-role", + "dictionary-source": "db", + "dependencies": [ + "vnf-model-customization-uuid" + ], + "version": 0 + }, + { + "name": "vnf-name", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "vnf-name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ], + "version": 0 + }, + { + "name": "unprotected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "unprotected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + }, + { + "name": "protected_private_net_cidr", + "property": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + }, + "input-param": false, + "dictionary-name": "protected_private_net_cidr", + "dictionary-source": "db", + "dependencies": [ + + ], + "version": 0 + } + ] + } + } + } + } + } + }, + "node_types": { + "tosca.nodes.Component": { + "description": "This is default Component Node", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.DG": { + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.Artifact": { + "description": "This is Deprecated Artifact Node Type.", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Action Name of the process", + "required": true, + "type": "string" + }, + "service-template-name": { + "description": "Service Template Name.", + "required": true, + "type": "string" + }, + "service-template-version": { + "description": "Service Template Version.", + "required": true, + "type": "string" + }, + "resource-type": { + "description": "Request type.", + "required": true, + "type": "string" + }, + "template-names": { + "description": "Name of the artifact Node Templates, to get the template Content.", + "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": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "dg-resource-assignment": { + "description": "This is Resource Assignment Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": "false" + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + }, + "content": { + "type": "tosca.capabilities.Content", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "json" + }, + "content": { + "required": false, + "type": "string" + } + } + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-resource-assignment", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignment": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" + }, + "artifact-config-template": { + "description": "This is Configuration Velocity Template", + "version": "1.0.0", + "properties": { + "action-names": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "capabilities": { + "content": { + "type": "tosca.capabilities.Content", + "properties": { + "content": { + "required": true, + "type": "string" + } + } + }, + "mapping": { + "type": "tosca.capabilities.Mapping", + "properties": { + "mapping": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-resource-assignment" + } + } + } + } + }, + "derived_from": "tosca.nodes.Artifact" + } + }, + "data_types": { + "datatype-property": { + "version": "1.0.0", + "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", + "properties": { + "type": { + "required": true, + "type": "string" + }, + "description": { + "required": false, + "type": "string" + }, + "required": { + "required": false, + "type": "boolean" + }, + "default": { + "required": false, + "type": "string" + }, + "entry_schema": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" + }, + "datatype-resource-assignment": { + "version": "1.0.0", + "description": "This is Resource Assignment Data Type", + "properties": { + "property": { + "required": true, + "type": "datatype-property" + }, + "input-param": { + "required": true, + "type": "boolean" + }, + "dictionary-name": { + "required": false, + "type": "string" + }, + "dictionary-source": { + "required": false, + "type": "string" + }, + "dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "status": { + "required": false, + "type": "string" + }, + "message": { + "required": false, + "type": "string" + }, + "updated-date": { + "required": false, + "type": "string" + }, + "updated-by": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" + }, + "dt-resource-assignment-request": { + "version": "1.0.0", + "description": "This is Dynamic Data type definition generated from resource mapping for the config template name activate-template.", + "properties": { + "password-user-ftap-nsm": { + "required": true, + "type": "string", + "default": "password-user-ftap" + }, + "reservation-id": { + "required": true, + "type": "string", + "value": "123" + }, + "security-manager-resource-key": { + "required": true, + "type": "string", + "value": "sdnc" + }, + "password-user-ftap": { + "description": "", + "required": true, + "type": "string", + "status": "", + "constraints": [ + { + + } + ], + "entry_schema": { + "type": "" + } + } + }, + "derived_from": "tosca.datatypes.Dynamic" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/service-blueprint/vFW/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..7918c1159 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,6 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: ONAP +Entry-Definitions: Definitions/vFW_spinup.json +Template-Tags: ONAP, vFW +Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl new file mode 100644 index 000000000..1f8298c5f --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl @@ -0,0 +1,56 @@ +{ + "resource-accumulator-resolved-data": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "vnf_id", + "param-value": "${vnf-id}" + }, + { + "param-name": "vnf_name", + "param-value": "${vnf-name}" + }, + { + "param-name": "vnf_model_customization_uuid", + "param-value": "${vnf-model-customization-uuid}" + }, + { + "param-name": "vf_module_id", + "param-value": "${vf-module-id}" + }, + { + "param-name": "vf_module_type", + "param-value": "${vf-module-type}" + }, + { + "param-name": "unprotected_private_net_id", + "param-value": "${vnf-name}_unprotected" + }, + { + "param-name": "unprotected_private_subnet_id", + "param-value": "${vnf-name}_unprotected_sub" + }, + { + "param-name": "unprotected_private_net_cidr", + "param-value": "${unprotected_private_net_cidr}" + }, + { + "param-name": "protected_private_net_id", + "param-value": "${vnf-name}_protected" + }, + { + "param-name": "protected_private_subnet_id", + "param-value": "${vnf-name}_protected_sub" + }, + { + "param-name": "protected_private_net_cidr", + "param-value": "${protected_private_net_cidr}" + }, + { + "param-name": "vf_module_name", + "param-value": "${vnf-name}_base" + } + ] +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl new file mode 100644 index 000000000..ca09046aa --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl @@ -0,0 +1,203 @@ +{ + "resource-accumulator-resolved-data": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "vnf_id", + "param-value": "${vnf-id}" + }, + { + "param-name": "vnf-model-customization-uuid", + "param-value": "${vnf-model-customization-uuid}" + }, + { + "param-name": "aic-cloud-region", + "param-value": "${aic-cloud-region}" + }, + { + "param-name": "onap_private_net_id", + "param-value": "${onap_private_net_id}" + }, + { + "param-name": "pub_key", + "param-value": "${pub_key}" + }, + { + "param-name": "image_name", + "param-value": "${image_name}" + }, + { + "param-name": "onap_private_subnet_id", + "param-value": "${onap_private_net_id}_sub" + } + ], + "capability-data": [ + { + "capability-name": "generate-name", + "key-mapping": [ + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vnf_name" + }, + { + "param-name": "resource-value", + "param-value": "${vnf_name}" + }, + { + "param-name": "external-key", + "param-value": "${vnf-id}_vnf_name" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VNF" + }, + { + "param-name": "AIC_CLOUD_REGION", + "param-value": "${aic-cloud-region}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vnf_name", + "resource-value": "${vnf_name}" + } + ] + } + ] + }, + { + "capability-name": "netbox-ip-assign", + "key-mapping": [ + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${protected-prefix-id}" + }, + { + "param-name": "vnf-id", + "param-value": "${vnf-id}" + }, + { + "param-name": "external_key", + "param-value": "${vnf-id}-vfw_private_ip_1" + } + ], + "output-key-mapping": [ + { + "resource-name": "vfw_private_ip_1", + "resource-value": "${vfw_private_ip_1}" + } + ] + }, + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${unprotected-prefix-id}" + }, + { + "param-name": "vnf-id", + "param-value": "${vnf-id}" + }, + { + "param-name": "external_key", + "param-value": "${vnf-id}-vfw_private_ip_0" + } + ], + "output-key-mapping": [ + { + "resource-name": "vfw_private_ip_0", + "resource-value": "${vfw_private_ip_0}" + } + ] + }, + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${unprotected-prefix-id}" + }, + { + "param-name": "vnf-id", + "param-value": "${vnf-id}" + }, + { + "param-name": "external_key", + "param-value": "${vnf-id}-vpg_private_ip_0" + } + ], + "output-key-mapping": [ + { + "resource-name": "vpg_private_ip_0", + "resource-value": "${vpg_private_ip_0}" + } + ] + }, + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${protected-prefix-id}" + }, + { + "param-name": "vnf-id", + "param-value": "${vnf-id}" + }, + { + "param-name": "external_key", + "param-value": "${vnf-id}-vsn_private_ip_0" + } + ], + "output-key-mapping": [ + { + "resource-name": "vsn_private_ip_0", + "resource-value": "${vsn_private_ip_0}" + } + ] + } + ] + }, + { + "capability-name": "unresolved-composite-data", + "key-mapping": [ + { + "output-key-mapping": [ + { + "resource-name": "key_name", + "resource-value": "${vnf_name}_key" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl new file mode 100644 index 000000000..06a91d3a1 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl @@ -0,0 +1,315 @@ +{ + "resource-accumulator-resolved-data": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "vnf_id", + "param-value": "${vnf-id}" + }, + { + "param-name": "vnf_name", + "param-value": "${vnf-name}" + }, + { + "param-name": "vnf_model_customization_uuid", + "param-value": "${vnf-model-customization-uuid}" + }, + { + "param-name": "vf_module_id", + "param-value": "${vnf-id}" + }, + { + "param-name": "vf_module_type", + "param-value": "${vf-module-type}" + }, + { + "param-name": "vf_module_customization_uuid", + "param-value": "${vf-module-model-customization-uuid}" + }, + { + "param-name": "vfc_customization_uuid", + "param-value": "${vfccustomizationuuid}" + }, + { + "param-name": "aic-cloud-region", + "param-value": "${aic-cloud-region}" + }, + { + "param-name": "vm-type", + "param-value": "${vm-type}" + }, + { + "param-name": "vnfc-model-customization-uuid", + "param-value": "${vfccustomizationuuid}" + }, + { + "param-name": "vnfc-model-invariant-uuid", + "param-value": "${vnfc-model-invariant-uuid}" + }, + { + "param-name": "vnfc-model-version", + "param-value": "${vnfc-model-version}" + }, + { + "param-name": "nfc-function", + "param-value": "${nf-role}" + }, + { + "param-name": "nfc-naming-code", + "param-value": "${nfc-naming-code}" + }, + { + "param-name": "cloud_env", + "param-value": "openstack" + }, + { + "param-name": "repo_url_artifacts", + "param-value": "https://nexus.onap.org/content/groups/staging" + }, + { + "param-name": "repo_url_blob", + "param-value": "https://nexus.onap.org/content/repositories/raw" + }, + { + "param-name": "dcae_collector_port", + "param-value": "8080" + }, + { + "param-name": "image_name", + "param-value": "${image_name}" + }, + { + "param-name": "flavor_name", + "param-value": "m1.medium" + }, + { + "param-name": "install_script_version", + "param-value": "1.2.1-SNAPSHOT" + }, + { + "param-name": "demo_artifacts_version", + "param-value": "1.2.1-SNAPSHOT" + }, + { + "param-name": "dcae_collector_ip", + "param-value": "10.0.4.1" + }, + { + "param-name": "key_name", + "param-value": "${key_name}" + }, + { + "param-name": "pub_key", + "param-value": "${pub_key}" + }, + { + "param-name": "public_net_id", + "param-value": "${public_net_id}" + }, + { + "param-name": "unprotected_private_net_id", + "param-value": "${vnf-name}_unprotected" + }, + { + "param-name": "protected_private_net_id", + "param-value": "${vnf-name}_protected" + }, + { + "param-name": "onap_private_net_id", + "param-value": "${onap_private_net_id}" + }, + { + "param-name": "onap_private_subnet_id", + "param-value": "${onap_private_subnet_id}" + }, + { + "param-name": "unprotected_private_net_cidr", + "param-value": "${unprotected_private_net_cidr}" + }, + { + "param-name": "protected_private_net_cidr", + "param-value": "${protected_private_net_cidr}" + }, + { + "param-name": "unprotected_private_subnet_id", + "param-value": "${vnf-name}_unprotected_sub" + }, + { + "param-name": "unprotected_private_net_cidr", + "param-value": "${unprotected_private_net_cidr}" + }, + { + "param-name": "protected_private_subnet_id", + "param-value": "${vnf-name}_protected_sub" + }, + { + "param-name": "nexus_artifact_repo", + "param-value": "${nexus_artifact_repo}" + }, + { + "param-name": "sec_group", + "param-value": "${sec_group}" + }, + { + "param-name": "onap_private_net_cidr", + "param-value": "${onap_private_net_cidr}" + } + ], + "capability-data": [ + { + "capability-name": "generate-name", + "key-mapping": [ + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vfw_name_0" + }, + { + "param-name": "resource-value", + "param-value": "${vfw_name_0}" + }, + { + "param-name": "external-key", + "param-value": "${vf-module-id}_vfw_name_0" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VNFC" + }, + { + "param-name": "VNF_NAME", + "param-value": "${vnf-name}" + }, + { + "param-name": "NFC_NAMING_CODE", + "param-value": "${nfc-naming-code}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vfw_name_0", + "resource-value": "${vfw_name_0}" + } + ] + }, + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vf_module_name" + }, + { + "param-name": "resource-value", + "param-value": "${vf_module_name}" + }, + { + "param-name": "external-key", + "param-value": "${vf-module-id}_vf_module_name" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VF-MODULE" + }, + { + "param-name": "VNF_NAME", + "param-value": "${vnf-name}" + }, + { + "param-name": "VF_MODULE_LABEL", + "param-value": "${vf-module-label}" + }, + { + "param-name": "VF_MODULE_TYPE", + "param-value": "${vf-module-type}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vf_module_name", + "resource-value": "${vf_module_name}" + } + ] + } + ] + }, + { + "capability-name": "netbox-ip-assign", + "key-mapping": [ + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${private-prefix-id}" + }, + { + "param-name": "vf-module-id", + "param-value": "${vf-module-id}" + }, + { + "param-name": "external_key", + "param-value": "${vf-module-id}-vfw_private_ip_2" + } + ], + "output-key-mapping": [ + { + "resource-name": "vfw_private_ip_2", + "resource-value": "${vfw_private_ip_2}" + } + ] + } + ] + }, + { + "capability-name": "unresolved-composite-data", + "key-mapping": [ + { + "output-key-mapping": [ + { + "resource-name": "KEY", + "resource-value": "${vnf_name}" + }, + { + "resource-name": "vf-module-name", + "resource-value": "${vf_module_name}" + }, + { + "resource-name": "vnfc-name", + "resource-value": "${vfw_name_0}" + }, + { + "resource-name": "ipv4-oam-address", + "resource-value": "${vfw_private_ip_2}" + }, + { + "resource-name": "ipv4-oam-address-prefix", + "resource-value": "${onap_private_net_cidr}" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl new file mode 100644 index 000000000..f7e3780a3 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl @@ -0,0 +1,315 @@ +{ + "resource-accumulator-resolved-data": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "vnf_id", + "param-value": "${vnf-id}" + }, + { + "param-name": "vnf_name", + "param-value": "${vnf-name}" + }, + { + "param-name": "vnf_model_customization_uuid", + "param-value": "${vnf-model-customization-uuid}" + }, + { + "param-name": "vf_module_id", + "param-value": "${vf-module-id}" + }, + { + "param-name": "vf_module_type", + "param-value": "${vf-module-type}" + }, + { + "param-name": "vf_module_customization_uuid", + "param-value": "${vf-module-model-customization-uuid}" + }, + { + "param-name": "vfc_customization_uuid", + "param-value": "${vfccustomizationuuid}" + }, + { + "param-name": "aic-cloud-region", + "param-value": "${aic-cloud-region}" + }, + { + "param-name": "vm-type", + "param-value": "${vm-type}" + }, + { + "param-name": "vnfc-model-customization-uuid", + "param-value": "${vfccustomizationuuid}" + }, + { + "param-name": "vnfc-model-invariant-uuid", + "param-value": "${vnfc-model-invariant-uuid}" + }, + { + "param-name": "vnfc-model-version", + "param-value": "${vnfc-model-version}" + }, + { + "param-name": "nfc-function", + "param-value": "${nf-role}" + }, + { + "param-name": "nfc-naming-code", + "param-value": "${nfc-naming-code}" + }, + { + "param-name": "cloud_env", + "param-value": "openstack" + }, + { + "param-name": "repo_url_artifacts", + "param-value": "https://nexus.onap.org/content/groups/staging" + }, + { + "param-name": "repo_url_blob", + "param-value": "https://nexus.onap.org/content/repositories/raw" + }, + { + "param-name": "dcae_collector_port", + "param-value": "8080" + }, + { + "param-name": "image_name", + "param-value": "${image_name}" + }, + { + "param-name": "flavor_name", + "param-value": "m1.medium" + }, + { + "param-name": "key_name", + "param-value": "${key_name}" + }, + { + "param-name": "pub_key", + "param-value": "${pub_key}" + }, + { + "param-name": "install_script_version", + "param-value": "1.2.1-SNAPSHOT" + }, + { + "param-name": "demo_artifacts_version", + "param-value": "1.2.1-SNAPSHOT" + }, + { + "param-name": "dcae_collector_ip", + "param-value": "10.0.4.1" + }, + { + "param-name": "public_net_id", + "param-value": "${public_net_id}" + }, + { + "param-name": "protected_private_net_id", + "param-value": "zdfw1fwl01_protected" + }, + { + "param-name": "onap_private_net_id", + "param-value": "${onap_private_net_id}" + }, + { + "param-name": "onap_private_subnet_id", + "param-value": "${onap_private_subnet_id}" + }, + { + "param-name": "unprotected_private_net_id", + "param-value": "${vnf-name}_unprotected" + }, + { + "param-name": "unprotected_private_subnet_id", + "param-value": "${vnf-name}_unprotected_sub" + }, + { + "param-name": "unprotected_private_net_cidr", + "param-value": "${unprotected_private_net_cidr}" + }, + { + "param-name": "protected_private_subnet_id", + "param-value": "${vnf-name}_protected_sub" + }, + { + "param-name": "protected_private_net_id", + "param-value": "${vnf-name}_protected" + }, + { + "param-name": "onap_private_net_cidr", + "param-value": "${onap_private_net_cidr}" + }, + { + "param-name": "vfw_private_ip_0", + "param-value": "${vfw_private_ip_0}" + }, + { + "param-name": "vsn_private_ip_0", + "param-value": "${vsn_private_ip_0}" + }, + { + "param-name": "nexus_artifact_repo", + "param-value": "${nexus_artifact_repo}" + }, + { + "param-name": "sec_group", + "param-value": "${sec_group}" + }, + { + "param-name": "vpg_private_ip_0", + "param-value": "${vpg_private_ip_0}" + } + ], + "capability-data": [ + { + "capability-name": "generate-name", + "key-mapping": [ + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vpg_name_0" + }, + { + "param-name": "resource-value", + "param-value": "${vpg_name_0}" + }, + { + "param-name": "external-key", + "param-value": "${vf-module-id}_vpg_name_0" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VNFC" + }, + { + "param-name": "VNF_NAME", + "param-value": "${vnf-name}" + }, + { + "param-name": "NFC_NAMING_CODE", + "param-value": "${nfc-naming-code}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vpg_name_0", + "resource-value": "${vpg_name_0}" + } + ] + }, + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vf_module_name" + }, + { + "param-name": "resource-value", + "param-value": "${vf_module_name}" + }, + { + "param-name": "external-key", + "param-value": "${vf-module-id}_vf_module_name" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VF-MODULE" + }, + { + "param-name": "VNF_NAME", + "param-value": "${vnf-name}" + }, + { + "param-name": "VF_MODULE_LABEL", + "param-value": "${vf-module-label}" + }, + { + "param-name": "VF_MODULE_TYPE", + "param-value": "${vf-module-type}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vf_module_name", + "resource-value": "${vf_module_name}" + } + ] + } + ] + }, + { + "capability-name": "netbox-ip-assign", + "key-mapping": [ + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${private-prefix-id}" + }, + { + "param-name": "vf-module-id", + "param-value": "${vf-module-id}" + }, + { + "param-name": "external_key", + "param-value": "${vf-module-id}-vpg_private_ip_1" + } + ], + "output-key-mapping": [ + { + "resource-name": "vpg_private_ip_1", + "resource-value": "${vpg_private_ip_1}" + } + ] + } + ] + }, + { + "capability-name": "unresolved-composite-data", + "key-mapping": [ + { + "output-key-mapping": [ + { + "resource-name": "vf-module-name", + "resource-value": "${vf_module_name}" + }, + { + "resource-name": "vnfc-name", + "resource-value": "${vpg_name_0}" + }, + { + "resource-name": "ipv4-oam-address-prefix", + "resource-value": "${onap_private_net_cidr}" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl new file mode 100644 index 000000000..727427a63 --- /dev/null +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl @@ -0,0 +1,311 @@ +{ + "resource-accumulator-resolved-data": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "vnf_id", + "param-value": "${vnf-id}" + }, + { + "param-name": "vnf_name", + "param-value": "${vnf-name}" + }, + { + "param-name": "vnf_model_customization_uuid", + "param-value": "${vnf-model-customization-uuid}" + }, + { + "param-name": "vf_module_id", + "param-value": "${vf-module-id}" + }, + { + "param-name": "vf_module_type", + "param-value": "${vf-module-type}" + }, + { + "param-name": "vf_module_customization_uuid", + "param-value": "${vf-module-model-customization-uuid}" + }, + { + "param-name": "vfc_customization_uuid", + "param-value": "${vfccustomizationuuid}" + }, + { + "param-name": "aic-cloud-region", + "param-value": "${aic-cloud-region}" + }, + { + "param-name": "vm-type", + "param-value": "${vm-type}" + }, + { + "param-name": "vnfc-model-customization-uuid", + "param-value": "${vfccustomizationuuid}" + }, + { + "param-name": "vnfc-model-invariant-uuid", + "param-value": "${vnfc-model-invariant-uuid}" + }, + { + "param-name": "vnfc-model-version", + "param-value": "${vnfc-model-version}" + }, + { + "param-name": "nfc-function", + "param-value": "${nf-role}" + }, + { + "param-name": "nfc-naming-code", + "param-value": "${nfc-naming-code}" + }, + { + "param-name": "cloud_env", + "param-value": "openstack" + }, + { + "param-name": "repo_url_artifacts", + "param-value": "https://nexus.onap.org/content/groups/staging" + }, + { + "param-name": "repo_url_blob", + "param-value": "https://nexus.onap.org/content/repositories/raw" + }, + { + "param-name": "dcae_collector_port", + "param-value": "8080" + }, + { + "param-name": "image_name", + "param-value": "${image_name}" + }, + { + "param-name": "flavor_name", + "param-value": "m1.medium" + }, + { + "param-name": "install_script_version", + "param-value": "1.2.1-SNAPSHOT" + }, + { + "param-name": "key_name", + "param-value": "${key_name}" + }, + { + "param-name": "pub_key", + "param-value": "${pub_key}" + }, + { + "param-name": "demo_artifacts_version", + "param-value": "1.2.1-SNAPSHOT" + }, + { + "param-name": "dcae_collector_ip", + "param-value": "10.0.4.1" + }, + { + "param-name": "public_net_id", + "param-value": "${public_net_id}" + }, + { + "param-name": "unprotected_private_net_id", + "param-value": "${vnf-name}_unprotected" + }, + { + "param-name": "protected_private_subnet_id", + "param-value": "${vnf-name}_protected_sub" + }, + { + "param-name": "protected_private_net_id", + "param-value": "${vnf-name}_protected" + }, + { + "param-name": "onap_private_net_id", + "param-value": "${onap_private_net_id}" + }, + { + "param-name": "onap_private_subnet_id", + "param-value": "${onap_private_subnet_id}" + }, + { + "param-name": "unprotected_private_net_cidr", + "param-value": "${unprotected_private_net_cidr}" + }, + { + "param-name": "protected_private_net_cidr", + "param-value": "${protected_private_net_cidr}" + }, + { + "param-name": "onap_private_net_cidr", + "param-value": "${onap_private_net_cidr}" + }, + { + "param-name": "nexus_artifact_repo", + "param-value": "${nexus_artifact_repo}" + }, + { + "param-name": "sec_group", + "param-value": "${sec_group}" + }, + { + "param-name": "vfw_private_ip_1", + "param-value": "${vfw_private_ip_1}" + } + ], + "capability-data": [ + { + "capability-name": "generate-name", + "key-mapping": [ + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vsn_name_0" + }, + { + "param-name": "resource-value", + "param-value": "${vsn_name_0}" + }, + { + "param-name": "external-key", + "param-value": "${vf-module-id}_vsn_name_0" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VNFC" + }, + { + "param-name": "VNF_NAME", + "param-value": "${vnf-name}" + }, + { + "param-name": "NFC_NAMING_CODE", + "param-value": "${nfc-naming-code}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vsn_name_0", + "resource-value": "${vsn_name_0}" + } + ] + }, + { + "payload": [ + { + "param-name": "resource-name", + "param-value": "vf_module_name" + }, + { + "param-name": "resource-value", + "param-value": "${vf_module_name}" + }, + { + "param-name": "external-key", + "param-value": "${vf-module-id}_vf_module_name" + }, + { + "param-name": "policy-instance-name", + "param-value": "${vf-naming-policy}" + }, + { + "param-name": "nf-role", + "param-value": "${nf-role}" + }, + { + "param-name": "naming-type", + "param-value": "VF-MODULE" + }, + { + "param-name": "VNF_NAME", + "param-value": "${vnf-name}" + }, + { + "param-name": "VF_MODULE_LABEL", + "param-value": "${vf-module-label}" + }, + { + "param-name": "VF_MODULE_TYPE", + "param-value": "${vf-module-type}" + } + ], + "output-key-mapping": [ + { + "resource-name": "vf_module_name", + "resource-value": "${vf_module_name}" + } + ] + } + ] + }, + { + "capability-name": "netbox-ip-assign", + "key-mapping": [ + { + "payload": [ + { + "param-name": "service-instance-id", + "param-value": "${service-instance-id}" + }, + { + "param-name": "prefix-id", + "param-value": "${private-prefix-id}" + }, + { + "param-name": "vf-module-id", + "param-value": "${vf-module-id}" + }, + { + "param-name": "external_key", + "param-value": "${vf-module-id}-vsn_private_ip_1" + } + ], + "output-key-mapping": [ + { + "resource-name": "vsn_private_ip_1", + "resource-value": "${vsn_private_ip_1}" + } + ] + } + ] + }, + { + "capability-name": "unresolved-composite-data", + "key-mapping": [ + { + "output-key-mapping": [ + { + "resource-name": "volume-group-name", + "resource-value": "${volume_group_name}" + }, + { + "resource-name": "vf-module-name", + "resource-value": "${vf_module_name}" + }, + { + "resource-name": "vnfc-name", + "resource-value": "${vsn_name_0}" + }, + { + "resource-name": "ipv4-oam-address", + "resource-value": "${vsn_private_ip_1}" + }, + { + "resource-name": "ipv4-oam-address-prefix", + "resource-value": "${onap_private_net_cidr}" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json new file mode 100644 index 000000000..4c1ca4a52 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -0,0 +1,388 @@ +{ + "metadata": { + "template_author": "Brinda Santh Muthuramalingam", + "author-email": "brindasanth@gmail.com", + "user-groups": "ADMIN, OPERATION", + "template_name": "baseconfiguration", + "template_version": "1.0.0", + "template_tags": "brinda, tosca" + }, + "topology_template": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "node_templates": { + "activate-process": { + "type": "bpmn-activate", + "properties": { + "process-name": { + "get_input": "action-name" + }, + "version": { + "get_property": [ + "SELF", + "process-name" + ] + }, + "content": { + "get_artifact": [ + "SELF", + "activate-process" + ] + } + }, + "artifacts": { + "activate-process": { + "type": "artifact-bpmn-camunda", + "file": "Plans/ActivateProcess.bpmn" + } + } + }, + "resource-assignment": { + "type": "component-resource-assignment", + "properties": { + "request-id": "1234" + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "get_input": "action-name" + }, + "resource-type": "vnf-type", + "request-id": { + "get_input": "request-id" + }, + "resource-id": { + "get_input": "hostname" + }, + "template-content": { + "get_artifact": [ + "SELF", + "baseconfig-template" + ] + }, + "mapping-content": { + "get_artifact": [ + "SELF", + "baseconfig-mapping" + ] + } + }, + "outputs": { + "resource-assignment-params": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "baseconfig-template": { + "type": "artifact-template-velocity", + "file": "Templates/baseconfig-template.vtl" + }, + "baseconfig-mapping": { + "type": "artifact-mapping-resource", + "file": "Mappings/baseconfig-mapping.json" + } + } + }, + "resource-assignment-py": { + "type": "component-resource-assignment", + "properties": { + "request-id": "1234" + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "action-name": { + "get_input": "action-name" + } + }, + "outputs": { + "resource-assignment-params": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/baseconfig-template.vtl" + } + } + } + }, + "workflows": { + "activate-process": { + "steps": { + "call-resource-assignment": { + "description": "Invoke Resource Assignment Component", + "target": "resource-assignment", + "activities": [ + { + "call_operation": "ResourceAssignmentNode.process" + } + ], + "on_success": [ + "download-baseconfig" + ] + }, + "download-baseconfig": { + "description": "Call Download Base Config Component", + "target": "activate-netconf", + "activities": [ + { + "call_operation": "NetconfTransactionNode.process" + } + ], + "on_success": [ + "download-licence" + ] + }, + "download-licence": { + "description": "Call Download Licence Component", + "target": "activate-netconf", + "activities": [ + { + "call_operation": "NetconfTransactionNode.process" + } + ] + } + } + } + } + }, + "artifact_types": { + "artifact-template-velocity": { + "description": " Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-mapping-resource": { + "description": " Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-kotlin": { + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "kt" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-python": { + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-bpmn-camunda": { + "description": " Camunda BPM File", + "version": "1.0.0", + "file_ext": [ + "bpmn" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-component-jar": { + "description": "Component Jar", + "version": "1.0.0", + "file_ext": [ + "jar" + ], + "derived_from": "tosca.artifacts.Implementation" + } + }, + "node_types": { + "bpmn-activate": { + "description": "This is BPMN Activate node type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.nodes.DG" + }, + "tosca.nodes.Component": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.DG": { + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Python": { + "description": "This is Resource Assignment Python Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "template-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "mapping-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-resource-assignment-python": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.component.Python" + } + }, + "data_types": { + "sample-property": { + "description": "This is sample data type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.datatypes.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json new file mode 100644 index 000000000..caee773bb --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json @@ -0,0 +1,3 @@ +{ + "assignments": "Sample Assignments" +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn new file mode 100644 index 000000000..89ae342f8 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn @@ -0,0 +1,66 @@ + + + + + SequenceFlow_0l0dq58 + + + SequenceFlow_1ay0k6p + + + + + + + + + + SequenceFlow_0l0dq58 + SequenceFlow_1ay0k6p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py new file mode 100644 index 000000000..fc5151338 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py @@ -0,0 +1,8 @@ +from com.brvith.orchestrator.core.interfaces import ComponentNode + +class SamplePythonComponentNode(ComponentNode): + def prepare(self, context, componentContext): + return None + + def prepare(self, context, componentContext): + return None \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/__init__.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..9066e4845 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Brinda Santh M +Entry-Definitions: Definitions/activation-blueprint.json +Template-Tags: Brinda Santh, activation-blueprint + +Name: Plans/ActivateProcess.bpmn +Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl new file mode 100644 index 000000000..026c59176 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl @@ -0,0 +1 @@ +This is Sample Velocity Template \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-bpmn-camunda.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-bpmn-camunda.json new file mode 100644 index 000000000..ac76b4f4f --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-bpmn-camunda.json @@ -0,0 +1,8 @@ +{ + "description": " Camunda BPM File", + "version": "1.0.0", + "file_ext": [ + "bpmn" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-directed-graph.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-directed-graph.json new file mode 100644 index 000000000..7ab3a5434 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-directed-graph.json @@ -0,0 +1,9 @@ +{ + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json new file mode 100644 index 000000000..0a3261b09 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json @@ -0,0 +1,8 @@ +{ + "description": " Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json new file mode 100644 index 000000000..b48d2b628 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json @@ -0,0 +1,8 @@ +{ + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-template-velocity.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-template-velocity.json new file mode 100644 index 000000000..9395d3970 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-template-velocity.json @@ -0,0 +1,8 @@ +{ + "description": " Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/tosca.artifacts.Implementation.json b/components/model-catalog/definition-type/starter-type/artifact_type/tosca.artifacts.Implementation.json new file mode 100644 index 000000000..5a7c95684 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/tosca.artifacts.Implementation.json @@ -0,0 +1,5 @@ +{ + "description": "TOSCA base type for implementation artifacts", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/data_type/datatype-property.json b/components/model-catalog/definition-type/starter-type/data_type/datatype-property.json new file mode 100644 index 000000000..5584b10ea --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/data_type/datatype-property.json @@ -0,0 +1,27 @@ +{ + "version": "1.0.0", + "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", + "properties": { + "type": { + "required": true, + "type": "string" + }, + "description": { + "required": false, + "type": "string" + }, + "required": { + "required": false, + "type": "boolean" + }, + "default": { + "required": false, + "type": "string" + }, + "entry_schema": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json b/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json new file mode 100644 index 000000000..cc9816ebb --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json @@ -0,0 +1,46 @@ +{ + "version": "1.0.0", + "description": "This is Resource Assignment Data Type", + "properties": { + "property": { + "required": true, + "type": "datatype-property" + }, + "input-param": { + "required": true, + "type": "boolean" + }, + "dictionary-name": { + "required": false, + "type": "string" + }, + "dictionary-source": { + "required": false, + "type": "string" + }, + "dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "status": { + "required": false, + "type": "string" + }, + "message": { + "required": false, + "type": "string" + }, + "updated-date": { + "required": false, + "type": "string" + }, + "updated-by": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/data_type/dt-license-key.json b/components/model-catalog/definition-type/starter-type/data_type/dt-license-key.json new file mode 100644 index 000000000..e9c312b79 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/data_type/dt-license-key.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0", + "description": "This is dt-plicense-key Data Type", + "properties": { + "license-key": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/data_type/dt-v4-aggregate.json b/components/model-catalog/definition-type/starter-type/data_type/dt-v4-aggregate.json new file mode 100644 index 000000000..842a7f805 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/data_type/dt-v4-aggregate.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0", + "description": "This is dt-v4-aggregate Data Type", + "properties": { + "ipv4-address": { + "required": true, + "type": "string" + }, + "ipv4-plen": { + "required": false, + "type": "integer" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/data_type/tosca.datatypes.Credential.json b/components/model-catalog/definition-type/starter-type/data_type/tosca.datatypes.Credential.json new file mode 100644 index 000000000..820a55168 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/data_type/tosca.datatypes.Credential.json @@ -0,0 +1,31 @@ +{ + "version": "1.0.0", + "description": "Credential", + "properties": { + "protocol": { + "required": false, + "type": "string" + }, + "token_type": { + "required": true, + "type": "string", + "default" : "password" + }, + "token": { + "required": false, + "type": "string" + }, + "keys": { + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "user": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/artifact-config-template.json b/components/model-catalog/definition-type/starter-type/node_type/artifact-config-template.json new file mode 100644 index 000000000..af99d75b8 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/artifact-config-template.json @@ -0,0 +1,37 @@ +{ + "description": "This is Configuration Velocity Template", + "version": "1.0.0", + "properties": { + "action-names": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "capabilities": { + "content": { + "type": "tosca.capabilities.Content", + "properties": { + "content": { + "required": true, + "type": "string" + } + } + }, + "mapping": { + "type": "tosca.capabilities.Mapping", + "properties": { + "mapping": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-resource-assignment" + } + } + } + } + }, + "derived_from": "tosca.nodes.Artifact" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json b/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json new file mode 100644 index 000000000..764f9e890 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json @@ -0,0 +1,72 @@ +{ + "description": "This is Generate Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": { + "operations": { + "process": { + "inputs": { + "template-data": { + "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", + "required": false, + "type": "string" + }, + "template-content": { + "description": "Conditional : Dynamic Template used to generate Configuration.", + "required": false, + "type": "string" + }, + "resource-type": { + "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", + "required": false, + "type": "string" + }, + "action-name": { + "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "template-name": { + "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", + "required": true, + "type": "string" + } + }, + "outputs": { + "generated-config": { + "description": "Generated Configuration for the Template adn Resource Data", + "required": true, + "type": "string" + }, + "mask-info": { + "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.apps.controllerblueprints.core.data.custom.MaskInfo ", + "required": false, + "type": "string" + }, + "status": { + "description": "Status of the Component Execution ( success or failure )", + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json new file mode 100644 index 000000000..240caf3fc --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -0,0 +1,79 @@ +{ + "description": "This is Netconf Transaction Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "vnf-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { + "operations": { + "process": { + "inputs": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "template-name": { + "description": "Service Template Name", + "required": true, + "type": "string" + }, + "template-version": { + "description": "Service Template Version", + "required": true, + "type": "string" + }, + "action-name": { + "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-id": { + "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "reservation-id": { + "description": "Reservation Id used to send to NPM", + "required": false, + "type": "string" + }, + "execution-script": { + "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.", + "required": true, + "type": "string" + } + }, + "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" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json new file mode 100644 index 000000000..d424a8e43 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json @@ -0,0 +1,68 @@ +{ + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "operations": { + "process": { + "inputs": { + "template-name": { + "description": "Service Template Name.", + "required": true, + "type": "string" + }, + "template-version": { + "description": "Service Template Version.", + "required": true, + "type": "string" + }, + "resource-type": { + "description": "Request type.", + "required": true, + "type": "string" + }, + "template-names": { + "description": "Name of the artifact Node Templates, to get the template Content.", + "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": true, + "type": "string" + }, + "action-name": { + "description": "Action Name of the process", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json b/components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json new file mode 100644 index 000000000..57667de98 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json @@ -0,0 +1,52 @@ +{ + "description": "This is Download Netconf Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": false + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-netconf-executor", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ActivateNetconf": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json b/components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json new file mode 100644 index 000000000..e59c34b6e --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json @@ -0,0 +1,51 @@ +{ + "description": "This is Activate DG for Config Generator Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": false + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-config-generator", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "GenerateConfiguration": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json b/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json new file mode 100644 index 000000000..ca703a793 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json @@ -0,0 +1,56 @@ +{ + "description": "This is Resource Assign and Activate Netconf Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": false + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "ra-component": { + "capability": "component-node", + "node": "component-resource-assignment", + "relationship": "tosca.relationships.DependsOn" + }, + "netconf-component": { + "capability": "component-node", + "node": "component-netconf-executor", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignAndActivate": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json new file mode 100644 index 000000000..9cce82a9e --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json @@ -0,0 +1,51 @@ +{ + "description": "This is Resource Assignment Directed Graph", + "version": "1.0.0", + "properties": { + "mode": { + "required": false, + "type": "string", + "default": "sync" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + }, + "is-start-flow": { + "required": false, + "type": "boolean", + "default": false + } + }, + "capabilities": { + "dg-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "component-dependency": { + "capability": "component-node", + "node": "component-resource-assignment", + "relationship": "tosca.relationships.DependsOn" + } + }, + "interfaces": { + "CONFIG": { + "operations": { + "ResourceAssignment": { + "inputs": { + "params": { + "required": false, + "type": "list", + "entry_schema": { + "type": "datatype-property" + } + } + } + } + } + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-db.json b/components/model-catalog/definition-type/starter-type/node_type/source-db.json new file mode 100644 index 000000000..661a9503b --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-db.json @@ -0,0 +1,44 @@ +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "query": { + "required": true, + "type": "string" + }, + "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" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-default.json b/components/model-catalog/definition-type/starter-type/node_type/source-default.json new file mode 100644 index 000000000..13e234e1b --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-default.json @@ -0,0 +1,18 @@ +{ + "description": "This is Default Resource Source Node Type", + "version": "1.0.0", + "properties": { + "key": { + "required": false, + "type": "string" + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-input.json b/components/model-catalog/definition-type/starter-type/node_type/source-input.json new file mode 100644 index 000000000..126ea30bd --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-input.json @@ -0,0 +1,18 @@ +{ + "description": "This is Input Resource Source Node Type", + "version": "1.0.0", + "properties": { + "key": { + "required": false, + "type": "string" + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} \ No newline at end of file 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 new file mode 100644 index 000000000..f8dd8b6fc --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-rest.json @@ -0,0 +1,61 @@ +{ + "description": "This is Rest Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "JSON", + "constraints": [ + { + "valid_values": [ + "JSON" + ] + } + ] + }, + "url-path": { + "required": true, + "type": "string" + }, + "path": { + "required": true, + "type": "string" + }, + "expression-type": { + "required": false, + "type": "string", + "default": "JSON_PATH", + "constraints": [ + { + "valid_values": [ + "JSON_PATH", + "JSON_POINTER" + ] + } + ] + }, + "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" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Artifact.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Artifact.json new file mode 100644 index 000000000..814105277 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Artifact.json @@ -0,0 +1,5 @@ +{ + "description": "This is Deprecated Artifact Node Type.", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Component.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Component.json new file mode 100644 index 000000000..bc4827b8b --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Component.json @@ -0,0 +1,5 @@ +{ + "description": "This is default Component Node", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.DG.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.DG.json new file mode 100644 index 000000000..86728cf2f --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.DG.json @@ -0,0 +1,5 @@ +{ + "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/definition-type/starter-type/node_type/tosca.nodes.ResourceSource.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.ResourceSource.json new file mode 100644 index 000000000..2ef553e24 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.ResourceSource.json @@ -0,0 +1,5 @@ +{ + "description": "TOSCA base type for Resource Sources", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Vnf.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Vnf.json new file mode 100644 index 000000000..acb1f2f31 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.Vnf.json @@ -0,0 +1,5 @@ +{ + "description": "This is VNF Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Python.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Python.json new file mode 100644 index 000000000..7b67c8cb2 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Python.json @@ -0,0 +1,5 @@ +{ + "description": "This is Python Component", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json new file mode 100644 index 000000000..246f17706 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json @@ -0,0 +1,42 @@ +{ + "description": "This is VNF Device with Netconf Capability", + "version": "1.0.0", + "capabilities": { + "netconf": { + "type": "tosca.capabilities.Netconf", + "properties": { + "login-key": { + "required": true, + "type": "string", + "default": "sdnc" + }, + "login-account": { + "required": true, + "type": "string", + "default": "sdnc-tacacs" + }, + "source": { + "required": true, + "type": "string", + "default": "npm" + }, + "target-ip-address": { + "required": true, + "type": "string" + }, + "port-number": { + "required": true, + "type": "integer", + "default": 830 + }, + "connection-time-out": { + "required": false, + "type": "integer", + "default": 30 + } + } + } + }, + "derived_from": "tosca.nodes.Vnf" + +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/address.json b/components/model-catalog/resource-dictionary/starter-dictionary/address.json new file mode 100755 index 000000000..11f92d76e --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/address.json @@ -0,0 +1,14 @@ +{ + "name": "address", + "tags": "address", + "updated-by" : "Singal, Kapil ", + "property": { + "description" : "address", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input" + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/aic-cloud-region.json b/components/model-catalog/resource-dictionary/starter-dictionary/aic-cloud-region.json new file mode 100755 index 000000000..1501a9a63 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/aic-cloud-region.json @@ -0,0 +1,15 @@ +{ + "name" : "aic-cloud-region", + "tags" : "aic-cloud-region", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "aic-cloud-region", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/aic_clli.json b/components/model-catalog/resource-dictionary/starter-dictionary/aic_clli.json new file mode 100755 index 000000000..ccbbe9d43 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/aic_clli.json @@ -0,0 +1,15 @@ +{ + "name" : "aic_clli", + "tags" : "aic_clli", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "aic_clli", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/availability_zone_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/availability_zone_0.json new file mode 100755 index 000000000..b9e07a9fa --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/availability_zone_0.json @@ -0,0 +1,15 @@ +{ + "name" : "availability_zone_0", + "tags" : "availability_zone_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "availability_zone_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json new file mode 100755 index 000000000..de46524ce --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json @@ -0,0 +1,24 @@ +{ + "name": "db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "bundle-id, brindasanth@onap.com", + "sources": { + "db": { + "type": "source-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/default-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/default-source.json new file mode 100755 index 000000000..42059ad8e --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/default-source.json @@ -0,0 +1,16 @@ +{ + "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", + "name": "default-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json new file mode 100755 index 000000000..37ef5ae19 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json @@ -0,0 +1,33 @@ +{ + "name": "image_name", + "tags": "image_name", + "updated-by": "Singal, Kapil ", + "property": { + "type": "string", + "description": "image_name" + }, + "sources": { + "input": { + "type": "source-input" + }, + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/image_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "image_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/input-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/input-source.json new file mode 100755 index 000000000..6c693848e --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/input-source.json @@ -0,0 +1,16 @@ +{ + "name": "input-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "input-source", + "sources": { + "input": { + "type": "source-input", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json new file mode 100755 index 000000000..1f1b3e65c --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json @@ -0,0 +1,33 @@ +{ + "name": "key_name", + "tags": "key_name", + "updated-by": "Singal, Kapil ", + "property": { + "type": "string", + "description": "key_name" + }, + "sources": { + "input": { + "type": "source-input" + }, + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/key_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "key_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json new file mode 100755 index 000000000..300a71f1f --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json @@ -0,0 +1,34 @@ +{ + "tags": "oam-local-ipv4-address", + "name": "mdsal-source", + "property" :{ + "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", + "path": "/v4-assigned-ip-list/0/v4-ip-prefix", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "network-role": "network-role", + "v4-ip-type": "v4-ip-type", + "vm-type": "vm-type" + }, + "output-key-mapping": { + "oam-local-ipv4-address": "v4-ip-prefix" + }, + "key-dependencies": [ + "service-instance-id", + "network-role", + "v4-ip-type", + "vm-type" + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/name_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/name_0.json new file mode 100755 index 000000000..433a3b724 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/name_0.json @@ -0,0 +1,15 @@ +{ + "name" : "name_0", + "tags" : "name_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "name_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nexus_artifact_repo.json b/components/model-catalog/resource-dictionary/starter-dictionary/nexus_artifact_repo.json new file mode 100755 index 000000000..6b0a79e03 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/nexus_artifact_repo.json @@ -0,0 +1,16 @@ +{ + "name" : "nexus_artifact_repo", + "tags" : "nexus_artifact_repo", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "nexus_artifact_repo", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json b/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json new file mode 100755 index 000000000..819c7e602 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json @@ -0,0 +1,25 @@ +{ + "name" : "nf-role", + "tags" : "nf-role", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf/nf-role", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid", + "input-key-mapping" : { + "vnfmodelcustomizationuuid" : "vnf-model-customization-uuid" + }, + "output-key-mapping" : { + "nf-role" : "vf_model_role" + }, + "key-dependencies" : [ "vnf-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json b/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json new file mode 100755 index 000000000..b82791877 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json @@ -0,0 +1,25 @@ +{ + "name" : "nfc-naming-code", + "tags" : "nfc-naming-code", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "nfc-naming-code", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "nfc-naming-code" : "nfc_naming_code" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json new file mode 100755 index 000000000..cee060153 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json @@ -0,0 +1,21 @@ +{ + "name" : "onap_private_net_cidr", + "tags" : "onap_private_net_cidr", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "onap_private_net_cidr", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private\"", + "output-key-mapping" : { + "onap_private_net_cidr" : "prefix" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json new file mode 100755 index 000000000..bb70fe3c4 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json @@ -0,0 +1,33 @@ +{ + "name": "onap_private_net_id", + "tags": "onap_private_net_id", + "updated-by": "Singal, Kapil ", + "property": { + "type": "string", + "description": "onap_private_net_id" + }, + "sources": { + "input": { + "type": "source-input" + }, + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/onap_private_net_id", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "onap_private_net_id": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json new file mode 100755 index 000000000..d38ceb49c --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json @@ -0,0 +1,33 @@ +{ + "name": "onap_private_subnet_id", + "tags": "onap_private_subnet_id", + "updated-by": "Singal, Kapil ", + "property": { + "type": "string", + "description": "onap_private_subnet_id" + }, + "sources": { + "input": { + "type": "source-input" + }, + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/onap_private_subnet_id", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "onap_private_subnet_id": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json new file mode 100755 index 000000000..5dea3e316 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json @@ -0,0 +1,21 @@ +{ + "name" : "private-prefix-id", + "tags" : "private-prefix-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "private-prefix-id", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private\"", + "output-key-mapping" : { + "private-prefix-id" : "prefix_id" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json new file mode 100755 index 000000000..fb572741c --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json @@ -0,0 +1,21 @@ +{ + "name" : "protected-prefix-id", + "tags" : "protected-prefix-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "protected-prefix-id", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"protected\"", + "output-key-mapping" : { + "protected-prefix-id" : "prefix_id" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json new file mode 100755 index 000000000..261920feb --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json @@ -0,0 +1,21 @@ +{ + "name" : "protected_private_net_cidr", + "tags" : "protected_private_net_cidr", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "protected_private_net_cidr", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"protected\"", + "output-key-mapping" : { + "protected_private_net_cidr" : "prefix" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_subnet_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_subnet_id.json new file mode 100755 index 000000000..b3daadc49 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_subnet_id.json @@ -0,0 +1,16 @@ +{ + "name" : "protected_private_subnet_id", + "tags" : "protected_private_subnet_id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "protected_private_subnet_id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json b/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json new file mode 100755 index 000000000..ce6c2f2a3 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json @@ -0,0 +1,34 @@ +{ + "name": "pub_key", + "tags": "pub_key", + "updated-by": "Singal, Kapil ", + "property": { + "type": "string", + "description": "pub_key" + }, + "sources": { + "input": { + "type": "source-input" + }, + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/pub_key", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "pub_key": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } +} + diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/public_net_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/public_net_id.json new file mode 100755 index 000000000..6cc9c2e38 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/public_net_id.json @@ -0,0 +1,14 @@ +{ + "name": "public_net_id", + "tags": "public_net_id", + "updated-by" : "Singal, Kapil ", + "property": { + "type": "string", + "description" : "public_net_id" + }, + "sources": { + "input": { + "type": "source-input" + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json new file mode 100644 index 000000000..90775aee0 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json @@ -0,0 +1,24 @@ +{ + "name": "sample-db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "db-source, brindasanth@onap.com", + "sources": { + "db": { + "type": "source-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-default-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-default-source.json new file mode 100644 index 000000000..395b0ddd1 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-default-source.json @@ -0,0 +1,16 @@ +{ + "tags": "sample-default-source", + "name": "sample-default-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-input-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-input-source.json new file mode 100644 index 000000000..73c0d4089 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-input-source.json @@ -0,0 +1,17 @@ +{ + "name": "sample-input-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "sample-input-source", + "sources": { + "input": { + "type": "source-input", + "properties": { + "key": "input-source" + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json new file mode 100644 index 000000000..5834dd49b --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json @@ -0,0 +1,29 @@ +{ + "tags": "sample-licenses", + "name": "sample-licenses", + "property": { + "description" : " Sample Data for licences", + "required": true, + "type": "list", + "entry_schema": { + "type": "dt-license-key" + } + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/", + "path": "/licenses", + "input-key-mapping": { + }, + "output-key-mapping": { + "licenses": "licenses" + }, + "key-dependencies": [] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json new file mode 100644 index 000000000..25464d3fe --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json @@ -0,0 +1,25 @@ +{ + "tags": "sample-mdsal-source", + "name": "sample-mdsal-source", + "property": { + "description": "Sample sample-mdsal-source", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", + "path": "/v4-assigned-ip-list/0/v4-ip-prefix", + "input-key-mapping": { + }, + "output-key-mapping": { + "mdsal-source": "v4-ip-prefix" + }, + "key-dependencies": [] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-v4-ip-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-v4-ip-type.json new file mode 100644 index 000000000..055279c1e --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-v4-ip-type.json @@ -0,0 +1,17 @@ +{ + "name": "sample-v4-ip-type", + "property": { + "description": "sample-v4-ip-type", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "sample-v4-ip-type", + "sources": { + "input": { + "type": "source-input", + "properties": { + "key": "sample-v4-ip-type" + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sec_group.json b/components/model-catalog/resource-dictionary/starter-dictionary/sec_group.json new file mode 100755 index 000000000..017ba984d --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sec_group.json @@ -0,0 +1,16 @@ +{ + "name" : "sec_group", + "tags" : "sec_group", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "sec_group", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json new file mode 100755 index 000000000..37b98687c --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json @@ -0,0 +1,15 @@ +{ + "name" : "service-instance-id", + "tags" : "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "To be provided", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/status.json b/components/model-catalog/resource-dictionary/starter-dictionary/status.json new file mode 100755 index 000000000..47a19d096 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/status.json @@ -0,0 +1,16 @@ +{ + "name" : "status", + "tags" : "status", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "status", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json new file mode 100755 index 000000000..3cb732056 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json @@ -0,0 +1,21 @@ +{ + "name" : "unprotected-prefix-id", + "tags" : "unprotected-prefix-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "unprotected-prefix-id", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"unprotected\"", + "output-key-mapping" : { + "unprotected-prefix-id" : "prefix_id" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json new file mode 100755 index 000000000..d2a339e7c --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json @@ -0,0 +1,21 @@ +{ + "name" : "unprotected_private_net_cidr", + "tags" : "unprotected_private_net_cidr", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "unprotected_private_net_cidr", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"unprotected\"", + "output-key-mapping" : { + "unprotected_private_net_cidr" : "prefix" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_subnet_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_subnet_id.json new file mode 100755 index 000000000..760d611ae --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_subnet_id.json @@ -0,0 +1,16 @@ +{ + "name" : "unprotected_private_subnet_id", + "tags" : "unprotected_private_subnet_id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "unprotected_private_subnet_id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-id.json new file mode 100755 index 000000000..74f9310e3 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-id.json @@ -0,0 +1,15 @@ +{ + "name" : "vf-module-id", + "tags" : "vf-module-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json new file mode 100755 index 000000000..ac5e21a6a --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-module-label", + "tags" : "vf-module-label", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-label", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", + "input-key-mapping" : { + "customizationid" : "vf-module-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-module-label" : "vf_module_label" + }, + "key-dependencies" : [ "vf-module-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-model-customization-uuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-model-customization-uuid.json new file mode 100755 index 000000000..6736e4feb --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-model-customization-uuid.json @@ -0,0 +1,15 @@ +{ + "name" : "vf-module-model-customization-uuid", + "tags" : "vf-module-model-customization-uuid", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-model-customization-uuid", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json new file mode 100755 index 000000000..147425c33 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-module-type", + "tags" : "vf-module-type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-module-type", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", + "input-key-mapping" : { + "customizationid" : "vf-module-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-module-type" : "vf_module_type" + }, + "key-dependencies" : [ "vf-module-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json new file mode 100755 index 000000000..f68cc3746 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-naming-policy", + "tags" : "vf-naming-policy", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-naming-policy", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", + "input-key-mapping" : { + "vnf_model_customization_uuid" : "vnf-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-naming-policy" : "vf_naming_policy" + }, + "key-dependencies" : [ "vnf-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json new file mode 100755 index 000000000..1865d47ff --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json @@ -0,0 +1,25 @@ +{ + "name" : "vf-nf-code", + "tags" : "vf-nf-code", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf-nf-code", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid", + "input-key-mapping" : { + "customizationid" : "vnf-model-customization-uuid" + }, + "output-key-mapping" : { + "vf-nf-code" : "vf_nf_code" + }, + "key-dependencies" : [ "vnf-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf_module_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf_module_name.json new file mode 100755 index 000000000..20ce458b8 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf_module_name.json @@ -0,0 +1,15 @@ +{ + "name" : "vf_module_name", + "tags" : "vf_module_name", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vf_module_name", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json new file mode 100755 index 000000000..463f8480b --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json @@ -0,0 +1,25 @@ +{ + "name" : "vfccustomizationuuid", + "tags" : "vfccustomizationuuid, tosca.datatypes.Root, data_type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfccustomizationuuid", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", + "input-key-mapping" : { + "vfmodulecustomizationuuid" : "vf-module-model-customization-uuid" + }, + "output-key-mapping" : { + "vfccustomizationuuid" : "vnf_customid" + }, + "key-dependencies" : [ "vf-module-model-customization-uuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_name_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_name_0.json new file mode 100755 index 000000000..96a975859 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_name_0.json @@ -0,0 +1,15 @@ +{ + "name" : "vfw_name_0", + "tags" : "vfw_name_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfw_name_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json new file mode 100755 index 000000000..71a4df2c4 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json @@ -0,0 +1,33 @@ +{ + "name" : "vfw_private_ip_0", + "tags" : "vfw_private_ip_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfw_private_ip_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vfw_private_ip_0", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vfw_private_ip_0" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json new file mode 100755 index 000000000..481edae8c --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json @@ -0,0 +1,33 @@ +{ + "name" : "vfw_private_ip_1", + "tags" : "vfw_private_ip_1", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vfw_private_ip_1", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vfw_private_ip_1", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vfw_private_ip_1" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_2.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_2.json new file mode 100755 index 000000000..f8adf741a --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_2.json @@ -0,0 +1,14 @@ +{ + "name": "vfw_private_ip_2", + "tags": "vfw_private_ip_2", + "updated-by" : "Singal, Kapil ", + "property": { + "type": "string", + "description" : "vfw_private_ip_2" + }, + "sources": { + "input": { + "type": "source-input" + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json new file mode 100755 index 000000000..0204c64bb --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json @@ -0,0 +1,25 @@ +{ + "name" : "vm-type", + "tags" : "vm-type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vm-type", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select VFC_MODEL.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "vm-type" : "vm_type" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnf-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-id.json new file mode 100755 index 000000000..7f3a18ffc --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-id.json @@ -0,0 +1,15 @@ +{ + "name" : "vnf-id", + "tags" : "vnf-id", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf-id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnf-model-customization-uuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-model-customization-uuid.json new file mode 100755 index 000000000..2aa08c40f --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-model-customization-uuid.json @@ -0,0 +1,15 @@ +{ + "name" : "vnf-model-customization-uuid", + "tags" : "vnf-model-customization-uuid", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf-model-customization-uuid", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json new file mode 100755 index 000000000..89b3dc1c0 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json @@ -0,0 +1,28 @@ +{ + "name" : "vnf-name", + "tags" : "vnf-name, tosca.datatypes.Root, data_type", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf-name", + "type" : "string" + }, + "sources" : { + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vnf-name" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json new file mode 100755 index 000000000..c55f1c18a --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json @@ -0,0 +1,27 @@ +{ + "name" : "vnf_name", + "tags" : "vnf_name", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnf_name", + "type" : "string" + }, + "sources" : { + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path" : "/param/0/value", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vnf_name" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json new file mode 100755 index 000000000..c894fb531 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json @@ -0,0 +1,25 @@ +{ + "name" : "vnfc-model-invariant-uuid", + "tags" : "vnfc-model-invariant-uuid", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnfc-model-invariant-uuid for SRIOV VPE template", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select VFC_MODEL.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "vnfc-model-invariant-uuid" : "vfc_invariant_uuid" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json new file mode 100755 index 000000000..45eb07f79 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json @@ -0,0 +1,25 @@ +{ + "name" : "vnfc-model-version", + "tags" : "vnfc-model-version", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vnfc-model-version for SRIOV VPE template", + "type" : "string" + }, + "sources" : { + "db" : { + "type" : "source-db", + "properties" : { + "type" : "SQL", + "query" : "select VFC_MODEL.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", + "input-key-mapping" : { + "vfccustomizationuuid" : "vfccustomizationuuid" + }, + "output-key-mapping" : { + "vnfc-model-version" : "vnfc_model_version" + }, + "key-dependencies" : [ "vfccustomizationuuid" ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/volume-name.json b/components/model-catalog/resource-dictionary/starter-dictionary/volume-name.json new file mode 100755 index 000000000..3fe5ab30f --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/volume-name.json @@ -0,0 +1,15 @@ +{ + "name" : "volume-name", + "tags" : "volume-name", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "volume-name", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/volume_group_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/volume_group_name.json new file mode 100755 index 000000000..90b360964 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/volume_group_name.json @@ -0,0 +1,16 @@ +{ + "name" : "volume_group_name", + "tags" : "volume_group_name", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "volume_group_name", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vpg_name_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_name_0.json new file mode 100755 index 000000000..f158d53c5 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_name_0.json @@ -0,0 +1,15 @@ +{ + "name" : "vpg_name_0", + "tags" : "vpg_name_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vpg_name_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json new file mode 100755 index 000000000..13d89993b --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json @@ -0,0 +1,33 @@ +{ + "name" : "vpg_private_ip_0", + "tags" : "vpg_private_ip_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vpg_private_ip_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vpg_private_ip_0", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vpg_private_ip_0" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_1.json b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_1.json new file mode 100755 index 000000000..ff58f8afb --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_1.json @@ -0,0 +1,16 @@ +{ + "name" : "vpg_private_ip_1", + "tags" : "vpg_private_ip_1", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vpg_private_ip_1", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vsn_name_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_name_0.json new file mode 100755 index 000000000..7b7ba4574 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_name_0.json @@ -0,0 +1,15 @@ +{ + "name" : "vsn_name_0", + "tags" : "vsn_name_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vsn_name_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json new file mode 100755 index 000000000..fcd6d8d55 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json @@ -0,0 +1,33 @@ +{ + "name" : "vsn_private_ip_0", + "tags" : "vsn_private_ip_0", + "updated-by" : "Singal, Kapil ", + "property" : { + "description" : "vsn_private_ip_0", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { + } + }, + "mdsal" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vsn_private_ip_0", + "path" : "/param/0/value", + "expression-type" : "JSON_POINTER", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vsn_private_ip_0" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + } + } +} diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_1.json b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_1.json new file mode 100755 index 000000000..52de69c62 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_1.json @@ -0,0 +1,14 @@ +{ + "name": "vsn_private_ip_1", + "tags": "vsn_private_ip_1", + "updated-by" : "Singal, Kapil ", + "property": { + "type": "string", + "description" : "vsn_private_ip_1" + }, + "sources": { + "input": { + "type": "source-input" + } + } +} diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 7377e7658..7308e9d2a 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -16,7 +16,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps @@ -28,14 +29,16 @@ App Components Parent pom - 2.0.5.RELEASE - 5.0.8.RELEASE - 1.2.70 + 2.0.6.RELEASE + 5.0.10.RELEASE + 1.3.0 + 1.0.1 1.0.0 26.0-jre 2.9.2 1.4.197 1.2.2 + 1.7.4 @@ -103,6 +106,11 @@ kotlin-stdlib ${kotlin.version} + + org.jetbrains.kotlin + kotlinx-couroutines-core + ${kotlin.couroutines.version} + org.jetbrains.kotlin kotlin-reflect @@ -113,6 +121,11 @@ kotlin-stdlib-jdk8 ${kotlin.version} + + org.jetbrains.kotlin + kotlin-stdlib-jdk7 + ${kotlin.version} + @@ -129,16 +142,6 @@ core ${project.version} - - org.onap.ccsdk.apps.controllerblueprints - service - ${project.version} - - - org.onap.ccsdk.apps.controllerblueprints - application - ${project.version} - org.onap.ccsdk.apps.controllerblueprints resource-dict @@ -149,12 +152,12 @@ org.powermock powermock-api-mockito2 - 1.7.4 + ${powermock.version} test org.jetbrains.kotlin - kotlin-test + kotlin-test-junit ${kotlin.version} test @@ -173,7 +176,7 @@ org.apache.commons commons-lang3 - + commons-collections commons-collections @@ -186,11 +189,10 @@ com.jayway.jsonpath json-path - - com.google.guava - guava - 26.0-jre - + + com.google.guava + guava + io.springfox springfox-swagger2 diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml index 508ae96f4..517895cb4 100644 --- a/components/resource-dict/pom.xml +++ b/components/resource-dict/pom.xml @@ -39,7 +39,7 @@ org.jetbrains.kotlin - kotlin-test + kotlin-test-junit test diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt index 6c83e5f93..6d186b598 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -49,10 +49,12 @@ open class ResourceDefinitionFileRepoService : BluePrintRepoFileService, constructor(basePath: String) : this(basePath, basePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE)) + .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE) + .plus(BluePrintConstants.PATH_DIVIDER) + .plus("starter-type")) constructor(basePath: String, modelTypePath: String) : super(modelTypePath) { - resourceDefinitionPath = basePath.plus("/resource_dictionary") + resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary") } override fun getResourceDefinition(resourceDefinitionName: String): Mono { diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java index 1772277df..6789c0e0e 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java @@ -25,7 +25,7 @@ public class ResourceDefinitionRepoServiceTest { @Test public void testGetResourceDefinition() throws Exception{ - ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("load"); + ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog"); ResourceDefinition resourceDefinition = resourceDefinitionRepoService .getResourceDefinition("db-source").block(); Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition); -- cgit 1.2.3-korg From c8f708adf9cdb0789fd29cce64a5fb0e89bfb7ca Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sun, 11 Nov 2018 17:41:48 -0500 Subject: Controller Blueprints Component Core Implement Blueprint context, run time service, metadata utils. Change-Id: Ifc3aa1e1b04b326778e431e972e5d997275c013b Issue-ID: CCSDK-670 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintProcessorException.kt | 3 +- .../controllerblueprints/core/CustomFunctions.kt | 69 ++++++- .../core/data/BluePrintModel.kt | 14 +- .../core/service/BluePrintContext.kt | 111 +++++++---- .../core/service/BluePrintRuntimeService.kt | 215 +++++++++++++++------ .../core/service/PropertyAssignmentService.kt | 11 +- .../core/utils/BluePrintMetadataUtils.kt | 60 +++--- .../core/utils/BluePrintRuntimeUtils.kt | 16 +- .../core/utils/TopologicalSortingUtils.kt | 4 +- .../core/service/BluePrintRuntimeServiceTest.kt | 58 ++---- .../core/utils/JacksonReactorUtilsTest.kt | 2 +- .../core/utils/JacksonUtilsTest.kt | 2 +- .../src/test/resources/properties/convert.json | 65 ++++--- 13 files changed, 412 insertions(+), 218 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt index 50717031d..000062134 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt @@ -16,12 +16,13 @@ */ package org.onap.ccsdk.apps.controllerblueprints.core + /** * * * @author Brinda Santh */ -class BluePrintProcessorException : Exception { +class BluePrintProcessorException : RuntimeException { var code: Int = 100 constructor(message: String, cause: Throwable) : super(message, cause) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt index 7302f2b96..c32e15f8a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -16,6 +16,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.BooleanNode +import com.fasterxml.jackson.databind.node.DoubleNode +import com.fasterxml.jackson.databind.node.IntNode +import com.fasterxml.jackson.databind.node.TextNode +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.slf4j.helpers.MessageFormatter import java.io.File import java.io.InputStream @@ -27,14 +33,30 @@ import kotlin.reflect.KClass * @author Brinda Santh */ -fun format(message: String, vararg args: Any?) : String{ - if(args != null && args.isNotEmpty()){ +fun String.asJsonPrimitive(): TextNode { + return TextNode(this) +} + +fun Boolean.asJsonPrimitive(): BooleanNode { + return BooleanNode.valueOf(this) +} + +fun Int.asJsonPrimitive(): IntNode { + return IntNode.valueOf(this) +} + +fun Double.asJsonPrimitive(): DoubleNode { + return DoubleNode.valueOf(this) +} + +fun format(message: String, vararg args: Any?): String { + if (args != null && args.isNotEmpty()) { return MessageFormatter.arrayFormat(message, args).message } - return message + return message } -fun MutableMap.getCastOptionalValue(key: String, valueType: KClass): T? { +fun MutableMap.castOptionalValue(key: String, valueType: KClass): T? { if (containsKey(key)) { return get(key) as? T } else { @@ -42,27 +64,54 @@ fun MutableMap.getCastOptionalValue(key: String, valueType: } } -fun MutableMap.getCastValue(key: String, valueType: KClass): T { +fun MutableMap.castValue(key: String, valueType: KClass): T { if (containsKey(key)) { return get(key) as T } else { - throw BluePrintException("couldn't find the key " + key) + throw BluePrintException("couldn't find the key $key") } } -fun checkNotEmpty(value : String?) : Boolean{ +fun MutableMap.putJsonElement(key: String, value: Any) { + when (value) { + is JsonNode -> + this.put(key, value) + is String -> + this.put(key, TextNode(value)) + is Boolean -> + this.put(key, BooleanNode.valueOf(value)) + is Int -> + this.put(key, IntNode.valueOf(value.toInt())) + is Double -> + this.put(key, DoubleNode.valueOf(value.toDouble())) + else -> + this.put(key, JacksonUtils.jsonNodeFromObject(value)) + } +} + +fun MutableMap.getAsString(key: String): String { + return this[key]?.asText() ?: throw BluePrintException("couldn't find value for key($key)") +} + +fun MutableMap.getAsBoolean(key: String): Boolean { + return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)") +} + +// Checks + +fun checkNotEmpty(value: String?): Boolean { return value != null && value.isNotEmpty() } -fun checkNotEmptyNThrow(value : String?, message : String? = value.plus(" is null/empty ")) : Boolean{ +fun checkNotEmptyNThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean { val notEmpty = value != null && value.isNotEmpty() - if(!notEmpty){ + if (!notEmpty) { throw BluePrintException(message!!) } return notEmpty } -fun InputStream.toFile(path: String) : File { +fun InputStream.toFile(path: String): File { val file = File(path) file.outputStream().use { this.copyTo(it) } return file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 70f3c5569..9b6fbbf19 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -91,7 +91,7 @@ A node filter definition defines criteria for selection of a TOSCA Node Template class NodeFilterDefinition { var properties: MutableMap? = null - var capabilities : MutableList? = null + var capabilities: MutableList? = null } /* @@ -348,7 +348,7 @@ class ArtifactType : EntityType() { A Data Type definition defines the schema for new named datatypes in TOSCA. */ -class DataType : EntityType(){ +class DataType : EntityType() { var constraints: MutableList? = null } @@ -410,7 +410,7 @@ class GroupType : EntityType() { topology at some stage of its lifecycle, but is not explicitly part of the topology itself (i.e., it does not prevent the application or service from being deployed or run if it did not exist). */ -class PolicyType : EntityType(){ +class PolicyType : EntityType() { lateinit var targets: MutableList } @@ -434,10 +434,10 @@ class GroupDefinition { var id: String? = null lateinit var type: String var description: String? = null - var metadata : MutableMap? = null - var properties : MutableMap? = null + var metadata: MutableMap? = null + var properties: MutableMap? = null var members = ArrayList() - var interfaces : MutableMap?= null + var interfaces: MutableMap? = null } /* @@ -597,7 +597,7 @@ class ServiceTemplate { @get:JsonProperty("node_types") var nodeTypes: MutableMap? = null @get:JsonProperty("policy_types") - var policyTypes: PolicyType? = null + var policyTypes: MutableMap? = null @get:JsonProperty("topology_template") var topologyTemplate: TopologyTemplate? = null } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 46da9d95a..4764479ad 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -22,17 +22,16 @@ import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + /** * * * @author Brinda Santh */ -class BluePrintContext(serviceTemplate: ServiceTemplate) { +class BluePrintContext(val serviceTemplate: ServiceTemplate) { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - val serviceTemplate: ServiceTemplate = serviceTemplate - val imports: List? = serviceTemplate.imports val metadata: MutableMap? = serviceTemplate.metadata @@ -41,18 +40,33 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { val inputs: MutableMap? = serviceTemplate.topologyTemplate?.inputs - val workflows: MutableMap? = serviceTemplate.topologyTemplate?.workflows - fun blueprintJson(pretty: Boolean = false): String = print("json", pretty) - fun blueprintYaml(pretty: Boolean = false): String = print("yaml", pretty) - private fun print(type: String? = "json", pretty: Boolean = false): String { return JacksonUtils.getJson(serviceTemplate, pretty) } // Workflow - fun workflowByName(name: String): Workflow? = workflows?.get(name) + val workflows: MutableMap? = serviceTemplate.topologyTemplate?.workflows + + fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName) + ?: throw BluePrintException("could't get workflow($workFlowName)") + + fun workflowStepByName(workFlowName: String, stepName: String): Step { + return workflowByName(workFlowName).steps?.get(stepName) + ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)") + } + + fun workflowStepNodeTemplate(workFlowName: String, stepName: String): NodeTemplate { + val nodeTemplateName = workflowStepByName(workFlowName, stepName).target + ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)") + return nodeTemplateByName(nodeTemplateName) + } + + fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String { + return workflowStepByName(workFlowName, stepName).activities?.filter { it.callOperation != null }?.single()?.callOperation + ?: throw BluePrintException("could't get first callOperation for WorkFlow($workFlowName) ") + } // Data Type fun dataTypeByName(name: String): DataType? = dataTypes?.get(name) @@ -60,41 +74,65 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { // Artifact Type val artifactTypes: MutableMap? = serviceTemplate.artifactTypes + // Policy Types + val policyTypes: MutableMap? = serviceTemplate.policyTypes + + fun policyTypeByName(policyName: String) = policyTypes?.get(policyName) + ?: throw BluePrintException("could't get policy type for the name($policyName)") + + fun policyTypesDerivedFrom(name: String): MutableMap? { + return policyTypes?.filterValues { policyType -> policyType.derivedFrom == name }?.toMutableMap() + } + + fun policyTypesTarget(target: String): MutableMap? { + return policyTypes?.filterValues { it.targets.contains(target) }?.toMutableMap() + } + + fun policyTypesTargetNDerivedFrom(target: String, derivedFrom: String): MutableMap? { + return policyTypesDerivedFrom(derivedFrom)?.filterValues { + it.targets.contains(target) + }?.toMutableMap() + } + // Node Type Methods val nodeTypes: MutableMap? = serviceTemplate.nodeTypes fun nodeTypeByName(name: String): NodeType = - nodeTypes?.get(name) ?: throw BluePrintException(String.format("Failed to get node type for the name : %s", name)) + nodeTypes?.get(name) + ?: throw BluePrintException("could't get node type for the name($name)") fun nodeTypeDerivedFrom(name: String): MutableMap? { return nodeTypes?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap() } - fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition? { + fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition { return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName) + ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)") } - fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition? { - return nodeTypeInterface(nodeTypeName, interfaceName)?.operations?.get(operationName) + fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition { + return nodeTypeInterface(nodeTypeName, interfaceName).operations?.get(operationName) + ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)") } - fun interfaceNameForNodeType(nodeTypeName: String): String? { + fun interfaceNameForNodeType(nodeTypeName: String): String { return nodeTypeByName(nodeTypeName).interfaces?.keys?.first() + ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name") } fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.inputs + return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).inputs } fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName)?.outputs + return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).outputs } // Node Template Methods val nodeTemplates: MutableMap? = serviceTemplate.topologyTemplate?.nodeTemplates fun nodeTemplateByName(name: String): NodeTemplate = - nodeTemplates?.get(name) ?: throw BluePrintException("Failed to get node template for the name " + name) + nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name) ") fun nodeTemplateForNodeType(name: String): MutableMap? { return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() @@ -113,55 +151,62 @@ class BluePrintContext(serviceTemplate: ServiceTemplate) { return nodeTemplateByName(nodeTemplateName).artifacts } - fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition? { + fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition { return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)") } - fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment? { + fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment { return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first() + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment") } - fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String? { + fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String { return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first() + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name") } - fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String? { - return nodeTemplateFirstInterface(nodeTemplateName)?.operations?.keys?.first() + fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String { + return nodeTemplateFirstInterface(nodeTemplateName).operations?.keys?.first() + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name") } fun nodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.inputs + return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).inputs } fun nodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)?.operations?.get(operationName)?.outputs + return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).outputs } - fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment? { + fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment { return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)") } - - fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment? { - return nodeTemplateInterface(nodeTemplateName, interfaceName)?.operations?.get(operationName) + fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment { + return nodeTemplateInterface(nodeTemplateName, interfaceName).operations?.get(operationName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)") } - fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment? { + fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment { return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)") } - fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment? { + fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment { return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)") } fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate { - val requirementNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node - ?: throw BluePrintException(String.format("failed to get node name for node template's (%s) requirement's (%s) " + nodeTemplateName, requirementName)) - return nodeTemplateByName(requirementNodeTemplateName) + val filteredNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node + ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ") + return nodeTemplateByName(filteredNodeTemplateName) } fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? { - return nodeTemplateCapability(nodeTemplateName, capabilityName)?.properties?.get(propertyName) + return nodeTemplateCapability(nodeTemplateName, capabilityName).properties?.get(propertyName) } // Chained Functions diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 2485abdb5..f84b2c569 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -18,8 +18,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException @@ -27,31 +31,123 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.node.ObjectNode -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper + +interface BluePrintRuntimeService { + + fun id(): String + + fun bluePrintContext(): BluePrintContext + + fun getExecutionContext(): T + + fun setExecutionContext(executionContext: T) + + fun put(key: String, value: JsonNode) + + fun get(key: String): JsonNode? + + fun cleanRuntime() + + /* + Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing + */ + fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap + + fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap + + fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap + + fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String + + fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) + + fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) + + fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) + + fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) + + fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) + + fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) + + fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) + + fun getInputValue(propertyName: String): JsonNode + + fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode + + fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? + + fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? + + fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? + + fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? + + fun assignInputs(jsonNode: JsonNode) + + fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) + + fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode +} /** * * * @author Brinda Santh */ -open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var context: MutableMap = hashMapOf()) { +open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) + : BluePrintRuntimeService> { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString()) + private var store: MutableMap = hashMapOf() + + override fun id(): String { + return id + } + + override fun bluePrintContext(): BluePrintContext { + return bluePrintContext + } + + override fun getExecutionContext(): MutableMap { + return store + } + + @Suppress("UNCHECKED_CAST") + override fun setExecutionContext(executionContext: MutableMap) { + this.store = executionContext + } + + override fun put(key: String, value: JsonNode) { + store[key] = value + } + + override fun get(key: String): JsonNode { + return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)") + } + + override fun cleanRuntime() { + store.clear() + } + + private fun getJsonNode(key: String): JsonNode { + return get(key) + } + /* Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing */ - open fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { + override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) - val propertyAssignmentValue: MutableMap = hashMapOf() + val propertyAssignmentValue: MutableMap = hashMapOf() val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - val propertyAssignments: MutableMap = - nodeTemplate.properties as MutableMap + val propertyAssignments: MutableMap = + nodeTemplate.properties as MutableMap // Get the Node Type Definitions val nodeTypeProperties: MutableMap = @@ -65,7 +161,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { // Resolve the Expressing - val propertyAssignmentExpression = PropertyAssignmentService(context, this) + val propertyAssignmentExpression = PropertyAssignmentService(this) resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) } else { // Assign default value to the Operation @@ -80,12 +176,12 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c return propertyAssignmentValue } - open fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, - interfaceName: String, operationName: String): MutableMap { + override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, + interfaceName: String, operationName: String): MutableMap { log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " + "operationName({})", nodeTemplateName, interfaceName, operationName) - val propertyAssignmentValue: MutableMap = hashMapOf() + val propertyAssignmentValue: MutableMap = hashMapOf() val propertyAssignments: MutableMap = bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap @@ -109,7 +205,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { // Resolve the Expressing - val propertyAssignmentExpression = PropertyAssignmentService(context, this) + val propertyAssignmentExpression = PropertyAssignmentService(this) resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) } else { // Assign default value to the Operation @@ -127,12 +223,12 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c } - open fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, - interfaceName: String, operationName: String): MutableMap { + override fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, + interfaceName: String, operationName: String): MutableMap { log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ({}),interface name ({}), " + "operationName({})", nodeTemplateName, interfaceName, operationName) - val propertyAssignmentValue: MutableMap = hashMapOf() + val propertyAssignmentValue: MutableMap = hashMapOf() val propertyAssignments: MutableMap = bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap @@ -155,7 +251,7 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { // Resolve the Expressing - val propertyAssignmentExpression = PropertyAssignmentService(context, this) + val propertyAssignmentExpression = PropertyAssignmentService(this) resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) } else { // Assign default value to the Operation @@ -173,131 +269,131 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c return propertyAssignmentValue } - open fun resolveNodeTemplateArtifact(nodeTemplateName: String, - artifactName: String): String { + override fun resolveNodeTemplateArtifact(nodeTemplateName: String, + artifactName: String): String { val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName) ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template" , artifactName)) - val propertyAssignmentExpression = PropertyAssignmentService(context, this) + val propertyAssignmentExpression = PropertyAssignmentService(this) return propertyAssignmentExpression.artifactContent(artifactDefinition) } - open fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { + override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { val path = StringBuilder(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() log.trace("setting input path ({}), values ({})", path, value) - context[path] = value + put(path, value) } - open fun setWorkflowInputValue(workflowName: String, propertyName: String, value: JsonNode) { + override fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS).append(BluePrintConstants.PATH_DIVIDER).append(workflowName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - context[path] = value + put(path, value) } - open fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { + override fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - context[path] = value + put(path, value) } - open fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { + override fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() - context[path] = value + put(path, value) } - open fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { + override fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() log.trace("setting operation property path ({}), values ({})", path, value) - context[path] = value + put(path, value) } - open fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { + override fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - context[path] = value + put(path, value) } - open fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { + override fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - context[path] = value + put(path, value) } - open fun getInputValue(propertyName: String): JsonNode { + override fun getInputValue(propertyName: String): JsonNode { val path = StringBuilder(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return context[path] as? JsonNode ?: NullNode.instance + return getJsonNode(path) } - open fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode { + override fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS).append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return context[path] as JsonNode + return getJsonNode(path) } - open fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? { + override fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return context[path] as JsonNode + return getJsonNode(path) } - open fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? { + override fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() - return context[path] as JsonNode + return getJsonNode(path) } - open fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: - String): JsonNode? { + override fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: + String): JsonNode { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return context[path] as JsonNode + return getJsonNode(path) } - open fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: - String): JsonNode? { + override fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: + String): JsonNode { val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return context[path] as JsonNode + return getJsonNode(path) } - open fun assignInputs(jsonNode: JsonNode) { + override fun assignInputs(jsonNode: JsonNode) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) bluePrintContext.inputs?.forEach { propertyName, property -> val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) @@ -306,27 +402,28 @@ open class BluePrintRuntimeService(var bluePrintContext: BluePrintContext, var c } } - open fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { + override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString()) - bluePrintContext.workflowByName(workflowName)?.inputs?.forEach { propertyName, _ -> + + bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property -> val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) ?: NullNode.getInstance() - setWorkflowInputValue(workflowName, propertyName, valueNode) + setInputValue(propertyName, property, valueNode) } } - open fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode { + override fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode { val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode() val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) .append(BluePrintConstants.PATH_DIVIDER).toString() - context.keys.filter { + store.keys.filter { it.startsWith(path) }.map { val key = it.replace(path, "") if (keys.contains(key)) { - val value = context[it] as JsonNode + val value = store[it] as JsonNode jsonNode.set(key, value) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 131bb30ae..5b511f158 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -18,6 +18,8 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants @@ -26,19 +28,16 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager /** * * * @author Brinda Santh */ -class PropertyAssignmentService(var context: MutableMap, - var bluePrintRuntimeService: BluePrintRuntimeService) { +class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService>) { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext + private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext() /* @@ -198,7 +197,7 @@ If Property Assignment is Expression. } fun artifactContent(artifactDefinition: ArtifactDefinition): String { - val bluePrintBasePath: String = context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] as? String + val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) as? String ?: throw BluePrintException(format("failed to get property (%s) from context", BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)) if (artifactDefinition.repository != null) { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index b7f9fc7e6..43d55feac 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -17,11 +17,16 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode import org.apache.commons.io.FileUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService import java.io.File import java.nio.charset.Charset @@ -57,39 +62,46 @@ object BluePrintMetadataUtils { return toscaMetaData } - /* + @JvmStatic fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { - val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator) - .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString() - - val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile) + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) - log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions) + log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") - return BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath) + return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) } - fun getBluePrintRuntime(requestId: String, blueprintBasePath: String): BluePrintRuntimeService { - - val metaDataFile = StringBuilder().append(blueprintBasePath).append(File.separator) - .append(BluePrintConstants.DEFAULT_TOSCA_METADATA_ENTRY_DEFINITION_FILE).toString() - - val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(metaDataFile) + @JvmStatic + fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - log.info("Processing blueprint base path ({}) and entry definition file ({})", blueprintBasePath, toscaMetaData.entityDefinitions) + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile(toscaMetaData.entityDefinitions!!, blueprintBasePath) + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath - context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = requestId + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(context) - val bluePrintRuntimeService: BluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + return bluePrintRuntimeService + } + @JvmStatic + fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap): BluePrintRuntimeService> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(executionContext) return bluePrintRuntimeService } - */ + + @JvmStatic + fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { + val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) + val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + // TODO ("Fix for Multiple Service Template file definitions") +// val schemaImportResolverUtils = BluePrintResolverService(rootServiceTemplate, basePath) +// val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() + return BluePrintContext(rootServiceTemplate) + } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt index 0e4c3e3e8..4501275cf 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -16,12 +16,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager /** * @@ -31,17 +31,23 @@ import com.att.eelf.configuration.EELFManager object BluePrintRuntimeUtils { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { + fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) return assignInputs(bluePrintContext, jsonNode, context) } - fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap) { + fun assignInputsFromClassPathFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { + val jsonNode = JacksonUtils.jsonNodeFromClassPathFile(fileName) + return assignInputs(bluePrintContext, jsonNode, context) + } + + fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap) { val jsonNode: JsonNode = JacksonUtils.jsonNode(content) return assignInputs(bluePrintContext, jsonNode, context) } - fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap) { + fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) bluePrintContext.inputs?.forEach { propertyName, _ -> val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt index dcafa974c..9d6fe084a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt @@ -64,7 +64,7 @@ class TopologicalSortingUtils { } fun outDegree(): Map { - var result: MutableMap = hashMapOf() + val result: MutableMap = hashMapOf() for (v in neighbors.keys) result[v] = neighbors[v]!!.size return result @@ -108,7 +108,7 @@ class TopologicalSortingUtils { fun bfsDistance(start: V): Map<*, *> { - var distance: MutableMap = hashMapOf() + val distance: MutableMap = hashMapOf() // Initially, all distance are infinity, except start node for (v in neighbors.keys) distance[v] = -1 diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index f1980d279..68031d292 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -17,16 +17,16 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode -import org.junit.Before import org.junit.Test import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -37,13 +37,6 @@ import kotlin.test.assertNotNull */ class BluePrintRuntimeServiceTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - val basepath = "load/blueprints" - - - @Before - fun setUp(): Unit { - - } @Test fun testResolveNodeTemplateProperties() { @@ -56,40 +49,32 @@ class BluePrintRuntimeServiceTest { val inputNode: JsonNode = jsonNodeFromFile(inputDataPath) bluePrintRuntimeService.assignInputs(inputNode) - val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action") - log.info("Context {}", bluePrintRuntimeService.context) + val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action") assertNotNull(propContext, "Failed to populate interface property values") - assertEquals(propContext.get("mode"), jsonNodeFromObject("sync"), "Failed to populate parameter process-name") - assertEquals(propContext.get("version"), jsonNodeFromObject("1.0.0"), "Failed to populate parameter version") + assertEquals(propContext.get("mode"), "sync".asJsonPrimitive(), "Failed to populate parameter process-name") + assertEquals(propContext.get("version"), "1.0.0".asJsonPrimitive(), "Failed to populate parameter version") } @Test fun testResolveNodeTemplateInterfaceOperationInputs() { log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - assertNotNull(bluePrintContext, "Failed to populate Blueprint context") - - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") - - val inputDataPath = "src/test/resources/data/default-context.json" - BluePrintRuntimeUtils.assignInputsFromFile(bluePrintContext, inputDataPath, context) + val bluePrintRuntimeService = getBluePrintRuntimeService() - val bluePrintRuntimeService = BluePrintRuntimeService(bluePrintContext, context) + val executionContext = bluePrintRuntimeService.getExecutionContext() - log.info("Prepared Context {}", context) + BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), + "data/default-context.json", executionContext) - val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component", + val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component", "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process") log.info("In Context {}", inContext) assertNotNull(inContext, "Failed to populate interface input property values") - assertEquals(inContext.get("action-name"), jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") - assertEquals(inContext.get("request-id"), jsonNodeFromObject("12345"), "Failed to populate parameter action-name") + assertEquals(inContext.get("action-name"), "sample-action".asJsonPrimitive(), "Failed to populate parameter action-name") + assertEquals(inContext.get("request-id"), "12345".asJsonPrimitive(), "Failed to populate parameter action-name") } @Test @@ -129,8 +114,6 @@ class BluePrintRuntimeServiceTest { bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2", jsonNodeFromObject("context2-value")) - log.info("Context {}", bluePrintRuntimeService.context) - val keys = listOf("context1", "context2") val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys) @@ -139,15 +122,14 @@ class BluePrintRuntimeServiceTest { } - private fun getBluePrintRuntimeService(): BluePrintRuntimeService { - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + private fun getBluePrintRuntimeService(): BluePrintRuntimeService> { + val blueprintBasePath: String = ("load/blueprints/baseconfiguration") + val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) + val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = basepath.plus("/simple-baseconfig") + assertEquals(blueprintBasePath.asJsonPrimitive(), checkBasePath, "Failed to get base path after runtime creation") - return BluePrintRuntimeService(bluePrintContext, context) + return blueprintRuntime } } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index d13caa52c..c5f451ea6 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -35,7 +35,7 @@ class JacksonReactorUtilsTest { assertNotNull(serviceTemplate, "Failed to simple transform Service Template") assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance") - val jsonContent = JacksonReactorUtils.getJson(serviceTemplate!!, true).block() + val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block() assertNotNull(jsonContent, "Failed to get json content") val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json") diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt index a5a630e3c..c3718b27a 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -44,7 +44,7 @@ class JacksonUtilsTest { assertNotNull(serviceTemplate, "Failed to simple transform Service Template") assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance") - val jsonContent = JacksonUtils.getJson(serviceTemplate!!, true) + val jsonContent = JacksonUtils.getJson(serviceTemplate, true) assertNotNull(jsonContent, "Failed to get json content") } diff --git a/components/core/src/test/resources/properties/convert.json b/components/core/src/test/resources/properties/convert.json index af79915fa..966b02533 100644 --- a/components/core/src/test/resources/properties/convert.json +++ b/components/core/src/test/resources/properties/convert.json @@ -1,33 +1,36 @@ { - "type": "sdnc-component-getResourceAssignment", - "interfaces": { - "ResourceAssignmentService": { - "operations": { - "getResourceAssignment": { - "inputs": { - "assignment-mappings": [ - { - "name": "service-name", - "mapping-field": "service", - "mapping-category": "SDN", - "required": true - }, - { - "name": "region-name", - "mapping-field": "region", - "mapping-category": "SDN", - "required": true - } - ], - "pre-data": { "get_input" : "get-resource-assignment.config-params" }, - "prifix": "get-resource-assignment" - }, - "outputs": { - "resource-assignment-status": "success", - "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" } - } - } - } - } - } + "type": "sdnc-component-getResourceAssignment", + "interfaces": { + "ResourceAssignmentService": { + "operations": { + "getResourceAssignment": { + "inputs": { + "assignment-mappings": [ + { + "name": "service-name", + "mapping-field": "service", + "mapping-category": "SDN", + "required": true + }, + { + "name": "region-name", + "mapping-field": "region", + "mapping-category": "SDN", + "required": true + } + ], + "pre-data": { + "get_input": "get-resource-assignment.config-params" + }, + "prifix": "get-resource-assignment" + }, + "outputs": { + "resource-assignment-status": "success", + "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" + } + } + } + } + } } + -- cgit 1.2.3-korg From 2c505b980ea8942ba84fb99278dd1c34a5b5873c Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 12 Nov 2018 12:32:25 -0500 Subject: Controller Blueprints Component Core Modify test case blueprint data pointing to model catalog location. Change-Id: I601eddf899516b01ae8624c96aa13c5e236c8e5b Issue-ID: CCSDK-678 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/factory/BluePrintParserFactory.kt | 51 ---------------------- .../core/service/PropertyAssignmentService.kt | 4 +- .../core/service/BluePrintContextTest.kt | 35 ++++----------- .../core/service/BluePrintParserFactoryTest.kt | 42 ------------------ .../core/service/BluePrintRuntimeServiceTest.kt | 44 ++++++++----------- .../BluePrintValidatorDefaultServiceTest.kt | 18 ++++---- .../core/utils/BluePrintMetadataUtilsTest.kt | 2 +- .../core/utils/JacksonReactorUtilsTest.kt | 4 +- .../core/utils/JacksonUtilsTest.kt | 21 ++------- .../Definitions/activation-blueprint.json | 9 +++- 10 files changed, 52 insertions(+), 178 deletions(-) delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt deleted file mode 100644 index 83233abc1..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintParserFactory.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.factory - -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintParserDefaultService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintParserService -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager - -/** - * - * BluePrintParserFactory - * @author Brinda Santh - */ - -object BluePrintParserFactory { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - var bluePrintParserServices: MutableMap = HashMap() - - init { - log.info("Initialised default BluePrintParser Service ") - bluePrintParserServices.put(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT, BluePrintParserDefaultService()) - } - - fun register(key:String, bluePrintParserService: BluePrintParserService){ - bluePrintParserServices.put(key, bluePrintParserService) - } - - /** - * Called by clients to get a Blueprint Parser for the Blueprint parser type - */ - fun instance(key : String) : BluePrintParserService? { - return bluePrintParserServices.get(key) - } -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 5b511f158..947eb41e0 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -197,8 +197,8 @@ If Property Assignment is Expression. } fun artifactContent(artifactDefinition: ArtifactDefinition): String { - val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) as? String - ?: throw BluePrintException(format("failed to get property (%s) from context", BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)) + val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText() + ?: throw BluePrintException("failed to get property (${BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH}) from getStore") if (artifactDefinition.repository != null) { TODO() diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt index 7a74ca476..6cfed3246 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt @@ -17,17 +17,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service -import org.apache.commons.io.FileUtils -import org.junit.Before -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager -import java.io.File -import java.nio.charset.Charset +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import kotlin.test.assertNotNull + /** * * @@ -37,30 +33,17 @@ class BluePrintContextTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - lateinit var bluePrintContext: BluePrintContext - - @Before - fun setUp() { - - val basepath = "load/blueprints" - - bluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - assertNotNull(bluePrintContext, "Failed to populate Blueprint context") - } + val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") @Test - fun testBluePrintContextFromContent() { - val fileName = "load/blueprints/baseconfiguration/Definitions/activation-blueprint.json" - val content : String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) - val bpContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprint(content) - assertNotNull(bpContext, "Failed to get blueprint content") - assertNotNull(bpContext.serviceTemplate, "Failed to get blueprint content's service template") + fun testBluePrintContextCreation() { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") } @Test fun testChainedProperty() { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) val nodeType = bluePrintContext.nodeTypeChained("component-resource-assignment") assertNotNull(nodeType, "Failed to get chained node type") log.trace("Properties {}", JacksonUtils.getJson(nodeType, true)) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt deleted file mode 100644 index 5a5557d75..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserFactoryTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import kotlin.test.assertNotNull - -/** - * - * - * @author Brinda Santh - */ -class BluePrintParserFactoryTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @Test - fun testBluePrintJson() { - val basepath = "load/blueprints" - - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - assertNotNull(bluePrintContext, "Failed to populate Blueprint context") - log.trace("Blue Print {}",bluePrintContext.blueprintJson(true)) - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 68031d292..19c6c2f9d 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -20,6 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode import org.junit.Test import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive @@ -49,11 +50,11 @@ class BluePrintRuntimeServiceTest { val inputNode: JsonNode = jsonNodeFromFile(inputDataPath) bluePrintRuntimeService.assignInputs(inputNode) - val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("resource-assignment-action") + val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") assertNotNull(propContext, "Failed to populate interface property values") - assertEquals(propContext.get("mode"), "sync".asJsonPrimitive(), "Failed to populate parameter process-name") - assertEquals(propContext.get("version"), "1.0.0".asJsonPrimitive(), "Failed to populate parameter version") + assertEquals(propContext["process-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter process-name") + assertEquals(propContext["version"], jsonNodeFromObject("sample-action"), "Failed to populate parameter version") } @Test @@ -67,14 +68,13 @@ class BluePrintRuntimeServiceTest { BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), "data/default-context.json", executionContext) - val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment-ra-component", - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process") - - log.info("In Context {}", inContext) + val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment", + "DefaultComponentNode", "process") assertNotNull(inContext, "Failed to populate interface input property values") - assertEquals(inContext.get("action-name"), "sample-action".asJsonPrimitive(), "Failed to populate parameter action-name") - assertEquals(inContext.get("request-id"), "12345".asJsonPrimitive(), "Failed to populate parameter action-name") + assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") + assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name") + assertEquals(inContext["template-content"], jsonNodeFromObject("This is Sample Velocity Template"), "Failed to populate parameter action-name") } @Test @@ -83,24 +83,18 @@ class BluePrintRuntimeServiceTest { val bluePrintRuntimeService = getBluePrintRuntimeService() - val successValue: JsonNode = jsonNodeFromObject("Success") - val paramValue: JsonNode = jsonNodeFromObject("param-content") - - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "params", paramValue) - - bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment-ra-component", - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process") - - val resourceAssignmentParamsNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component", - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "resource-assignment-params") - - val statusNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment-ra-component", - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode", "process", "status") + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance()) - assertEquals(paramValue, resourceAssignmentParamsNode, "Failed to get operation property resource-assignment-params") + bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", + "DefaultComponentNode", "process") - assertEquals(successValue, statusNode, "Failed to get operation property status") + val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", + "DefaultComponentNode", "process", "status") + assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status") + val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", + "DefaultComponentNode", "process", "resource-assignment-params") + assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params") } @@ -123,7 +117,7 @@ class BluePrintRuntimeServiceTest { } private fun getBluePrintRuntimeService(): BluePrintRuntimeService> { - val blueprintBasePath: String = ("load/blueprints/baseconfiguration") + val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt index b05fcb61b..09c58170f 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt @@ -16,12 +16,11 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service -import org.junit.Before -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.factory.BluePrintParserFactory import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager +import org.junit.Before +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils /** * @@ -30,7 +29,6 @@ import com.att.eelf.configuration.EELFManager */ class BluePrintValidatorDefaultServiceTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - val basepath = "load/blueprints" @Before fun setUp(): Unit { @@ -39,11 +37,13 @@ class BluePrintValidatorDefaultServiceTest { @Test fun testValidateBluePrint() { - val bluePrintContext: BluePrintContext = BluePrintParserFactory.instance(BluePrintConstants.TYPE_DEFAULT)!! - .readBlueprintFile("baseconfiguration/Definitions/activation-blueprint.json", basepath) - val properties : MutableMap = hashMapOf() + + val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + val properties: MutableMap = hashMapOf() + val validatorService = BluePrintValidatorDefaultService() - validatorService.validateBlueprint(bluePrintContext.serviceTemplate,properties) + validatorService.validateBlueprint(bluePrintContext.serviceTemplate, properties) log.info("Validation Message {}", properties) } } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt index ddb39a2d6..d5b184f6e 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt @@ -26,7 +26,7 @@ class BluePrintMetadataUtilsTest { @Test fun testToscaMetaData(){ - val basePath : String = "load/blueprints/baseconfiguration" + val basePath : String = "./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration" val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath) assertNotNull(toscaMetaData, "Missing Tosca Definition Object") diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index c5f451ea6..be76593d8 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -29,7 +29,7 @@ class JacksonReactorUtilsTest { @Test fun testReadValues() { - val serviceTemplate = JacksonReactorUtils.readValueFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json", + val serviceTemplate = JacksonReactorUtils.readValueFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json", ServiceTemplate::class.java).block() assertNotNull(serviceTemplate, "Failed to simple transform Service Template") @@ -38,7 +38,7 @@ class JacksonReactorUtilsTest { val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block() assertNotNull(jsonContent, "Failed to get json content") - val jsonNode = JacksonReactorUtils.jsonNodeFromFile("load/blueprints/baseconfiguration/Definitions/activation-blueprint.json") + val jsonNode = JacksonReactorUtils.jsonNodeFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json") .block() assertNotNull(jsonContent, "Failed to get json Node") } diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt index c3718b27a..b5edab0fa 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -17,12 +17,10 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager -import kotlin.test.assertEquals +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -35,19 +33,6 @@ class JacksonUtilsTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - val basePath = "load/blueprints" - - @Test - fun testReadValues() { - val content = ResourceResolverUtils.getFileContent("baseconfiguration/Definitions/activation-blueprint.json", basePath) - val serviceTemplate = JacksonUtils.readValue(content, ServiceTemplate::class.java) - assertNotNull(serviceTemplate, "Failed to simple transform Service Template") - assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance") - - val jsonContent = JacksonUtils.getJson(serviceTemplate, true) - assertNotNull(jsonContent, "Failed to get json content") - } - @Test fun testJsonNodeFromClassPathFile() { val filePath = "data/default-context.json" @@ -56,7 +41,7 @@ class JacksonUtilsTest { @Test fun testJsonNodeFromFile() { - val filePath = basePath + "/baseconfiguration/Definitions/activation-blueprint.json" + val filePath = "src/test/resources/data/default-context.json" JacksonUtils.jsonNodeFromFile(filePath) } diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 4c1ca4a52..0137cd2bd 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -87,8 +87,13 @@ } }, "outputs": { - "resource-assignment-params": "", - "status": "" + "resource-assignment-params": { + "get_attribute": [ + "SELF", + "assignment-params" + ] + }, + "status": "success" } } } -- cgit 1.2.3-korg From 3f4f703dc13b6b4640bc849da5fbcf44e862a103 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 12 Nov 2018 13:08:42 -0500 Subject: Controller Blueprints Component Core Clean unused blueprint and model files under component core. Change-Id: I9385a653c5d6874b9267e9607fc497dac17b1c35 Issue-ID: CCSDK-677 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../Definitions/activation-blueprint.json | 411 --------------------- .../Mappings/baseconfig-mapping.json | 3 - .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 ---- .../Scripts/SamplePythonComponentNode.py | 8 - .../baseconfiguration/Scripts/__init__.py | 0 .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 8 - .../Templates/baseconfig-template.vtl | 1 - .../load/blueprints/baseconfiguration/__init__.py | 0 .../Definitions/sample-nodetype.json | 5 - .../Definitions/simple-baseconfig.json | 340 ----------------- .../Mappings/baseconfig-mapping.json | 3 - .../simple-baseconfig/Plans/ActivateProcess.bpmn | 66 ---- .../Scripts/SamplePythonComponentNode.py | 8 - .../simple-baseconfig/Scripts/__init__.py | 0 .../simple-baseconfig/TOSCA-Metadata/TOSCA.meta | 8 - .../Templates/base-config-template.vtl | 40 -- .../Templates/baseconfig-template.vtl | 1 - .../Templates/licence-template.vtl | 4 - .../load/blueprints/simple-baseconfig/__init__.py | 0 19 files changed, 972 deletions(-) delete mode 100644 components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json delete mode 100644 components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json delete mode 100644 components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn delete mode 100644 components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py delete mode 100644 components/core/load/blueprints/baseconfiguration/Scripts/__init__.py delete mode 100644 components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta delete mode 100644 components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl delete mode 100644 components/core/load/blueprints/baseconfiguration/__init__.py delete mode 100644 components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json delete mode 100644 components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json delete mode 100644 components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json delete mode 100644 components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn delete mode 100644 components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py delete mode 100644 components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py delete mode 100644 components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta delete mode 100644 components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl delete mode 100644 components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl delete mode 100644 components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl delete mode 100644 components/core/load/blueprints/simple-baseconfig/__init__.py diff --git a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json deleted file mode 100644 index bc10f7673..000000000 --- a/components/core/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ /dev/null @@ -1,411 +0,0 @@ -{ - "metadata": { - "template_author": "Brinda Santh Muthuramalingam", - "author-email": "brindasanth@gmail.com", - "user-groups": "ADMIN, OPERATION", - "template_name": "baseconfiguration", - "template_version": "1.0.0", - "template_tags": "brinda, tosca" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - }, - "template_name": { - "required": true, - "type": "string" - }, - "template_version": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "resource-assignment-ra-component": { - "capabilities": { - "component-node": {} - }, - "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "template-names": [ - "base-config-template", - "licence-template" - ], - "action-name": { - "get_input": "action-name" - }, - "template-name": { - "get_input": "template_name" - }, - "template-version": { - "get_input": "template_version" - }, - "resource-type": "vnf-type", - "request-id": { - "get_input": "request-id" - }, - "resource-id": { - "get_input": "hostname" - } - }, - "outputs": { - "resource-assignment-params": { "get_attribute" : ["SELF", "params"] }, - "status": "Success" - } - } - } - } - }, - "type": "component-resource-assignment" - }, - "resource-assignment-action": { - "properties": { - "mode": "sync", - "version": { - "get_input": "template_version" - }, - "is-start-flow": false - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment-ra-component", - "relationship": "tosca.relationships.DependsOn" - } - }, - "capabilities": { - "dg-node": {} - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": [] - } - } - } - } - }, - "type": "dg-resource-assignment" - } - }, - "workflows": { - "activate-process": { - "steps": { - "call-resource-assignment": { - "description": "Invoke Resource Assignment Component", - "target": "resource-assignment", - "activities": [ - { - "call_operation": "ResourceAssignmentNode.process" - } - ], - "on_success": [ - "download-baseconfig" - ] - }, - "download-baseconfig": { - "description": "Call Download Base Config Component", - "target": "activate-netconf", - "activities": [ - { - "call_operation": "NetconfTransactionNode.process" - } - ], - "on_success": [ - "download-licence" - ] - }, - "download-licence": { - "description": "Call Download Licence Component", - "target": "activate-netconf", - "activities": [ - { - "call_operation": "NetconfTransactionNode.process" - } - ] - } - } - } - } - }, - "artifact_types": { - "artifact-template-velocity": { - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-mapping-resource": { - "description": " Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-kotlin": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "kt" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-python": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-bpmn-camunda": { - "description": " Camunda BPM File", - "version": "1.0.0", - "file_ext": [ - "bpmn" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-component-jar": { - "description": "Component Jar", - "version": "1.0.0", - "file_ext": [ - "jar" - ], - "derived_from": "tosca.artifacts.Implementation" - } - }, - "node_types": { - "dg-resource-assignment": { - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Action Name of the process", - "required": true, - "type": "string" - }, - "template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "template-version": { - "description": "Service Template Version.", - "required": true, - "type": "string" - }, - "resource-type": { - "description": "Request type.", - "required": true, - "type": "string" - }, - "template-names": { - "description": "Name of the artifact Node Templates, to get the template Content.", - "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": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "tosca.nodes.DG": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.component.Python": { - "description": "This is Resource Assignment Python Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - } - }, - "data_types": { - "datatype-resource-assignment": { - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "status": { - "required": false, - "type": "string" - }, - "message": { - "required": false, - "type": "string" - }, - "updated-date": { - "required": false, - "type": "string" - }, - "updated-by": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-property": { - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json b/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json deleted file mode 100644 index 6abfb51bd..000000000 --- a/components/core/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "assignments": "Sample Assignments" -} \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn b/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn deleted file mode 100644 index 5e94c0f8e..000000000 --- a/components/core/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn +++ /dev/null @@ -1,66 +0,0 @@ - - - - - SequenceFlow_0l0dq58 - - - SequenceFlow_1ay0k6p - - - - - - - - - - SequenceFlow_0l0dq58 - SequenceFlow_1ay0k6p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py deleted file mode 100644 index eb198c79a..000000000 --- a/components/core/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py +++ /dev/null @@ -1,8 +0,0 @@ -from com.brvith.orchestrator.core.interfaces import ComponentNode - -class SamplePythonComponentNode(ComponentNode): - def prepare(self, context, componentContext): - return None - - def prepare(self, context, componentContext): - return None \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/Scripts/__init__.py b/components/core/load/blueprints/baseconfiguration/Scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta deleted file mode 100644 index fb38c1594..000000000 --- a/components/core/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta +++ /dev/null @@ -1,8 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: Brinda Santh M -Entry-Definitions: Definitions/activation-blueprint.json -Template-Tags: Brinda Santh, activation-blueprint - -Name: Plans/ActivateProcess.bpmn -Content-Type: application/vnd.oasis.bpmn diff --git a/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl b/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl deleted file mode 100644 index 026c59176..000000000 --- a/components/core/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl +++ /dev/null @@ -1 +0,0 @@ -This is Sample Velocity Template \ No newline at end of file diff --git a/components/core/load/blueprints/baseconfiguration/__init__.py b/components/core/load/blueprints/baseconfiguration/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json b/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json deleted file mode 100644 index 207fcc415..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Definitions/sample-nodetype.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json b/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json deleted file mode 100644 index cb091da0f..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json +++ /dev/null @@ -1,340 +0,0 @@ -{ - "metadata": { - "template_author": "Brinda Santh", - "template_name": "simple-baseconfig", - "template_version": "1.0.0", - "service-type": "Sample Service", - "release": "1806", - "vnf-type": "VPE" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "vpe-netconf-device": { - "capabilities": { - "netconf": { - "properties": { - "login-key": "sdnc", - "login-account": "sndc-local", - "source": "local", - "target-ip-address": { "get_attribute": ["SELF", "lo0-local-ipv4-address"]}, - "port-number": 22, - "connection-time-out": 30 - } - } - }, - "type": "vnf-netconf-device" - }, - "activate-netconf-component": { - "capabilities": { - "component-node": {} - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vpe-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "org-onap-ccsdk-netconf-adaptor-service-NetconfExecutorNode": { - "operations": { - "process": { - "inputs": { - "action-name": { "get_input" : "action-name" }, - "service-template-name": { "get_input" : "template_name" }, - "service-template-version": { "get_input" : "service-template-version" }, - "resource-type": "vnf-type", - "request-id": { "get_input" : "request-id" }, - "resource-id": { "get_input" : "hostname" }, - "execution-script": "execution-script" - }, - "outputs": { - "response-data": { "get_input" : ["SELF", "netconf-executor-baseconfig.response-data"] }, - "status": { "get_input" : ["SELF", "netconf-executor-baseconfig.status"] } - }, - "implementation" : { - "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py" - } - } - } - } - }, - "type": "component-netconf-executor" - }, - "resource-assignment-ra-component": { - "capabilities": { - "component-node": {} - }, - "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "template-names": [ - "base-config-template", - "licence-template" - ], - "action-name": { "get_input" : "action-name" }, - "service-template-name": { "get_input" : "template_name" }, - "service-template-version": { "get_input" : "service-template-version" }, - "resource-type": "vnf-type", - "request-id": { "get_input" : "request-id" }, - "resource-id": { "get_input" : "hostname" } - }, - "outputs": { - "resource-assignment-params": "success", - "status": "status" - } - } - } - } - }, - "type": "component-resource-assignment" - }, - "resource-assignment-action": { - "properties": { - "mode": "sync", - "version": "LATEST", - "is-start-flow": false - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment-ra-component", - "relationship": "tosca.relationships.DependsOn" - } - }, - "capabilities": { - "dg-node": {} - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": [] - } - } - } - } - }, - "type": "dg-resource-assignment" - }, - "activate-action": { - "properties": { - "mode": "sync", - "version": "LATEST", - "is-start-flow": false - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "activate-netconf-component", - "relationship": "tosca.relationships.DependsOn" - } - }, - "capabilities": { - "dg-node": {}, - "content": { - "properties": { - "type": "json" - } - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ActivateNetconf": { - "inputs": { - "params": [] - } - } - } - } - }, - "type": "dg-activate-netconf" - }, - "base-config-template": { - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "bundle-mac", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "bundle-mac", - "dictionary-source": "db", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "wan-aggregate-ipv4-addresses", - "property": { - "description": "", - "required": true, - "type": "list", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "dt-v4-aggregate" - } - }, - "input-param": false, - "dictionary-name": "wan-aggregate-ipv4-addresses", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "oam-network-role", - "oam-v4-ip-type ", - "oam-vm-type" - ], - "version": 0 - }, - { - "name": "hostname", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "hostname", - "dictionary-source": "input", - "version": 0, - "input-param": false - }, - { - "name": "service", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "service", - "dictionary-source": "input", - "version": 0, - "input-param": false - }, - { - "name": "service-instance-id", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "version": 0, - "input-param": false - } - ] - } - } - }, - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "type": "artifact-config-template" - }, - "licence-template": { - "capabilities": { - "content": { - "properties": { - "content": "db://licence-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "licenses", - "property": { - "description": "", - "required": true, - "type": "list", - "status": "", - "constraints": [ - {} - ], - "entry_schema": { - "type": "dt-license-key" - } - }, - "input-param": false, - "dictionary-name": "licenses", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id" - ], - "version": 0 - }, - { - "name": "service-instance-id", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "version": 0, - "input-param": false - } - ] - } - } - }, - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "type": "artifact-config-template" - } - } - }, - "node_types": { - }, - "data_types": { - } -} \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json b/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json deleted file mode 100644 index 6abfb51bd..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Mappings/baseconfig-mapping.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "assignments": "Sample Assignments" -} \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn b/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn deleted file mode 100644 index 5e94c0f8e..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Plans/ActivateProcess.bpmn +++ /dev/null @@ -1,66 +0,0 @@ - - - - - SequenceFlow_0l0dq58 - - - SequenceFlow_1ay0k6p - - - - - - - - - - SequenceFlow_0l0dq58 - SequenceFlow_1ay0k6p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py b/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py deleted file mode 100644 index eb198c79a..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Scripts/SamplePythonComponentNode.py +++ /dev/null @@ -1,8 +0,0 @@ -from com.brvith.orchestrator.core.interfaces import ComponentNode - -class SamplePythonComponentNode(ComponentNode): - def prepare(self, context, componentContext): - return None - - def prepare(self, context, componentContext): - return None \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py b/components/core/load/blueprints/simple-baseconfig/Scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta b/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta deleted file mode 100644 index d7ae5e8a2..000000000 --- a/components/core/load/blueprints/simple-baseconfig/TOSCA-Metadata/TOSCA.meta +++ /dev/null @@ -1,8 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: Brinda Santh M -Entry-Definitions: Definitions/simple-baseconfig.json -Template-Tags: vrr-test, Brinda Santh - -Name: Plans/ActivateProcess.bpmn -Content-Type: application/vnd.oasis.bpmn diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl deleted file mode 100644 index 92dba1024..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Templates/base-config-template.vtl +++ /dev/null @@ -1,40 +0,0 @@ - - - - ${group-name} - - - <*> - - - - - - 224.0.1.40/32 - - - 224.0.1.39/32 - - - 224.0.0.0/4 - - - - - - - - - - <*> - - 1000 - - - - - - - - - \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl deleted file mode 100644 index 026c59176..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Templates/baseconfig-template.vtl +++ /dev/null @@ -1 +0,0 @@ -This is Sample Velocity Template \ No newline at end of file diff --git a/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl b/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl deleted file mode 100644 index 626974f27..000000000 --- a/components/core/load/blueprints/simple-baseconfig/Templates/licence-template.vtl +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/components/core/load/blueprints/simple-baseconfig/__init__.py b/components/core/load/blueprints/simple-baseconfig/__init__.py deleted file mode 100644 index e69de29bb..000000000 -- cgit 1.2.3-korg From cfd7f8b587045758a64ed36581e6e37083fb158c Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 12 Nov 2018 13:49:04 -0500 Subject: Controller Blueprints Component Core Define blueprint component or function Interface and Execution data.. Change-Id: I818096a65b750a0723dc14064a18d1b8b47fbaa1 Issue-ID: CCSDK-671 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintConstants.kt | 8 ++--- .../core/interfaces/BlueprintFunctionNode.kt | 37 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 2590d6dc3..84d2befc5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -143,15 +143,15 @@ object BluePrintConstants { const val METADATA_TEMPLATE_VERSION = "template_version" const val METADATA_TEMPLATE_AUTHOR = "template_author" const val METADATA_TEMPLATE_TAGS = "template_tags" + const val METADATA_WORKFLOW_NAME = "workflow_name" - const val PAYLOAD_CONTENT = "payload-content" const val PAYLOAD_DATA = "payload-data" - const val SELECTOR = "selector" + const val PROPERTY_CURRENT_STEP = "current-step" + const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" const val PROPERTY_CURRENT_INTERFACE = "current-interface" const val PROPERTY_CURRENT_OPERATION = "current-operation" const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" - - const val PROPERTY_ACTION_NAME = "action" + const val PROPERTY_EXECUTION_REQUEST = "execution-request" const val OPERATION_PROCESS = "process" const val OPERATION_PREPARE = "prepare" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt new file mode 100644 index 000000000..6add70e64 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import java.util.function.Function + + +interface BlueprintFunctionNode : Function { + + @Throws(BluePrintProcessorException::class) + fun prepareRequest(executionRequest: T): T + + @Throws(BluePrintProcessorException::class) + fun process(executionRequest: T) + + @Throws(BluePrintProcessorException::class) + fun recover(runtimeException: RuntimeException, executionRequest: T) + + @Throws(BluePrintProcessorException::class) + fun prepareResponse(): R + +} \ No newline at end of file -- cgit 1.2.3-korg From f4fb7a6f016fbe0bd06525b05eb26a365be7c6ba Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 12 Nov 2018 15:08:40 -0500 Subject: Controller Blueprints Microservice Add blueprint multiple import file capability. Change-Id: If57aecb08447252b0e84a7e55b081e682d6a0bbd Issue-ID: CCSDK-681 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/service/BluePrintImportService.kt | 94 +++++++ .../core/service/BluePrintValidatorService.kt | 10 +- .../core/utils/BluePrintMetadataUtils.kt | 9 +- .../core/utils/ServiceTemplateUtils.kt | 66 +++++ .../Definitions/activation-blueprint.json | 273 +++------------------ .../baseconfiguration/Definitions/types.json | 210 ++++++++++++++++ 6 files changed, 419 insertions(+), 243 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt new file mode 100644 index 000000000..fce06f3f5 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt @@ -0,0 +1,94 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import java.io.File +import java.net.URL +import java.net.URLDecoder +import java.nio.charset.Charset + +class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { + + private val log: Logger = LoggerFactory.getLogger(this::class.toString()) + val PARENT_SERVICE_TEMPLATE: String = "parent" + + var importServiceTemplateMap: MutableMap = hashMapOf() + + + fun getImportResolvedServiceTemplate(): ServiceTemplate { + // Populate Imported Service Templates + traverseSchema(PARENT_SERVICE_TEMPLATE, parentServiceTemplate) + + importServiceTemplateMap.forEach { key, serviceTemplate -> + ServiceTemplateUtils.merge(parentServiceTemplate, serviceTemplate) + log.debug("merged service template $key") + } + return parentServiceTemplate + } + + private fun traverseSchema(key: String, serviceTemplate: ServiceTemplate) { + if (key != PARENT_SERVICE_TEMPLATE) { + importServiceTemplateMap[key] = serviceTemplate + } + val imports: List? = serviceTemplate.imports + + imports?.let { + serviceTemplate.imports?.forEach { importDefinition -> + val childServiceTemplate = resolveImportDefinition(importDefinition) + val keyName: String = importDefinition.file + traverseSchema(keyName, childServiceTemplate) + } + } + } + + private fun resolveImportDefinition(importDefinition: ImportDefinition): ServiceTemplate { + var serviceTemplate: ServiceTemplate? = null + val file: String = importDefinition.file + val decodedSystemId: String = URLDecoder.decode(file, Charset.defaultCharset().toString()) + log.trace("file ({}), decodedSystemId ({}) ", file, decodedSystemId) + try { + if (decodedSystemId.startsWith("http", true) + || decodedSystemId.startsWith("https", true)) { + val givenUrl: String = URL(decodedSystemId).toString() + val systemUrl: String = File(".").toURI().toURL().toString() + log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl) + if (givenUrl.startsWith(systemUrl)) { + + } + } else { + if (!decodedSystemId.startsWith("/")) { + importDefinition.file = StringBuilder().append(blueprintBasePath).append(File.separator).append(file).toString() + } + serviceTemplate = ServiceTemplateUtils.getServiceTemplate(importDefinition.file) + } + } catch (e: Exception) { + throw BluePrintException("failed to populate service template for ${importDefinition.file}", e) + } + if (serviceTemplate == null) { + throw BluePrintException("failed to populate service template for : ${importDefinition.file}") + } + return serviceTemplate + } + + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 7ad38332a..178373704 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -17,13 +17,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.* import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import java.io.Serializable @@ -530,7 +530,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BluePrintException(format("Failed to ArtifactType for ArtifactDefinition : {}", artifactDefinitionName)) + ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) } @@ -538,14 +538,14 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class) open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get ArtifactType ({})'s derivedFrom({}) definition ", artifactTypeName, derivedFrom)) + throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") } } @Throws(BluePrintException::class) open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get DataType ({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) + throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index 43d55feac..320c306c3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -25,6 +25,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintImportService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService import java.io.File @@ -99,9 +100,9 @@ object BluePrintMetadataUtils { fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) - // TODO ("Fix for Multiple Service Template file definitions") -// val schemaImportResolverUtils = BluePrintResolverService(rootServiceTemplate, basePath) -// val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() - return BluePrintContext(rootServiceTemplate) + // Recursively Import Template files + val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath) + val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() + return BluePrintContext(completeServiceTemplate) } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt index 0d739357c..0249e20b1 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils import org.apache.commons.io.FileUtils import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate import java.io.File import java.nio.charset.Charset @@ -40,5 +41,70 @@ object ServiceTemplateUtils { return JacksonUtils.readValue(content) } + fun merge(parentServiceTemplate: ServiceTemplate, toMerge: ServiceTemplate, removeImports: Boolean? = true): ServiceTemplate { + if (removeImports!!) { + parentServiceTemplate.imports = null + toMerge.imports = null + } + + toMerge.metadata?.let { + parentServiceTemplate.metadata = parentServiceTemplate.metadata ?: hashMapOf() + parentServiceTemplate.metadata?.putAll(toMerge.metadata as MutableMap) + } + + toMerge.dslDefinitions?.let { + parentServiceTemplate.dslDefinitions = parentServiceTemplate.dslDefinitions ?: hashMapOf() + parentServiceTemplate.dslDefinitions?.putAll(toMerge.dslDefinitions as MutableMap) + } + + toMerge.dataTypes?.let { + parentServiceTemplate.dataTypes = parentServiceTemplate.dataTypes ?: hashMapOf() + parentServiceTemplate.dataTypes?.putAll(toMerge.dataTypes as MutableMap) + } + + toMerge.nodeTypes?.let { + parentServiceTemplate.nodeTypes = parentServiceTemplate.nodeTypes ?: hashMapOf() + parentServiceTemplate.nodeTypes?.putAll(toMerge.nodeTypes as MutableMap) + } + + toMerge.artifactTypes?.let { + parentServiceTemplate.artifactTypes = parentServiceTemplate.artifactTypes ?: hashMapOf() + parentServiceTemplate.artifactTypes?.putAll(toMerge.artifactTypes as MutableMap) + } + + toMerge.repositories?.let { + parentServiceTemplate.repositories = parentServiceTemplate.repositories ?: hashMapOf() + parentServiceTemplate.repositories?.putAll(toMerge.repositories as MutableMap) + } + + parentServiceTemplate.topologyTemplate = parentServiceTemplate.topologyTemplate ?: TopologyTemplate() + + toMerge.topologyTemplate?.inputs?.let { + parentServiceTemplate.topologyTemplate?.inputs = parentServiceTemplate.topologyTemplate?.inputs ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.inputs?.putAll(parentServiceTemplate.topologyTemplate?.inputs as MutableMap) + } + + toMerge.topologyTemplate?.nodeTemplates?.let { + parentServiceTemplate.topologyTemplate?.nodeTemplates = parentServiceTemplate.topologyTemplate?.nodeTemplates ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.nodeTemplates?.putAll(parentServiceTemplate.topologyTemplate?.nodeTemplates as MutableMap) + } + + toMerge.topologyTemplate?.relationshipTemplates?.let { + parentServiceTemplate.topologyTemplate?.relationshipTemplates = parentServiceTemplate.topologyTemplate?.relationshipTemplates ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.relationshipTemplates?.putAll(parentServiceTemplate.topologyTemplate?.relationshipTemplates as MutableMap) + } + + toMerge.topologyTemplate?.policies?.let { + parentServiceTemplate.topologyTemplate?.policies = parentServiceTemplate.topologyTemplate?.policies ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.policies?.putAll(parentServiceTemplate.topologyTemplate?.policies as MutableMap) + } + + toMerge.topologyTemplate?.workflows?.let { + parentServiceTemplate.topologyTemplate?.workflows = parentServiceTemplate.topologyTemplate?.workflows ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.workflows?.putAll(parentServiceTemplate.topologyTemplate?.workflows as MutableMap) + } + return parentServiceTemplate + } + } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 0137cd2bd..ee02b3a77 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -1,12 +1,17 @@ { "metadata": { "template_author": "Brinda Santh Muthuramalingam", - "author-email": "brindasanth@gmail.com", + "author-email": "brindasanth@in.ibm.com", "user-groups": "ADMIN, OPERATION", "template_name": "baseconfiguration", "template_version": "1.0.0", "template_tags": "brinda, tosca" }, + "imports": [ + { + "file": "Definitions/types.json" + } + ], "topology_template": { "inputs": { "request-id": { @@ -28,7 +33,7 @@ }, "node_templates": { "activate-process": { - "type": "bpmn-activate", + "type": "dg-activate", "properties": { "process-name": { "get_input": "action-name" @@ -42,13 +47,13 @@ "content": { "get_artifact": [ "SELF", - "activate-process" + "dg-activate-process" ] } }, "artifacts": { - "activate-process": { - "type": "artifact-bpmn-camunda", + "dg-activate-process": { + "type": "artifact-directed-graph", "file": "Plans/ActivateProcess.bpmn" } } @@ -144,250 +149,50 @@ } }, "workflows": { - "activate-process": { + "resource-assignment": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, "steps": { "call-resource-assignment": { - "description": "Invoke Resource Assignment Component", + "description": "Resource Assignment Workflow", "target": "resource-assignment", "activities": [ { "call_operation": "ResourceAssignmentNode.process" } - ], - "on_success": [ - "download-baseconfig" - ] - }, - "download-baseconfig": { - "description": "Call Download Base Config Component", - "target": "activate-netconf", - "activities": [ - { - "call_operation": "NetconfTransactionNode.process" - } - ], - "on_success": [ - "download-licence" ] - }, - "download-licence": { - "description": "Call Download Licence Component", - "target": "activate-netconf", + } + } + }, + "activate": { + "steps": { + "call-resource-assignment": { + "description": "Netconf Activation Workflow", + "target": "resource-assignment", "activities": [ { - "call_operation": "NetconfTransactionNode.process" + "call_operation": "ResourceAssignmentNode.process" } ] } } } } - }, - "artifact_types": { - "artifact-template-velocity": { - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-mapping-resource": { - "description": " Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-kotlin": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "kt" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-python": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-bpmn-camunda": { - "description": " Camunda BPM File", - "version": "1.0.0", - "file_ext": [ - "bpmn" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-component-jar": { - "description": "Component Jar", - "version": "1.0.0", - "file_ext": [ - "jar" - ], - "derived_from": "tosca.artifacts.Implementation" - } - }, - "node_types": { - "bpmn-activate": { - "description": "This is BPMN Activate node type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.nodes.DG" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.component.Python": { - "description": "This is Resource Assignment Python Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "template-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "mapping-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "component-resource-assignment-python": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.component.Python" - } - }, - "data_types": { - "sample-property": { - "description": "This is sample data type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.datatypes.Root" - } } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json new file mode 100644 index 000000000..056d5f182 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json @@ -0,0 +1,210 @@ +{ + "artifact_types": { + "artifact-template-velocity": { + "description": " Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-mapping-resource": { + "description": " Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-kotlin": { + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "kt" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-python": { + "description": " Kotlin Script Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-directed-graph": { + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-component-jar": { + "description": "Component Jar", + "version": "1.0.0", + "file_ext": [ + "jar" + ], + "derived_from": "tosca.artifacts.Implementation" + } + }, + "node_types": { + "dg-activate": { + "description": "This is BPMN Activate node type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.nodes.DG" + }, + "tosca.nodes.Component": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.DG": { + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Python": { + "description": "This is Resource Assignment Python Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "template-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "mapping-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-resource-assignment-python": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "DefaultComponentNode": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.component.Python" + } + }, + "data_types": { + "sample-property": { + "description": "This is sample data type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.datatypes.Root" + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From 758fde46420ecf8dd1e8641322deff4ba85c9e6b Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 15 Nov 2018 08:36:28 -0500 Subject: Blueprints Processor Microservice Refactor functon module as seperate module project. Change-Id: I392fc62e6dfb6c5f38f478c00e46460d5084f85c Issue-ID: CCSDK-688 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/parent/pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 7308e9d2a..71310f1e6 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -31,7 +31,8 @@ 2.0.6.RELEASE 5.0.10.RELEASE - 1.3.0 + 1.3.10 + 1.3.0 1.0.1 1.0.0 26.0-jre @@ -234,7 +235,7 @@ kotlin-maven-plugin org.jetbrains.kotlin - ${kotlin.version} + ${kotlin.maven.version} compile -- cgit 1.2.3-korg From 52797e239404c427012a53c1c57e6f7914a88e92 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 15 Nov 2018 13:12:09 -0500 Subject: Blueprints Processor Microservice Implement Resource Resolution Processor Interface definitions. Change-Id: Ic2eb7915d48b9473639494ee9d159003bf56e81e Issue-ID: CCSDK-724 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../resource/dict/ResourceAssignmentProcessor.kt | 43 +++++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt index a6802f677..327d50ac4 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications Copyright © 2017-2018 AT&T Intellectual Property. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,19 +17,41 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.slf4j.LoggerFactory -interface ResourceAssignmentProcessor { +abstract class ResourceAssignmentProcessor : BlueprintFunctionNode { - @Throws(BluePrintProcessorException::class) - fun validate(resourceAssignment: ResourceAssignment, context : MutableMap) + private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java) - @Throws(BluePrintProcessorException::class) - fun process(resourceAssignment: ResourceAssignment, context : MutableMap) + private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null - @Throws(BluePrintProcessorException::class) - fun errorHandle(resourceAssignment: ResourceAssignment, context : MutableMap) + open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { + this.bluePrintRuntimeService = bluePrintRuntimeService + } - @Throws(BluePrintProcessorException::class) - fun reTrigger(resourceAssignment: ResourceAssignment, context : MutableMap) + open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> { + return this.bluePrintRuntimeService!! + } + + override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment { + log.info("prepareRequest...") + return resourceAssignment + } + + override fun prepareResponse(): ResourceAssignment { + log.info("Preparing Response...") + return ResourceAssignment() + } + + override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment { + prepareRequest(executionServiceInput) + process(executionServiceInput) + return prepareResponse() + } + + override abstract fun process(executionRequest: ResourceAssignment) + + override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) } \ No newline at end of file -- cgit 1.2.3-korg From da8a1fdae5ceab75a37ed79edb895f9ac57b6e5d Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 16 Oct 2018 15:57:47 -0400 Subject: Add support for aai node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6c4d70f270d605dd4d49e89580849c9100ec4928 Issue-ID: SDNC-123 Signed-off-by: Alexis de Talhouët --- .../vFW/Templates/base_template.vtl | 21 ++++++++++++++++++ .../vFW/Templates/vFW_vNF_Artifact.vtl | 19 ++++++++++++++++ .../service-blueprint/vFW/Templates/vfw.vtl | 25 +++++++++++++++++++++- .../service-blueprint/vFW/Templates/vpg.vtl | 23 ++++++++++++++++++++ .../service-blueprint/vFW/Templates/vsn.vtl | 23 ++++++++++++++++++++ 5 files changed, 110 insertions(+), 1 deletion(-) diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl index 1f8298c5f..271c50738 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/base_template.vtl @@ -52,5 +52,26 @@ "param-name": "vf_module_name", "param-value": "${vnf-name}_base" } + ], + "capability-data": [ + { + "capability-name": "aai-vf-module-put", + "key-mapping": [ + { + "payload": [ + { + "param-name": "vf-module", + "param-value": "vf-module" + } + ], + "output-key-mapping": [ + { + "resource-name": "aai-vf-module-put", + "resource-value": "${status}" + } + ] + } + ] + } ] } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl index ca09046aa..0faf09ca6 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl @@ -198,6 +198,25 @@ ] } ] + }, + { + "capability-name": "aai-vnf-put", + "key-mapping": [ + { + "payload": [ + { + "param-name": "generic-vnf", + "param-value": "generic-vnf" + } + ], + "output-key-mapping": [ + { + "resource-name": "aai-vnf-put", + "resource-value": "${status}" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl index 06a91d3a1..6864a36fe 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vfw.vtl @@ -18,7 +18,7 @@ }, { "param-name": "vf_module_id", - "param-value": "${vnf-id}" + "param-value": "${vf-module-id}" }, { "param-name": "vf_module_type", @@ -282,6 +282,29 @@ } ] }, + { + "capability-name": "aai-vf-module-put", + "key-mapping": [ + { + "payload": [ + { + "param-name": "vf-module", + "param-value": "vf-module" + }, + { + "param-name": "vnfc", + "param-value": "vnfc" + } + ], + "output-key-mapping": [ + { + "resource-name": "aai-vf-module-put", + "resource-value": "${status}" + } + ] + } + ] + }, { "capability-name": "unresolved-composite-data", "key-mapping": [ diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl index f7e3780a3..2ff6596ee 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vpg.vtl @@ -290,6 +290,29 @@ } ] }, + { + "capability-name": "aai-vf-module-put", + "key-mapping": [ + { + "payload": [ + { + "param-name": "vf-module", + "param-value": "vf-module" + }, + { + "param-name": "vnfc", + "param-value": "vnfc" + } + ], + "output-key-mapping": [ + { + "resource-name": "aai-vf-module-put", + "resource-value": "${status}" + } + ] + } + ] + }, { "capability-name": "unresolved-composite-data", "key-mapping": [ diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl index 727427a63..11fcea9fd 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vsn.vtl @@ -278,6 +278,29 @@ } ] }, + { + "capability-name": "aai-vf-module-put", + "key-mapping": [ + { + "payload": [ + { + "param-name": "vf-module", + "param-value": "vf-module" + }, + { + "param-name": "vnfc", + "param-value": "vnfc" + } + ], + "output-key-mapping": [ + { + "resource-name": "aai-vf-module-put", + "resource-value": "${status}" + } + ] + } + ] + }, { "capability-name": "unresolved-composite-data", "key-mapping": [ -- cgit 1.2.3-korg From 1adb9b5f44376f5602959a3709565ee812f6ddb1 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Fri, 16 Nov 2018 07:58:28 -0500 Subject: Do no prepend "sub" for subnet net id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icc240f30ef9a2f7e9f99345f05897e5d7f9d4c3a Issue-ID: CCSDK-727 Signed-off-by: Alexis de Talhouët --- .../service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl index ca09046aa..ea6a7b885 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Templates/vFW_vNF_Artifact.vtl @@ -30,7 +30,7 @@ }, { "param-name": "onap_private_subnet_id", - "param-value": "${onap_private_net_id}_sub" + "param-value": "${onap_private_subnet_id}" } ], "capability-data": [ -- cgit 1.2.3-korg From 421823b343881c6d1690be8b1082a878764635f2 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 19 Nov 2018 12:48:31 -0500 Subject: Implement Base Jython Executor function. Change-Id: I3fb066a021de4a7b3aa1fce7f6c191bc3944fb51 Issue-ID: CCSDK-696 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/service/BluePrintRuntimeService.kt | 16 ++++++++++----- .../Definitions/activation-blueprint.json | 20 ++++++++++++++++++- .../Scripts/SamplePythonComponentNode.py | 14 ++++++++----- .../scripts/python/ccsdk_blueprints/__init__.py | 0 .../abstract_blueprint_function.py | 11 +++++++++++ .../python/ccsdk_blueprints/blueprint_constants.py | 23 ++++++++++++++++++++++ .../ccsdk_blueprints/blueprint_runtime_service.py | 13 ++++++++++++ .../ccsdk_blueprints/sample_blueprint_component.py | 12 +++++++++++ 8 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 components/scripts/python/ccsdk_blueprints/__init__.py create mode 100644 components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py create mode 100644 components/scripts/python/ccsdk_blueprints/blueprint_constants.py create mode 100644 components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py create mode 100644 components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index f84b2c569..9da5b0ee4 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -59,6 +59,8 @@ interface BluePrintRuntimeService { fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String + fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition + fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) @@ -269,15 +271,19 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return propertyAssignmentValue } - override fun resolveNodeTemplateArtifact(nodeTemplateName: String, - artifactName: String): String { + override fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String { + val artifactDefinition: ArtifactDefinition = resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName) + val propertyAssignmentExpression = PropertyAssignmentService(this) + return propertyAssignmentExpression.artifactContent(artifactDefinition) + } + + override fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition { val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - val artifactDefinition: ArtifactDefinition = nodeTemplate.artifacts?.get(artifactName) + return nodeTemplate.artifacts?.get(artifactName) ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template" , artifactName)) - val propertyAssignmentExpression = PropertyAssignmentService(this) - return propertyAssignmentExpression.artifactContent(artifactDefinition) + } diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index ee02b3a77..e067a7dfd 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -143,7 +143,7 @@ "artifacts": { "component-script": { "type": "artifact-script-python", - "file": "Scripts/baseconfig-template.vtl" + "file": "Scripts/SamplePythonComponentNode.py" } } } @@ -181,6 +181,24 @@ } }, "activate": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, "steps": { "call-resource-assignment": { "description": "Netconf Activation Workflow", diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py index fc5151338..0a583dc57 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py @@ -1,8 +1,12 @@ -from com.brvith.orchestrator.core.interfaces import ComponentNode +from abstract_blueprint_function import AbstractPythonComponentFunction +from blueprint_constants import * -class SamplePythonComponentNode(ComponentNode): - def prepare(self, context, componentContext): +class SamplePythonComponentNode(AbstractPythonComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None - def prepare(self, context, componentContext): - return None \ No newline at end of file + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/scripts/python/ccsdk_blueprints/__init__.py b/components/scripts/python/ccsdk_blueprints/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py new file mode 100644 index 000000000..0ddab16e7 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py @@ -0,0 +1,11 @@ +from org.onap.ccsdk.apps.blueprintsprocessor.services.execution import AbstractComponentFunction + +class AbstractPythonComponentFunction(AbstractComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + return None diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py new file mode 100644 index 000000000..2ec95f312 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py @@ -0,0 +1,23 @@ + +PROPERTY_BLUEPRINT_PROCESS_ID= "blueprint-process-id" +PROPERTY_BLUEPRINT_BASE_PATH= "blueprint-basePath" +PROPERTY_BLUEPRINT_RUNTIME= "blueprint-runtime" +PROPERTY_BLUEPRINT_INPUTS_DATA= "blueprint-inputs-data" +PROPERTY_BLUEPRINT_CONTEXT= "blueprint-context" +PROPERTY_BLUEPRINT_NAME= "template_name" +PROPERTY_BLUEPRINT_VERSION= "template_version" + +METADATA_USER_GROUPS = "user-groups" +METADATA_TEMPLATE_NAME = "template_name" +METADATA_TEMPLATE_VERSION = "template_version" +METADATA_TEMPLATE_AUTHOR = "template_author" +METADATA_TEMPLATE_TAGS = "template_tags" +METADATA_WORKFLOW_NAME = "workflow_name" + +PAYLOAD_DATA = "payload-data" +PROPERTY_CURRENT_STEP = "current-step" +PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" +PROPERTY_CURRENT_INTERFACE = "current-interface" +PROPERTY_CURRENT_OPERATION = "current-operation" +PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" +PROPERTY_EXECUTION_REQUEST = "execution-request" diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py new file mode 100644 index 000000000..022b47244 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py @@ -0,0 +1,13 @@ +class BluePrintRuntimeService: + + def __init__(self, bps): + self.bps = bps + + def resolveNodeTemplateArtifact(self, node_template_name, artifact_name): + return self.bps.resolveNodeTemplateArtifact(node_template_name, artifact_name) + + def setNodeTemplateAttributeValue(self, nodeTemplateName, attributeName, value): + return self.bps.setNodeTemplateAttributeValue(nodeTemplateName, attributeName, value) + + def setNodeTemplatePropertyValue(self, nodeTemplateName, propertyName, value): + return self.bps.setNodeTemplatePropertyValue(nodeTemplateName, propertyName, value) diff --git a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py new file mode 100644 index 000000000..62665dc8f --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py @@ -0,0 +1,12 @@ +from abstract_blueprint_function import AbstractPythonComponentFunction +from blueprint_constants import * + +class SampleBlueprintComponent(AbstractPythonComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None -- cgit 1.2.3-korg From 7af6a923ef993bed14d0fc5f769c3766c94b88b3 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 20 Nov 2018 12:20:30 -0500 Subject: Add Jython Component model and validation logics. Change-Id: I2bdba0016a41e16198d60be68dff68d1ce7ad13a Issue-ID: CCSDK-696 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../node_type/component-resource-assignment.json | 2 +- .../core/BluePrintConstants.kt | 1 + .../controllerblueprints/core/BluePrintTypes.kt | 1 + .../core/service/BluePrintRuntimeServiceTest.kt | 8 +- .../vFW/Definitions/vFW_spinup.json | 4 +- .../Definitions/activation-blueprint.json | 42 ++++- .../Definitions/artifact-types.json | 45 +++++ .../baseconfiguration/Definitions/data-types.json | 24 +++ .../baseconfiguration/Definitions/node-types.json | 130 +++++++++++++ .../baseconfiguration/Definitions/types.json | 210 --------------------- .../artifact_type/artifact-script-jython.json | 8 + .../artifact_type/artifact-script-python.json | 2 +- .../node_type/component-config-generator.json | 2 +- .../node_type/component-jython-executor.json | 40 ++++ .../node_type/component-netconf-executor.json | 4 +- .../node_type/component-resource-assignment.json | 2 +- .../node_type/tosca.nodes.component.Jython.json | 5 + 17 files changed, 302 insertions(+), 228 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json index 1389bc328..2a9035619 100644 --- a/components/core/load/model_type/node_type/component-resource-assignment.json +++ b/components/core/load/model_type/node_type/component-resource-assignment.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "ResourceAssignmentComponent": { "operations": { "process": { "inputs": { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 84d2befc5..a41284187 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -93,6 +93,7 @@ object BluePrintConstants { const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" + const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index a971898d3..64797ed40 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -37,6 +37,7 @@ object BluePrintTypes { BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE, BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT, BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON, BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT ) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 19c6c2f9d..2f519802d 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -69,7 +69,7 @@ class BluePrintRuntimeServiceTest { "data/default-context.json", executionContext) val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment", - "DefaultComponentNode", "process") + "ResourceAssignmentComponent", "process") assertNotNull(inContext, "Failed to populate interface input property values") assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") @@ -86,14 +86,14 @@ class BluePrintRuntimeServiceTest { bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance()) bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", - "DefaultComponentNode", "process") + "ResourceAssignmentComponent", "process") val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "DefaultComponentNode", "process", "status") + "ResourceAssignmentComponent", "process", "status") assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status") val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "DefaultComponentNode", "process", "resource-assignment-params") + "ResourceAssignmentComponent", "process", "resource-assignment-params") assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params") } diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json index d5416c0ea..1137c1d58 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json @@ -40,7 +40,7 @@ "resource-assignment-ra-component": { "type": "component-resource-assignment", "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "ResourceAssignmentComponent": { "operations": { "process": { "inputs": { @@ -3337,7 +3337,7 @@ } }, "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "ResourceAssignmentComponent": { "operations": { "process": { "inputs": { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index e067a7dfd..269fd0cf0 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -9,7 +9,13 @@ }, "imports": [ { - "file": "Definitions/types.json" + "file": "Definitions/data-types.json" + }, + { + "file": "Definitions/node-types.json" + }, + { + "file": "Definitions/artifact-types.json" } ], "topology_template": { @@ -64,7 +70,7 @@ "request-id": "1234" }, "interfaces": { - "DefaultComponentNode": { + "ResourceAssignmentComponent": { "operations": { "process": { "inputs": { @@ -121,7 +127,7 @@ "request-id": "1234" }, "interfaces": { - "DefaultComponentNode": { + "ResourceAssignmentComponent": { "operations": { "process": { "implementation": { @@ -142,7 +148,31 @@ }, "artifacts": { "component-script": { - "type": "artifact-script-python", + "type": "artifact-script-jython", + "file": "Scripts/SamplePythonComponentNode.py" + } + } + }, + "activate-jython": { + "type": "component-jython-executor", + "interfaces": { + "JythonExecutorComponent": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "outputs": { + "response-data": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-jython", "file": "Scripts/SamplePythonComponentNode.py" } } @@ -174,7 +204,7 @@ "target": "resource-assignment", "activities": [ { - "call_operation": "ResourceAssignmentNode.process" + "call_operation": "ResourceAssignmentComponent.process" } ] } @@ -205,7 +235,7 @@ "target": "resource-assignment", "activities": [ { - "call_operation": "ResourceAssignmentNode.process" + "call_operation": "ResourceAssignmentComponent.process" } ] } diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json new file mode 100644 index 000000000..d741d151e --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json @@ -0,0 +1,45 @@ +{ + "artifact_types": { + "artifact-template-velocity": { + "description": "Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-mapping-resource": { + "description": "Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-jython": { + "description": "Jython Script File", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-directed-graph": { + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-component-jar": { + "description": "Component Jar", + "version": "1.0.0", + "file_ext": [ + "jar" + ], + "derived_from": "tosca.artifacts.Implementation" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json new file mode 100644 index 000000000..6ca1ffde2 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json @@ -0,0 +1,24 @@ +{ + "data_types": { + "sample-property": { + "description": "This is sample data type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.datatypes.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json new file mode 100644 index 000000000..139ebb1a3 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json @@ -0,0 +1,130 @@ +{ + "node_types": { + "dg-activate": { + "description": "This is BPMN Activate node type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.nodes.DG" + }, + "tosca.nodes.Component": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.DG": { + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Jython": { + "description": "This is Resource Assignment Jython Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "ResourceAssignmentComponent": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "template-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "mapping-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-jython-executor": { + "description": "This is Jython Execution Component.", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "JythonExecutorComponent": { + "operations": { + "process": { + "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.Jython" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json deleted file mode 100644 index 056d5f182..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/types.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "artifact_types": { - "artifact-template-velocity": { - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-mapping-resource": { - "description": " Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-kotlin": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "kt" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-python": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-directed-graph": { - "description": "Directed Graph File", - "version": "1.0.0", - "file_ext": [ - "json", - "xml" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-component-jar": { - "description": "Component Jar", - "version": "1.0.0", - "file_ext": [ - "jar" - ], - "derived_from": "tosca.artifacts.Implementation" - } - }, - "node_types": { - "dg-activate": { - "description": "This is BPMN Activate node type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.nodes.DG" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.component.Python": { - "description": "This is Resource Assignment Python Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "template-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "mapping-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "component-resource-assignment-python": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.component.Python" - } - }, - "data_types": { - "sample-property": { - "description": "This is sample data type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json new file mode 100644 index 000000000..969662ab7 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-jython.json @@ -0,0 +1,8 @@ +{ + "description": "Jython Script File", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json index b48d2b628..b42f7156a 100644 --- a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-python.json @@ -1,5 +1,5 @@ { - "description": " Kotlin Script Template used for Configuration", + "description": "Python Script file", "version": "1.0.0", "file_ext": [ "py" diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json b/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json index 764f9e890..ba142600f 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-config-generator.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": { + "ConfigGeneratorComponent": { "operations": { "process": { "inputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json new file mode 100644 index 000000000..4959a9dd1 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json @@ -0,0 +1,40 @@ +{ + "description": "This is Jython Execution Component.", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "JythonExecutorComponent": { + "operations": { + "process": { + "inputs": { + "instance-dependencies": { + "required": true, + "description": "Instance Names to Inject to Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "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.Jython" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index 240caf3fc..7e1d81343 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -14,7 +14,7 @@ } }, "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { + "NetconfExecutorComponent": { "operations": { "process": { "inputs": { @@ -75,5 +75,5 @@ } } }, - "derived_from": "tosca.nodes.Component" + "derived_from": "tosca.nodes.component.Jython" } \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json index d424a8e43..a29a875cb 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { + "ResourceAssignmentComponent": { "operations": { "process": { "inputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json new file mode 100644 index 000000000..8e194f6dd --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Jython.json @@ -0,0 +1,5 @@ +{ + "description": "This is Jython Component", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file -- cgit 1.2.3-korg From 6af718b8552503a7dfce2e4e1f61a12eb0837921 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 20 Nov 2018 15:55:29 -0500 Subject: Add directed graph reterive and execution service. Change-Id: Ia31af4d14e38e6229166cda0f39fa090764ef1cb Issue-ID: CCSDK-672 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/service/BluePrintContext.kt | 16 ++++++++-- .../core/service/BluePrintRuntimeService.kt | 28 ++++++++++++++++-- .../Definitions/activation-blueprint.json | 6 ++-- .../Plans/CONFIG_ActivateNetconf_1.0.0.xml | 34 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 4764479ad..f73fb727d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -57,10 +57,15 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)") } - fun workflowStepNodeTemplate(workFlowName: String, stepName: String): NodeTemplate { - val nodeTemplateName = workflowStepByName(workFlowName, stepName).target + fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String { + return workflowStepByName(workFlowName, stepName).target ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)") - return nodeTemplateByName(nodeTemplateName) + } + + fun workflowFirstStepNodeTemplate(workFlowName: String): String { + val firstStepName = workflowByName(workFlowName).steps?.keys?.first() + ?: throw BluePrintException("could't get first step for workflow($workFlowName)") + return workflowStepNodeTemplate(workFlowName, firstStepName) } fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String { @@ -156,6 +161,11 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)") } + fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition { + return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)") + } + fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment { return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first() ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment") diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 9da5b0ee4..84ba10473 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -48,6 +48,14 @@ interface BluePrintRuntimeService { fun cleanRuntime() + fun getAsString(key: String): String? + + fun getAsBoolean(key: String): Boolean? + + fun getAsInt(key: String): Int? + + fun getAsDouble(key: String): Double? + /* Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing */ @@ -139,9 +147,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return get(key) } + override fun getAsString(key: String): String? { + return get(key).asText() + } + + override fun getAsBoolean(key: String): Boolean? { + return get(key).asBoolean() + } + + override fun getAsInt(key: String): Int? { + return get(key).asInt() + } + + override fun getAsDouble(key: String): Double? { + return get(key).asDouble() + } + /* - Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing - */ + Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing + */ override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) val propertyAssignmentValue: MutableMap = hashMapOf() diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 269fd0cf0..9d1172fc5 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -60,7 +60,7 @@ "artifacts": { "dg-activate-process": { "type": "artifact-directed-graph", - "file": "Plans/ActivateProcess.bpmn" + "file": "Plans/CONFIG_ActivateNetconf_1.0.0.xml" } } }, @@ -230,9 +230,9 @@ } }, "steps": { - "call-resource-assignment": { + "activate-process": { "description": "Netconf Activation Workflow", - "target": "resource-assignment", + "target": "activate-process", "activities": [ { "call_operation": "ResourceAssignmentComponent.process" diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml new file mode 100644 index 000000000..d256bbd23 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From 16841978f6c50618776c1b12ff1e9a0713c456a6 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sat, 24 Nov 2018 14:25:26 -0500 Subject: Add coroutines and GRPC maven dependencies. Change-Id: I5b9ebc7c75a99ca36d09c233cf9e217c8aec38a2 Issue-ID: CCSDK-744 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/parent/pom.xml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 71310f1e6..39f2d1015 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -32,8 +32,9 @@ 2.0.6.RELEASE 5.0.10.RELEASE 1.3.10 - 1.3.0 + 1.3.10 1.0.1 + 1.16.1 1.0.0 26.0-jre 2.9.2 @@ -108,8 +109,8 @@ ${kotlin.version} - org.jetbrains.kotlin - kotlinx-couroutines-core + org.jetbrains.kotlinx + kotlinx-coroutines-core ${kotlin.couroutines.version} @@ -128,6 +129,23 @@ ${kotlin.version} + + + io.grpc + grpc-netty + ${grpc.version} + + + io.grpc + grpc-protobuf + ${grpc.version} + + + io.grpc + grpc-stub + ${grpc.version} + + @@ -210,6 +228,10 @@ org.jetbrains.kotlin kotlin-stdlib-jdk8 + + org.jetbrains.kotlinx + kotlinx-coroutines-core + com.fasterxml.jackson.module jackson-module-kotlin -- cgit 1.2.3-korg From 304b509a1c90de0bfcbc7fee36cfe373c1cc463e Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 26 Nov 2018 14:51:58 -0500 Subject: Add Resource Dictionary Artifact Type. Change-Id: I40c4cb47cb54c460b198c9d700ccd84b578da0a4 Issue-ID: CCSDK-747 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../baseconfiguration/Mappings/resources-dictionary.json | 3 +++ .../starter-type/artifact_type/artifact-dictionary-resource.json | 8 ++++++++ .../starter-type/artifact_type/artifact-mapping-resource.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json new file mode 100644 index 000000000..0e0dcd235 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json new file mode 100644 index 000000000..ccc15985f --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-dictionary-resource.json @@ -0,0 +1,8 @@ +{ + "description": "Resource Dictionary File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json index 0a3261b09..ea3aa232b 100644 --- a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-mapping-resource.json @@ -1,5 +1,5 @@ { - "description": " Velocity Template Resource Mapping File used along with Configuration template", + "description": "Resource Mapping File used along with Configuration template", "version": "1.0.0", "file_ext": [ "json" -- cgit 1.2.3-korg From a09c74a9c080bb5ed8b769c30617025eeb4ca3a4 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 10:03:04 -0500 Subject: Add Blueprint Validation Interfaces. Change-Id: Idbda09fc8be7878814e782990ab8d6e9a5d8b047 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintValidationError.kt | 29 +++++ .../core/interfaces/BlueprintValidator.kt | 129 +++++++++++++++++++++ .../core/service/BluePrintContext.kt | 5 + 3 files changed, 163 insertions(+) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt new file mode 100644 index 000000000..3ec0691f4 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt @@ -0,0 +1,29 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +class BluePrintValidationError { + var errors: MutableList = arrayListOf() + + fun addError(type: String, name: String, error: String) { + this.errors.add("$type : $name : $error") + } + + fun addError(error: String) { + this.errors.add(error) + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt new file mode 100644 index 000000000..9407cfa11 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -0,0 +1,129 @@ +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + + +interface BluePrintValidator { + + fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: T) + +} + + +interface BluePrintServiceTemplateValidator : BluePrintValidator + +interface BluePrintTopologyTemplateValidator : BluePrintValidator + +interface BluePrintArtifactTypeValidator : BluePrintValidator + +interface BluePrintDataTypeValidator : BluePrintValidator + +interface BluePrintNodeTypeValidator : BluePrintValidator + +interface BluePrintNodeTemplateValidator : BluePrintValidator + +interface BluePrintWorkflowValidator : BluePrintValidator + +interface BluePrintPropertyDefinitionValidator : BluePrintValidator + +interface BluePrintAttributeDefinitionValidator : BluePrintValidator + +/** + * Blueprint Validation Interface. + */ +interface BluePrintValidatorService { + + @Throws(BluePrintException::class) + fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap) +} + + +interface BluePrintTypeValidatorService { + + fun getServiceTemplateValidators(): List + + fun getDataTypeValidators(): List + + fun getArtifactTypeValidators(): List + + fun getNodeTypeValidators(): List + + fun getTopologyTemplateValidators(): List + + fun getNodeTemplateValidators(): List + + fun getWorkflowValidators(): List + + fun getPropertyDefinitionValidators(): List + + fun getAttributeDefinitionValidators(): List + + fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) { + val validators = getServiceTemplateValidators() + doValidation(bluePrintContext, error, name, serviceTemplate, validators) + } + + fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) { + val validators = getArtifactTypeValidators() + doValidation(bluePrintContext, error, name, artifactType, validators) + } + + fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) { + val validators = getDataTypeValidators() + doValidation(bluePrintContext, error, name, dataType, validators) + } + + fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeType: NodeType) { + val validators = getNodeTypeValidators() + doValidation(bluePrintContext, error, name, nodeType, validators) + } + + fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) { + val validators = getTopologyTemplateValidators() + doValidation(bluePrintContext, error, name, topologyTemplate, validators) + } + + fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeTemplate: NodeTemplate) { + val validators = getNodeTemplateValidators() + doValidation(bluePrintContext, error, name, nodeTemplate, validators) + } + + fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, workflow: Workflow) { + val validators = getWorkflowValidators() + doValidation(bluePrintContext, error, name, workflow, validators) + } + + fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, properties: MutableMap) { + properties.forEach { propertyName, propertyDefinition -> + validatePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition) + } + } + + fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) { + val validators = getPropertyDefinitionValidators() + doValidation(bluePrintContext, error, name, propertyDefinition, validators) + } + + fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, attributes: MutableMap) { + attributes.forEach { attributeName, attributeDefinition -> + validateAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition) + } + } + + fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, attributeDefinition: AttributeDefinition) { + val validators = getAttributeDefinitionValidators() + doValidation(bluePrintContext, error, name, attributeDefinition, validators) + } + + private fun doValidation(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, definition: Any, validators: List>) { + validators.forEach { + it.validate(bluePrintContext, error, name, definition as T) + } + } +} + + + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index f73fb727d..cce6d904c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -32,6 +32,11 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + /** + * Blueprint CBA extracted file location + */ + var rootPath = "." + val imports: List? = serviceTemplate.imports val metadata: MutableMap? = serviceTemplate.metadata -- cgit 1.2.3-korg From a99c9b95ec21ab16ec9ccc83df71d3955a05f678 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 10:27:19 -0500 Subject: Add Service Template Blueprint Validation. Change-Id: Id0df5664cf22a9c4ed09019627c8d697bb73390a Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../BluePrintServiceTemplateValidatorImpl.kt | 92 ++++++++++++++++++++++ .../core/validation/BluePrintValidatorService.kt | 36 +++++++++ 2 files changed, 128 insertions(+) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt new file mode 100644 index 000000000..257528d73 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -0,0 +1,92 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.google.common.base.Preconditions +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + var bluePrintContext: BluePrintContext? = null + var error: BluePrintValidationError? = null + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) { + log.info("Validating Service Template..") + try { + this.bluePrintContext = bluePrintContext + this.error = error + + serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } + serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } + serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) } + serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } + serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } + } catch (e: Exception) { + throw BluePrintException(e, "failed to validate blueprint with message ${e.message}") + } + } + + fun validateMetadata(metaDataMap: MutableMap) { + + val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] + val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] + val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] + val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] + + Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") + } + + + fun validateDataTypes(dataTypes: MutableMap) { + dataTypes.forEach { dataTypeName, dataType -> + // Validate Single Data Type + bluePrintTypeValidatorService.validateDataType(bluePrintContext!!, error!!, dataTypeName, dataType) + } + } + + fun validateArtifactTypes(artifactTypes: MutableMap) { + artifactTypes.forEach { artifactName, artifactType -> + // Validate Single Artifact Type + bluePrintTypeValidatorService.validateArtifactType(bluePrintContext!!, error!!, artifactName, artifactType) + } + } + + fun validateNodeTypes(nodeTypes: MutableMap) { + nodeTypes.forEach { nodeTypeName, nodeType -> + // Validate Single Node Type + bluePrintTypeValidatorService.validateNodeType(bluePrintContext!!, error!!, nodeTypeName, nodeType) + } + } + + fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { + bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintContext!!, error!!, "topologyTemplate", topologyTemplate) + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt new file mode 100644 index 000000000..9840dd25c --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt @@ -0,0 +1,36 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + + +open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + + override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap) { + log.info("Validation blueprints...") + val error = BluePrintValidationError() + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate) + } +} -- cgit 1.2.3-korg From 1fd59087321c50a88e82645b58f5da3bc8cae869 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 13:27:43 -0500 Subject: Add Topology Template Blueprint Validation. Change-Id: If415979740c4c82d7024ea34eecd11185524dab8 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../BluePrintTopologyTemplateValidatorImpl.kt | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt new file mode 100644 index 000000000..7cddf27a5 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -0,0 +1,68 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { + + var bluePrintContext: BluePrintContext? = null + var error: BluePrintValidationError? = null + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) { + this.bluePrintContext = bluePrintContext + // Validate Inputs + topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } + // Validate Node Templates + topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) } + // Validate Workflow + topologyTemplate.workflows?.let { validateWorkflows(topologyTemplate.workflows!!) } + } + + @Throws(BluePrintException::class) + fun validateInputs(inputs: MutableMap) { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, inputs) + } + + + @Throws(BluePrintException::class) + fun validateNodeTemplates(nodeTemplates: MutableMap) { + + nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> + // Validate Single Node Template + bluePrintTypeValidatorService.validateNodeTemplate(bluePrintContext!!, error!!, nodeTemplateName, nodeTemplate) + } + } + + @Throws(BluePrintException::class) + open fun validateWorkflows(workflows: MutableMap) { + + workflows.forEach { workflowName, workflow -> + // Validate Single workflow + bluePrintTypeValidatorService.validateWorkflow(bluePrintContext!!, error!!, workflowName, workflow) + } + } + +} \ No newline at end of file -- cgit 1.2.3-korg From 8f789029f7e3a5a36c49c651b76aea3a9cd7ec7a Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 13:47:08 -0500 Subject: Add Property, Data, Artifact and Node Validation. Change-Id: I0aac1b0a5e565fd3502fccc3e7e34a04070497c5 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../BluePrintArtifactTypeValidatorImpl.kt | 32 +++++++++ .../validation/BluePrintDataTypeValidatorImpl.kt | 33 +++++++++ .../validation/BluePrintNodeTypeValidatorImpl.kt | 31 +++++++++ .../BluePrintPropertyDefinitionValidatorImpl.kt | 78 ++++++++++++++++++++++ .../validation/BluePrintWorkflowValidatorImpl.kt | 30 +++++++++ 5 files changed, 204 insertions(+) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt new file mode 100644 index 000000000..2f440945c --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt @@ -0,0 +1,32 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator { + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) { + artifactType.properties?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!) + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt new file mode 100644 index 000000000..a4a81280e --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt @@ -0,0 +1,33 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) { + dataType.properties?.let { + + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, dataType.properties!!) + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt new file mode 100644 index 000000000..a703143ed --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -0,0 +1,31 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + + +open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: NodeType) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt new file mode 100644 index 000000000..6f67cd73e --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -0,0 +1,78 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { + + var bluePrintContext: BluePrintContext? = null + var error: BluePrintValidationError? = null + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) { + this.bluePrintContext = bluePrintContext + this.error = error + + val dataType: String = propertyDefinition.type + + when { + BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { + // Do Nothing + } + BluePrintTypes.validCollectionTypes().contains(dataType) -> { + val entrySchemaType: String = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, name)) + checkPrimitiveOrComplex(entrySchemaType, name) + } + else -> checkPropertyDataType(dataType, name) + } + } + + + private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { + return true + } else { + throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) + } + } + + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { + + val dataType = bluePrintContext!!.serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + } + + private fun checkDataType(key: String): Boolean { + return bluePrintContext!!.serviceTemplate.dataTypes?.containsKey(key) ?: false + } + + open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt new file mode 100644 index 000000000..f813cc5d2 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt @@ -0,0 +1,30 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: Workflow) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file -- cgit 1.2.3-korg From 036306b08099fd0c321b8ac57b7214423a5d24f7 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 14:52:02 -0500 Subject: Add Property, Interface, Operation Validation. Change-Id: Ie6ecfd29919bfbad4b0aa68288bfc6c139e46f7c Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../validation/BluePrintNodeTypeValidatorImpl.kt | 129 ++++++++++++++++++++- 1 file changed, 126 insertions(+), 3 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt index a703143ed..1ed301c12 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -16,8 +16,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow +import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext @@ -25,7 +30,125 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: NodeType) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + var bluePrintContext: BluePrintContext? = null + var error: BluePrintValidationError? = null + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTypeName: String, nodeType: NodeType) { + + this.bluePrintContext = bluePrintContext + this.error = error + paths.add(nodeTypeName) + + val derivedFrom: String = nodeType.derivedFrom + //Check Derived From + checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) + + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + bluePrintContext.serviceTemplate.nodeTypes?.get(derivedFrom) + ?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)") + } + + nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, nodeType.properties!!) } + nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } + nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } + nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } + + paths.removeAt(paths.lastIndex) + } + + fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("Failed to get node type ($nodeTypeName)'s derivedFrom($derivedFrom) definition ") + } + } + + open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { + val capabilities = nodeType.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityDefinition -> + paths.add(capabilityName) + + validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String, + capabilityDefinition: CapabilityDefinition) { + val capabilityType = capabilityDefinition.type + check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { + throw BluePrintException("failed to get CapabilityType($capabilityType) for NodeType($nodeTypeName)") + } + } + + open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { + paths.add("requirements") + val requirements = nodeType.requirements + + requirements?.forEach { requirementDefinitionName, requirementDefinition -> + paths.add(requirementDefinitionName) + validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) } + + open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String, + requirementDefinition: RequirementDefinition) { + + log.info("validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName) + val requirementNodeTypeName = requirementDefinition.node!! + val capabilityName = requirementDefinition.capability + val relationship = requirementDefinition.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException("failed to get relationship($relationship) for NodeType($nodeTypeName)'s requirement($requirementDefinitionName)") + } + + val relationShipNodeType = bluePrintContext!!.serviceTemplate.nodeTypes?.get(requirementNodeTypeName) + ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s for requirement($requirementDefinitionName) ") + + relationShipNodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s " + + "capability($nodeTypeName) for NodeType ($capabilityName)'s requirement($requirementDefinitionName) ") + + } + + open fun validateInterfaceDefinitions(interfaces: MutableMap) { + paths.add("interfaces") + interfaces.forEach { interfaceName, interfaceDefinition -> + paths.add(interfaceName) + interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateOperationDefinitions(operations: MutableMap) { + paths.add("operations") + operations.forEach { opertaionName, operationDefinition -> + paths.add(opertaionName) + operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } + + operationDefinition.inputs?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, operationDefinition.inputs!!) + } + + operationDefinition.outputs?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, operationDefinition.outputs!!) + } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateImplementation(implementation: Implementation) { + checkNotEmptyNThrow(implementation.primary) + } + } \ No newline at end of file -- cgit 1.2.3-korg From 24debe3ea855c6a6f59f8d611798910b06533945 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 15:29:57 -0500 Subject: Add NodeTemplate Interface & Operation Validation. Change-Id: I0a694512c6eaaf9190b0137f63b7ad4dbddaf1e6 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../BluePrintNodeTemplateValidatorImpl.kt | 295 +++++++++++++++++++++ 1 file changed, 295 insertions(+) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt new file mode 100644 index 000000000..bf2954684 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -0,0 +1,295 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + + +open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) + + var bluePrintContext: BluePrintContext? = null + var error: BluePrintValidationError? = null + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + paths.add(nodeTemplateName) + + val type: String = nodeTemplate.type + + val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type) + ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)") + + nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } + nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } + nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } + + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateArtifactDefinitions(artifacts: MutableMap) { + paths.add("artifacts") + artifacts.forEach { artifactDefinitionName, artifactDefinition -> + paths.add(artifactDefinitionName) + val type: String = artifactDefinition.type + ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)") + // Check Artifact Type + checkValidArtifactType(artifactDefinitionName, type) + + val file: String = artifactDefinition.file + ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)") + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + + @Throws(BluePrintException::class) + open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, + properties: MutableMap) { + properties.forEach { propertyName, propertyAssignment -> + val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] + ?: throw BluePrintException("failed to get definition for the property ($propertyName)") + + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + + } + } + + @Throws(BluePrintException::class) + open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition, + propertyAssignment: JsonNode) { + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) + } + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val capabilities = nodeTemplate.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityAssignment -> + paths.add(capabilityName) + + val capabilityDefinition = nodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) capability definition ($capabilityName) " + + "from NodeType(${nodeTemplate.type})") + + validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String, + capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) { + + capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val requirements = nodeTemplate.requirements + paths.add("requirements") + requirements?.forEach { requirementName, requirementAssignment -> + paths.add(requirementName) + val requirementDefinition = nodeType.requirements?.get(requirementName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) requirement definition ($requirementName) from" + + " NodeType(${nodeTemplate.type})") + // Validate Requirement Assignment + validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, + requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { + log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) + val requirementNodeTemplateName = requirementAssignment.node!! + val capabilityName = requirementAssignment.capability + val relationship = requirementAssignment.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException("Failed to get relationship type ($relationship) for NodeTemplate($nodeTemplateName)'s requirement($requirementAssignmentName)") + } + + val relationShipNodeTemplate = bluePrintContext!!.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) + ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + + "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)") + + relationShipNodeTemplate.capabilities?.get(capabilityName) + ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + + "capability($capabilityName) for NodeTemplate ($nodeTemplateName)'s requirement($requirementAssignmentName)") + + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + val interfaces = nodeTemplate.interfaces + paths.add("interfaces") + interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> + paths.add(interfaceAssignmentName) + val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) interface definition ($interfaceAssignmentName) from" + + " NodeType(${nodeTemplate.type})") + + validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + } + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + it.forEach { operationAssignmentName, operationAssignments -> + + val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)") + + log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName, + interfaceAssignmentName, operationAssignmentName) + + val inputs = operationAssignments.inputs + val outputs = operationAssignments.outputs + + inputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.inputs?.get(propertyName) + ?: throw BluePrintException("Failed to get NodeTemplate(nodeTemplateName) operation " + + "definition (operationAssignmentName) property definition(propertyName)") + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + outputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.outputs?.get(propertyName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " + + "output property definition($propertyName)") + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + } + } + + } + + open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { + + val artifactType = bluePrintContext!!.serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") + + checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) + } + + @Throws(BluePrintException::class) + open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") + } + } + + open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { + val propertyType = propertyDefinition.type + val isValid: Boolean + + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + + val entrySchemaType = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) + + if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { + checkPropertyDataType(entrySchemaType, propertyName) + } + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) + } else { + checkPropertyDataType(propertyType, propertyName) + isValid = true + } + + check(isValid) { + throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)") + } + } + + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { + + val dataType = bluePrintContext!!.serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found") + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + + } + + private fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ") + } + } + +} \ No newline at end of file -- cgit 1.2.3-korg From cb8751a59f47519757371938998d340b8e317ce5 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 27 Nov 2018 16:48:39 -0500 Subject: Add Validator Junit test case Change-Id: I785e8cb2d3705f5650512ecc27517d2edd9df683 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintConstants.kt | 6 +++ .../core/interfaces/BlueprintValidator.kt | 2 +- .../core/utils/BluePrintMetadataUtils.kt | 4 +- .../BluePrintArtifactTypeValidatorImpl.kt | 1 + .../BluePrintAttributeDefinitionValidatorImpl.kt | 30 +++++++++++ .../validation/BluePrintDataTypeValidatorImpl.kt | 5 ++ .../BluePrintNodeTemplateValidatorImpl.kt | 5 +- .../validation/BluePrintNodeTypeValidatorImpl.kt | 3 +- .../BluePrintPropertyDefinitionValidatorImpl.kt | 6 +++ .../BluePrintServiceTemplateValidatorImpl.kt | 19 +++++-- .../BluePrintTopologyTemplateValidatorImpl.kt | 7 +++ .../core/validation/BluePrintValidatorService.kt | 36 ------------- .../validation/BluePrintValidatorServiceImpl.kt | 40 +++++++++++++++ .../validation/BluePrintWorkflowValidatorImpl.kt | 30 ++++++++++- .../core/mock/MockBluePrintTypeValidatorService.kt | 59 ++++++++++++++++++++++ .../BluePrintValidatorServiceImplTest.kt | 43 ++++++++++++++++ 16 files changed, 251 insertions(+), 45 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index a41284187..2908a6325 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -48,6 +48,12 @@ object BluePrintConstants { const val MODEL_CONTENT_TYPE_SCHEMA: String = "SCHEMA" const val PATH_DIVIDER: String = "/" + const val PATH_SERVICE_TEMPLATE: String = "service_template" + const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" + const val PATH_METADATA: String = "metadata" + const val PATH_NODE_TYPES: String = "node_types" + const val PATH_ARTIFACT_TYPES: String = "artifact_types" + const val PATH_DATA_TYPES: String = "data_types" const val PATH_INPUTS: String = "inputs" const val PATH_NODE_WORKFLOWS: String = "workflows" const val PATH_NODE_TEMPLATES: String = "node_templates" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt index 9407cfa11..322f65741 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -37,7 +37,7 @@ interface BluePrintAttributeDefinitionValidator : BluePrintValidator) + fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap) : Boolean } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index 320c306c3..0092b7026 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -103,6 +103,8 @@ object BluePrintMetadataUtils { // Recursively Import Template files val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath) val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() - return BluePrintContext(completeServiceTemplate) + val blueprintContext = BluePrintContext(completeServiceTemplate) + blueprintContext.rootPath = basePath + return blueprintContext } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt index 2f440945c..9208bdac3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt @@ -28,5 +28,6 @@ open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidator artifactType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!) } + // TODO ("Files Present ") } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt new file mode 100644 index 000000000..d0faf1c25 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -0,0 +1,30 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: AttributeDefinition) { + //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt index a4a81280e..c8d8a74d5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator @@ -23,8 +25,11 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeVal import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString()) override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) { + log.trace("Validating DataType($name)") + dataType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, dataType.properties!!) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt index bf2954684..94d6251cc 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -40,6 +40,9 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator var paths: MutableList = arrayListOf() override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + log.trace("Validating NodeTemplate($nodeTemplateName)") + this.bluePrintContext = bluePrintContext + this.error = error paths.add(nodeTemplateName) @@ -48,11 +51,11 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type) ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)") - nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } paths.removeAt(paths.lastIndex) } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt index 1ed301c12..86bf521fa 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -37,9 +37,10 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ var paths: MutableList = arrayListOf() override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTypeName: String, nodeType: NodeType) { - + log.trace("Validating NodeType($nodeTypeName)") this.bluePrintContext = bluePrintContext this.error = error + paths.add(nodeTypeName) val derivedFrom: String = nodeType.derivedFrom diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt index 6f67cd73e..f4804d4c5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError @@ -27,6 +29,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + var bluePrintContext: BluePrintContext? = null var error: BluePrintValidationError? = null @@ -34,6 +38,8 @@ open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeVal this.bluePrintContext = bluePrintContext this.error = error + log.trace("Validating PropertyDefinition($name)") + val dataType: String = propertyDefinition.type when { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt index 257528d73..66c504dea 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -21,7 +21,6 @@ import com.att.eelf.configuration.EELFManager import com.google.common.base.Preconditions import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator @@ -34,9 +33,10 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida var bluePrintContext: BluePrintContext? = null var error: BluePrintValidationError? = null + var paths: MutableList = arrayListOf() override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) { - log.info("Validating Service Template..") + log.trace("Validating Service Template..") try { this.bluePrintContext = bluePrintContext this.error = error @@ -47,12 +47,14 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } } catch (e: Exception) { - throw BluePrintException(e, "failed to validate blueprint with message ${e.message}") + error.addError(BluePrintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) } } fun validateMetadata(metaDataMap: MutableMap) { + paths.add(BluePrintConstants.PATH_METADATA) + val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] @@ -62,31 +64,42 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") + + paths.removeAt(paths.lastIndex) } fun validateDataTypes(dataTypes: MutableMap) { + + paths.add(BluePrintConstants.PATH_DATA_TYPES) dataTypes.forEach { dataTypeName, dataType -> // Validate Single Data Type bluePrintTypeValidatorService.validateDataType(bluePrintContext!!, error!!, dataTypeName, dataType) } + paths.removeAt(paths.lastIndex) } fun validateArtifactTypes(artifactTypes: MutableMap) { + paths.add(BluePrintConstants.PATH_ARTIFACT_TYPES) artifactTypes.forEach { artifactName, artifactType -> // Validate Single Artifact Type bluePrintTypeValidatorService.validateArtifactType(bluePrintContext!!, error!!, artifactName, artifactType) } + paths.removeAt(paths.lastIndex) } fun validateNodeTypes(nodeTypes: MutableMap) { + paths.add(BluePrintConstants.PATH_NODE_TYPES) nodeTypes.forEach { nodeTypeName, nodeType -> // Validate Single Node Type bluePrintTypeValidatorService.validateNodeType(bluePrintContext!!, error!!, nodeTypeName, nodeType) } + paths.removeAt(paths.lastIndex) } fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { + paths.add(BluePrintConstants.PATH_TOPOLOGY_TEMPLATE) bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintContext!!, error!!, "topologyTemplate", topologyTemplate) + paths.removeAt(paths.lastIndex) } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt index 7cddf27a5..411cdb4d3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate @@ -28,11 +30,16 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + var bluePrintContext: BluePrintContext? = null var error: BluePrintValidationError? = null override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) { + log.trace("Validating Topology Template..") this.bluePrintContext = bluePrintContext + this.error = error + // Validate Inputs topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } // Validate Node Templates diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt deleted file mode 100644 index 9840dd25c..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorService.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext - - -open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) - - override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap) { - log.info("Validation blueprints...") - val error = BluePrintValidationError() - bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate) - } -} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt new file mode 100644 index 000000000..10e8d65bc --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt @@ -0,0 +1,40 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + + +open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + + override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap): Boolean { + val error = BluePrintValidationError() + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate) + if (error.errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${error.errors.joinToString("\n")}") + } + return true + } +} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt index f813cc5d2..8ba6f7204 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt @@ -16,6 +16,9 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -24,7 +27,30 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: Workflow) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + var bluePrintContext: BluePrintContext? = null + var error: BluePrintValidationError? = null + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, workflowName: String, workflow: Workflow) { + log.info("Validating Workflow($workflowName)") + + this.bluePrintContext = bluePrintContext + this.error = error + + paths.add(workflowName) + paths.joinToString(BluePrintConstants.PATH_DIVIDER) + + // Step Validation Start + paths.add("steps") + workflow.steps?.forEach { stepName, _ -> + paths.add(stepName) + paths.joinToString(BluePrintConstants.PATH_DIVIDER) + // TODO("Step Validation") + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + // Step Validation Ends + paths.removeAt(paths.lastIndex) } } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt new file mode 100644 index 000000000..4c174f92e --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt @@ -0,0 +1,59 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.mock + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* +import org.onap.ccsdk.apps.controllerblueprints.core.validation.* + +class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService { + + override fun getServiceTemplateValidators(): List { + return listOf(BluePrintServiceTemplateValidatorImpl(this)) + } + + override fun getDataTypeValidators(): List { + return listOf(BluePrintDataTypeValidatorImpl(this)) + } + + override fun getArtifactTypeValidators(): List { + return listOf(BluePrintArtifactTypeValidatorImpl(this)) + } + + override fun getNodeTypeValidators(): List { + return listOf(BluePrintNodeTypeValidatorImpl(this)) + } + + override fun getTopologyTemplateValidators(): List { + return listOf(BluePrintTopologyTemplateValidatorImpl(this)) + } + + override fun getNodeTemplateValidators(): List { + return listOf(BluePrintNodeTemplateValidatorImpl(this)) + } + + override fun getWorkflowValidators(): List { + return listOf(BluePrintWorkflowValidatorImpl(this)) + } + + override fun getPropertyDefinitionValidators(): List { + return listOf(BluePrintPropertyDefinitionValidatorImpl(this)) + } + + override fun getAttributeDefinitionValidators(): List { + return listOf(BluePrintAttributeDefinitionValidatorImpl(this)) + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt new file mode 100644 index 000000000..ca238db53 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt @@ -0,0 +1,43 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.validation + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import kotlin.test.assertTrue + +class BluePrintValidatorServiceImplTest { + + val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + + + @Test + fun testValidateOfType() { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + + val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() + + val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) + + val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintContext, hashMapOf()) + + assertTrue(valid, "failed in blueprint Validation") + + } +} + -- cgit 1.2.3-korg From a4863f4aa59555ee786786e6c30295d3dad6a5e0 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sat, 1 Dec 2018 19:54:07 -0500 Subject: Enable Webflux Service. Change-Id: I99bacee9b63aa788bb368dec60981bf19ea759c4 Issue-ID: CCSDK-781 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/parent/pom.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 39f2d1015..8a779c1dc 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -29,8 +29,8 @@ App Components Parent pom - 2.0.6.RELEASE - 5.0.10.RELEASE + 2.1.1.RELEASE + 5.1.3.RELEASE 1.3.10 1.3.10 1.0.1 @@ -130,6 +130,11 @@ + + io.grpc + grpc-core + ${grpc.version} + io.grpc grpc-netty @@ -180,6 +185,12 @@ ${kotlin.version} test + + io.grpc + grpc-testing + ${grpc.version} + test + -- cgit 1.2.3-korg From e1e4a87bf588ba6f4d7e1fbc1698131876bc9f70 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 3 Dec 2018 12:34:39 -0500 Subject: Add Blueprint File utils Change-Id: I9896d934684343358d1c0c7e321725511430c7e6 Issue-ID: CCSDK-783 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintConstants.kt | 2 + .../core/utils/BluePrintFileUtils.kt | 128 ++++++++++++++++++++ .../core/utils/JacksonUtils.kt | 7 ++ .../core/utils/BluePrintFileUtilsTest.kt | 59 ++++++++++ .../Definitions/activation-blueprint.json | 8 +- .../Definitions/artifact-types.json | 45 ------- .../Definitions/artifact_types.json | 45 +++++++ .../Definitions/baseconfig-mapping.json | 3 + .../baseconfiguration/Definitions/data-types.json | 24 ---- .../baseconfiguration/Definitions/data_types.json | 24 ++++ .../baseconfiguration/Definitions/node-types.json | 130 --------------------- .../baseconfiguration/Definitions/node_types.json | 130 +++++++++++++++++++++ .../Definitions/resources_dictionaty_types.json | 3 + .../Mappings/baseconfig-mapping.json | 3 - .../Mappings/resources-dictionary.json | 3 - 15 files changed, 405 insertions(+), 209 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 2908a6325..0517e90ba 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -139,7 +139,9 @@ object BluePrintConstants { const val PROPERTY_BLUEPRINT_NAME: String = "template_name" const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" + const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" + const val TOSCA_DEFINITIONS_DIR: String = "Definitions" const val TOSCA_PLANS_DIR: String = "Plans" const val TOSCA_SCRIPTS_DIR: String = "Scripts" const val TOSCA_MAPPINGS_DIR: String = "Mappings" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt new file mode 100644 index 000000000..d9222d754 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -0,0 +1,128 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import kotlinx.coroutines.runBlocking +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import java.io.File +import java.io.FileFilter +import java.nio.file.Files +import java.nio.file.StandardOpenOption + +class BluePrintFileUtils { + companion object { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + fun createEmptyBluePrint(basePath: String) { + + val blueprintDir = File(basePath) + FileUtils.deleteDirectory(blueprintDir) + + Files.createDirectories(blueprintDir.toPath()) + + val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR)) + Files.createDirectories(metaDataDir.toPath()) + + val metafile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)) + Files.write(metafile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) + + val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)) + Files.createDirectories(definitionsDir.toPath()) + + val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_SCRIPTS_DIR)) + Files.createDirectories(scriptsDir.toPath()) + + val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_PLANS_DIR)) + Files.createDirectories(plansDir.toPath()) + + val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_TEMPLATES_DIR)) + Files.createDirectories(templatesDir.toPath()) + + } + + fun copyBluePrint(sourcePath: String, targetPath: String) { + val sourceFile = File(sourcePath) + val targetFile = File(targetPath) + sourceFile.copyRecursively(targetFile, true) + } + + fun deleteBluePrintTypes(basePath: String) { + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + log.info("deleting definition types under : $definitionPath") + + val definitionDir = File(definitionPath) + // Find the Type Definitions + val fileFilter = FileFilter { pathname -> pathname.absolutePath.endsWith("_types.json") } + // Delete the Type Files + definitionDir.listFiles(fileFilter).forEach { + Files.deleteIfExists(it.toPath()) + } + } + + fun writeBluePrintTypes(blueprintContext: BluePrintContext) { + + val basePath = blueprintContext.rootPath + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + val definitionDir = File(definitionPath) + + check(definitionDir.exists()) { + throw BluePrintException("couldn't get definition file under path(${definitionDir.absolutePath})") + } + + blueprintContext.dataTypes.let { + val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, blueprintContext.dataTypes!!, true) + writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) + + } + + blueprintContext.artifactTypes.let { + val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, blueprintContext.artifactTypes!!, true) + writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) + } + + blueprintContext.nodeTypes.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, blueprintContext.nodeTypes!!, true) + writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) + } + + } + + private fun writeFile(definitionPath: String, type: String, content: String) = runBlocking { + val typeFile = File(definitionPath.plus(File.separator).plus("$type.json")) + + Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) + check(typeFile.exists()) { + throw BluePrintException("couldn't write $type.json file under path(${typeFile.absolutePath})") + } + } + + private fun getMetaDataContent(): String { + return "TOSCA-Meta-File-Version: 1.0.0" + + "\nCSAR-Version: " + + "\nCreated-By: " + + "\nEntry-Definitions: Definitions/.json" + + "\nTemplate-Tags: " + } + + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index cf5f9e20c..f53f86154 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -104,6 +104,13 @@ object JacksonUtils { return getJson(any, false) } + @JvmStatic + fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String { + val wrapperMap = hashMapOf() + wrapperMap[wrapper] = any + return getJson(wrapperMap, pretty) + } + @JvmStatic fun getJson(any: kotlin.Any, pretty: Boolean = false): String { val objectMapper = jacksonObjectMapper() diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt new file mode 100644 index 000000000..143c4a848 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt @@ -0,0 +1,59 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import kotlinx.coroutines.runBlocking +import org.junit.Test +import java.io.File +import java.nio.file.Paths +import kotlin.test.assertTrue + + +class BluePrintFileUtilsTest { + + @Test + fun testNewBlueprint() = runBlocking { + val targetPath: String = Paths.get("target").toUri().toURL().path.plus("bp-new-test") + BluePrintFileUtils.createEmptyBluePrint(targetPath) + + } + + @Test + fun testBlueprintCopy() = runBlocking { + val sourcePath: String = "./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration" + + val targetPath: String = Paths.get("target").toUri().toURL().path.plus("bp-copy-test") + + val targetDir = File(targetPath) + targetDir.deleteOnExit() + // Copy the BP file + BluePrintFileUtils.copyBluePrint(sourcePath, targetDir.absolutePath) + + assertTrue(targetDir.exists(), "faield to copy blueprint to ${targetDir.absolutePath}") + + // Delete Type Files + BluePrintFileUtils.deleteBluePrintTypes(targetDir.absolutePath) + + // Generate the Type Files + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(sourcePath) + bluePrintContext.rootPath = targetDir.absolutePath + + BluePrintFileUtils.writeBluePrintTypes(bluePrintContext) + + + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 9d1172fc5..04e0efce8 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -9,13 +9,13 @@ }, "imports": [ { - "file": "Definitions/data-types.json" + "file": "Definitions/data_types.json" }, { - "file": "Definitions/node-types.json" + "file": "Definitions/node_types.json" }, { - "file": "Definitions/artifact-types.json" + "file": "Definitions/artifact_types.json" } ], "topology_template": { @@ -117,7 +117,7 @@ }, "baseconfig-mapping": { "type": "artifact-mapping-resource", - "file": "Mappings/baseconfig-mapping.json" + "file": "Definitions/baseconfig-mapping.json" } } }, diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json deleted file mode 100644 index d741d151e..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact-types.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "artifact_types": { - "artifact-template-velocity": { - "description": "Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-mapping-resource": { - "description": "Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-jython": { - "description": "Jython Script File", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-directed-graph": { - "description": "Directed Graph File", - "version": "1.0.0", - "file_ext": [ - "json", - "xml" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-component-jar": { - "description": "Component Jar", - "version": "1.0.0", - "file_ext": [ - "jar" - ], - "derived_from": "tosca.artifacts.Implementation" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json new file mode 100644 index 000000000..d741d151e --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json @@ -0,0 +1,45 @@ +{ + "artifact_types": { + "artifact-template-velocity": { + "description": "Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-mapping-resource": { + "description": "Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-jython": { + "description": "Jython Script File", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-directed-graph": { + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-component-jar": { + "description": "Component Jar", + "version": "1.0.0", + "file_ext": [ + "jar" + ], + "derived_from": "tosca.artifacts.Implementation" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json new file mode 100644 index 000000000..caee773bb --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json @@ -0,0 +1,3 @@ +{ + "assignments": "Sample Assignments" +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json deleted file mode 100644 index 6ca1ffde2..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data-types.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "data_types": { - "sample-property": { - "description": "This is sample data type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json new file mode 100644 index 000000000..6ca1ffde2 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -0,0 +1,24 @@ +{ + "data_types": { + "sample-property": { + "description": "This is sample data type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.datatypes.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json deleted file mode 100644 index 139ebb1a3..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node-types.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "node_types": { - "dg-activate": { - "description": "This is BPMN Activate node type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.nodes.DG" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.component.Jython": { - "description": "This is Resource Assignment Jython Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "template-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "mapping-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "component-jython-executor": { - "description": "This is Jython Execution Component.", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "JythonExecutorComponent": { - "operations": { - "process": { - "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.Jython" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json new file mode 100644 index 000000000..139ebb1a3 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -0,0 +1,130 @@ +{ + "node_types": { + "dg-activate": { + "description": "This is BPMN Activate node type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.nodes.DG" + }, + "tosca.nodes.Component": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.DG": { + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Jython": { + "description": "This is Resource Assignment Jython Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "properties": { + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + } + }, + "interfaces": { + "ResourceAssignmentComponent": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "template-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "mapping-content": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-jython-executor": { + "description": "This is Jython Execution Component.", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "JythonExecutorComponent": { + "operations": { + "process": { + "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.Jython" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json new file mode 100644 index 000000000..0e0dcd235 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json deleted file mode 100644 index caee773bb..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/baseconfig-mapping.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "assignments": "Sample Assignments" -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json deleted file mode 100644 index 0e0dcd235..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Mappings/resources-dictionary.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file -- cgit 1.2.3-korg From 6cba7f8da7640b8c6dd3c662ce424fd11acc621f Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 4 Dec 2018 10:25:44 -0500 Subject: Add Blueprint Runtime Input/Output logic Change-Id: I0355e78862096b7b4074faa882d66ce27d6e1844 Issue-ID: CCSDK-670 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintConstants.kt | 3 + .../controllerblueprints/core/CustomFunctions.kt | 20 ++- .../core/service/BluePrintContext.kt | 2 + .../core/service/BluePrintRuntimeService.kt | 34 +++-- .../core/service/PropertyAssignmentService.kt | 3 +- .../core/utils/BluePrintArchiveUtils.kt | 148 +++++++++++++++++++++ .../Definitions/activation-blueprint.json | 109 ++++++++++----- .../baseconfiguration/Definitions/data_types.json | 69 ++++++++++ .../baseconfiguration/Definitions/node_types.json | 2 +- .../Plans/CONFIG_ActivateNetconf_1.0.0.xml | 2 +- .../Plans/CONFIG_AssignActivateNetconf_1.0.0.xml | 42 ++++++ .../Plans/CONFIG_ResourceAssignment_1.0.0.xml | 34 +++++ components/parent/pom.xml | 9 ++ 13 files changed, 424 insertions(+), 53 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 0517e90ba..167496ebc 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -29,6 +29,9 @@ object BluePrintConstants { const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + const val STATUS_SUCCESS: String = "success" + const val STATUS_FAILURE: String = "failure" + const val TYPE_DEFAULT: String = "default" const val DATA_TYPE_STRING: String = "string" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt index c32e15f8a..2329fc935 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -75,17 +75,17 @@ fun MutableMap.castValue(key: String, valueType: KClass) fun MutableMap.putJsonElement(key: String, value: Any) { when (value) { is JsonNode -> - this.put(key, value) + this[key] = value is String -> - this.put(key, TextNode(value)) + this[key] = TextNode(value) is Boolean -> - this.put(key, BooleanNode.valueOf(value)) + this[key] = BooleanNode.valueOf(value) is Int -> - this.put(key, IntNode.valueOf(value.toInt())) + this[key] = IntNode.valueOf(value.toInt()) is Double -> - this.put(key, DoubleNode.valueOf(value.toDouble())) + this[key] = DoubleNode.valueOf(value.toDouble()) else -> - this.put(key, JacksonUtils.jsonNodeFromObject(value)) + this[key] = JacksonUtils.jsonNodeFromObject(value) } } @@ -97,6 +97,14 @@ fun MutableMap.getAsBoolean(key: String): Boolean { return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)") } +fun MutableMap.getAsInt(key: String): Int { + return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)") +} + +fun MutableMap.getAsDouble(key: String): Double { + return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)") +} + // Checks fun checkNotEmpty(value: String?): Boolean { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index cce6d904c..84af3f988 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -57,6 +57,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName) ?: throw BluePrintException("could't get workflow($workFlowName)") + fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs + fun workflowStepByName(workFlowName: String, stepName: String): Step { return workflowByName(workFlowName).steps?.get(stepName) ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)") diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 84ba10473..448a06a86 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate @@ -211,15 +210,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignments: MutableMap = bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap - ?: throw BluePrintException(String.format("failed to get input definitions for node template (%s), " + - "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName)) + ?: hashMapOf() val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type val nodeTypeInterfaceOperationInputs: MutableMap = bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName) - ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " + - "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName)) + ?: hashMapOf() log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments) @@ -258,15 +255,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignments: MutableMap = bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap - ?: throw BluePrintException(String.format("failed to get output definitions for node template (%s), " + - "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName)) + ?: hashMapOf() val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type val nodeTypeInterfaceOperationOutputs: MutableMap = bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName) - ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " + - "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName)) + ?: hashMapOf() // Iterate Node Type Properties nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty -> @@ -435,10 +430,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString()) + val dynamicInputPropertiesName = "$workflowName-properties" + bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property -> - val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) - ?: NullNode.getInstance() - setInputValue(propertyName, property, valueNode) + if (propertyName != dynamicInputPropertiesName) { + val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setInputValue(propertyName, property, valueNode) + } + } + + val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName) + + workflowDynamicInputs?.let { + bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property -> + val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setInputValue(propertyName, property, valueNode) + + } } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 947eb41e0..36c141f5e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -197,8 +197,7 @@ If Property Assignment is Expression. } fun artifactContent(artifactDefinition: ArtifactDefinition): String { - val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText() - ?: throw BluePrintException("failed to get property (${BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH}) from getStore") + val bluePrintBasePath: String = bluePrintContext.rootPath if (artifactDefinition.repository != null) { TODO() diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt new file mode 100644 index 000000000..f02524ffa --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -0,0 +1,148 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream +import org.apache.commons.io.IOUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import java.io.* +import java.nio.charset.Charset +import java.util.zip.ZipFile + +class BluePrintArchiveUtils { + + companion object { + + + fun compress(source: String, destination: String, absolute: Boolean): Boolean { + val rootDir = File(source) + val saveFile = File(destination) + return compress(rootDir, saveFile, absolute) + } + + /** + * Create a new Zip from a root directory + * + * @param directory the base directory + * @param filename the output filename + * @param absolute store absolute filepath (from directory) or only filename + * @return True if OK + */ + fun compress(source: File, destination: File, absolute: Boolean): Boolean { + // recursive call + val zaos: ZipArchiveOutputStream + try { + zaos = ZipArchiveOutputStream(FileOutputStream(destination)) + } catch (e: FileNotFoundException) { + return false + } + + try { + recurseFiles(source, source, zaos, absolute) + } catch (e2: IOException) { + try { + zaos.close() + } catch (e: IOException) { + // ignore + } + + return false + } + + try { + zaos.finish() + } catch (e1: IOException) { + // ignore + } + + try { + zaos.flush() + } catch (e: IOException) { + // ignore + } + + try { + zaos.close() + } catch (e: IOException) { + // ignore + } + + return true + } + + /** + * Recursive traversal to add files + * + * @param root + * @param file + * @param zaos + * @param absolute + * @throws IOException + */ + @Throws(IOException::class) + private fun recurseFiles(root: File, file: File, zaos: ZipArchiveOutputStream, + absolute: Boolean) { + if (file.isDirectory) { + // recursive call + val files = file.listFiles() + for (file2 in files!!) { + recurseFiles(root, file2, zaos, absolute) + } + } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) { + var filename: String? = null + if (absolute) { + filename = file.absolutePath.substring(root.absolutePath.length) + } else { + filename = file.name + } + val zae = ZipArchiveEntry(filename) + zae.setSize(file.length()) + zaos.putArchiveEntry(zae) + val fis = FileInputStream(file) + IOUtils.copy(fis, zaos) + zaos.closeArchiveEntry() + } + } + + + fun deCompress(zipFile: File, targetPath: String): File { + val zip = ZipFile(zipFile, Charset.defaultCharset()) + val enumeration = zip.entries() + while (enumeration.hasMoreElements()) { + val entry = enumeration.nextElement() + val destFilePath = File(targetPath, entry.name) + destFilePath.parentFile.mkdirs() + if (entry.isDirectory) + continue + val bufferedIs = BufferedInputStream(zip.getInputStream(entry)) + bufferedIs.use { + destFilePath.outputStream().buffered(1024).use { bos -> + bufferedIs.copyTo(bos) + } + } + } + + val destinationDir = File(targetPath) + check(destinationDir.isDirectory && destinationDir.exists()) { + throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ") + } + return destinationDir + } + } + +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 04e0efce8..b538f50d3 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -38,6 +38,32 @@ } }, "node_templates": { + "resource-assignment-process": { + "type": "dg-activate", + "properties": { + "process-name": { + "get_input": "action-name" + }, + "version": { + "get_property": [ + "SELF", + "process-name" + ] + }, + "content": { + "get_artifact": [ + "SELF", + "dg-resource-assignment-process" + ] + } + }, + "artifacts": { + "dg-resource-assignment-process": { + "type": "artifact-directed-graph", + "file": "Plans/CONFIG_ResourceAssignment_1.0.0.xml" + } + } + }, "activate-process": { "type": "dg-activate", "properties": { @@ -64,6 +90,32 @@ } } }, + "assign-activate-process": { + "type": "dg-activate", + "properties": { + "process-name": { + "get_input": "action-name" + }, + "version": { + "get_property": [ + "SELF", + "process-name" + ] + }, + "content": { + "get_artifact": [ + "SELF", + "dg-assign-activate-process" + ] + } + }, + "artifacts": { + "dg-assign-activate-process": { + "type": "artifact-directed-graph", + "file": "Plans/CONFIG_AssignActivateNetconf_1.0.0.xml" + } + } + }, "resource-assignment": { "type": "component-resource-assignment", "properties": { @@ -181,30 +233,18 @@ "workflows": { "resource-assignment": { "inputs": { - "request-id": { + "resource-assignment-properties": { "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" + "type": "resource-assignment-properties" } }, "steps": { "call-resource-assignment": { "description": "Resource Assignment Workflow", - "target": "resource-assignment", + "target": "resource-assignment-process", "activities": [ { - "call_operation": "ResourceAssignmentComponent.process" + "call_operation": "CONFIG.ResourceAssignment" } ] } @@ -212,21 +252,9 @@ }, "activate": { "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { + "activate-properties": { "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" + "type": "activate-properties" } }, "steps": { @@ -235,7 +263,26 @@ "target": "activate-process", "activities": [ { - "call_operation": "ResourceAssignmentComponent.process" + "call_operation": "CONFIG.ActivateProcess" + } + ] + } + } + }, + "assign-activate": { + "inputs": { + "assign-activate-properties": { + "required": true, + "type": "assign-activate-properties" + } + }, + "steps": { + "activate-process": { + "description": "Resource Assign and Netconf Activation Workflow", + "target": "assign-activate-process", + "activities": [ + { + "call_operation": "CONFIG.AssignActivateProcess" } ] } diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json index 6ca1ffde2..569b668ac 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -19,6 +19,75 @@ } }, "derived_from": "tosca.datatypes.Root" + }, + "activate-properties": { + "description": "This is Dynamically generated data type for workflow activate", + "version": "1.0.0", + "properties": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" + }, + "resource-assignment-properties": { + "description": "This is Dynamically generated data type for workflow activate", + "version": "1.0.0", + "properties": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" + }, + "assign-activate-properties": { + "description": "This is Dynamically generated data type for workflow assign-activate", + "version": "1.0.0", + "properties": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" } } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 139ebb1a3..b83fd2a3f 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -1,7 +1,7 @@ { "node_types": { "dg-activate": { - "description": "This is BPMN Activate node type", + "description": "This is Generic Directed Graph Type", "version": "1.0.0", "properties": { "content": { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml index d256bbd23..2f6d2eda8 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml @@ -19,7 +19,7 @@ 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'> - + diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml new file mode 100644 index 000000000..eb41b7dfa --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml new file mode 100644 index 000000000..a197877f5 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 8a779c1dc..5c4620880 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -91,6 +91,11 @@ commons-io 2.6 + + org.apache.commons + commons-compress + 1.15 + org.apache.velocity velocity @@ -215,6 +220,10 @@ commons-io commons-io + + org.apache.commons + commons-compress + com.jayway.jsonpath json-path -- cgit 1.2.3-korg From 6579644f0a797ecb04d7e00505cd1263a8c5810f Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 4 Dec 2018 20:53:22 -0500 Subject: Add Netconf Executor Function module Change-Id: If264e63d4fc4305bc26dc6b249a462afefcbfe1e Issue-ID: CCSDK-790 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../baseconfiguration/Definitions/activation-blueprint.json | 6 ++++++ .../baseconfiguration/Definitions/node_types.json | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index b538f50d3..e5f0c9c02 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -214,6 +214,12 @@ "implementation": { "primary": "component-script" }, + "inputs": { + "instance-dependencies": [ + "json-parser-service", + "netconf-rpc-service" + ] + }, "outputs": { "response-data": "", "status": "" diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index b83fd2a3f..2723510a0 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -108,6 +108,16 @@ "JythonExecutorComponent": { "operations": { "process": { + "inputs": { + "instance-dependencies": { + "required": true, + "description": "Instance Names to Inject to Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, "outputs": { "response-data": { "description": "Execution Response Data in JSON format.", -- cgit 1.2.3-korg From dfbf45d200567022e3c076a7dfa3966ff281c26d Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 6 Dec 2018 13:25:36 -0500 Subject: Store step inputs to blueprint runtime service. Change-Id: Ib01edfc358625d25ac0625f88739c7c57f7f967c Issue-ID: CCSDK-670 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt | 4 ++++ .../controllerblueprints/core/interfaces/BlueprintFunctionNode.kt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt index 2329fc935..4d1d9b653 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -49,6 +49,10 @@ fun Double.asJsonPrimitive(): DoubleNode { return DoubleNode.valueOf(this) } +fun MutableMap.asJsonNode(): JsonNode { + return JacksonUtils.jsonNodeFromObject(this) +} + fun format(message: String, vararg args: Any?): String { if (args != null && args.isNotEmpty()) { return MessageFormatter.arrayFormat(message, args).message diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt index 6add70e64..0b9f1f182 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt @@ -22,6 +22,8 @@ import java.util.function.Function interface BlueprintFunctionNode : Function { + fun getName(): String + @Throws(BluePrintProcessorException::class) fun prepareRequest(executionRequest: T): T -- cgit 1.2.3-korg From 0948a5aefe07ad80092fd2e8e8499dd5609996e1 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 7 Dec 2018 16:37:03 -0500 Subject: Add GRPC Blueprint Processing API Change-Id: Id2c31e8db2b5ede6a992d923f695ce1e0e14b450 Issue-ID: CCSDK-799 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../api-definition/proto/BluePrintManagement.proto | 56 ++++++++++++++++++++++ .../api-definition/proto/BluePrintProcessing.proto | 49 +++++++++++++++++++ components/parent/pom.xml | 24 ++++++++++ 3 files changed, 129 insertions(+) create mode 100644 components/model-catalog/api-definition/proto/BluePrintManagement.proto create mode 100644 components/model-catalog/api-definition/proto/BluePrintProcessing.proto diff --git a/components/model-catalog/api-definition/proto/BluePrintManagement.proto b/components/model-catalog/api-definition/proto/BluePrintManagement.proto new file mode 100644 index 000000000..55f9466e4 --- /dev/null +++ b/components/model-catalog/api-definition/proto/BluePrintManagement.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.management.api; + +message BluePrintUploadInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; + FileChunk fileChunk = 4; +} + +message FileChunk { + bytes chunk = 1; +} + +message BluePrintUploadOutput { + CommonHeader commonHeader = 1; + Status status = 3; +} + +message BluePrintRemoveInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; +} + +message BluePrintRemoveOutput { + CommonHeader commonHeader = 1; + Status status = 3; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; +} + +message ActionIdentifiers { + string blueprintName = 1; + string blueprintVersion = 2; + string actionName = 3; + string mode = 4; +} + +message Status { + string timestamp = 1; + int32 code = 2; + string message = 3; + string errorMessage = 4; +} + +service BluePrintManagementService { + rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintUploadOutput); + rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintRemoveOutput); +} diff --git a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto b/components/model-catalog/api-definition/proto/BluePrintProcessing.proto new file mode 100644 index 000000000..8fa4a13fa --- /dev/null +++ b/components/model-catalog/api-definition/proto/BluePrintProcessing.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; +import "google/protobuf/struct.proto"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.processing.api; + +message ExecutionServiceInput { + CommonHeader commonHeader = 1; + ActionIdentifiers actionIdentifiers = 2; + google.protobuf.Struct payload = 3; +} + +message ExecutionServiceOutput { + CommonHeader commonHeader = 1; + ActionIdentifiers actionIdentifiers = 2; + Status status = 3; + google.protobuf.Struct payload = 4; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; + Flag flag = 5; +} + +message Flag { + bool isForce = 1; + int32 ttl = 2; +} + +message ActionIdentifiers { + string blueprintName = 1; + string blueprintVersion = 2; + string actionName = 3; + string mode = 4; +} + +message Status { + int32 code = 1; + string errorMessage = 2; + string message = 3; + string eventType = 4; + string timestamp = 5; +} + +service BluePrintProcessingService { + rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput); +} diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 5c4620880..03656ebd7 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -35,6 +35,7 @@ 1.3.10 1.0.1 1.16.1 + 3.6.1 1.0.0 26.0-jre 2.9.2 @@ -155,6 +156,11 @@ grpc-stub ${grpc.version} + + com.google.protobuf + protobuf-java-util + ${protobuff.java.utils.version} + @@ -256,6 +262,24 @@ com.fasterxml.jackson.module jackson-module-kotlin + + + io.grpc + grpc-netty + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-stub + + + com.google.protobuf + protobuf-java-util + + -- cgit 1.2.3-korg From 08a5bc8044c8a11aff1797c8e8a8d52973c98605 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 10 Dec 2018 17:01:38 -0500 Subject: Implement Resource Resolution Services Change-Id: Ia1cf57c9fa16cb943836e3a78d4d2c9776f0e32f Issue-ID: CCSDK-724 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/utils/JacksonUtils.kt | 12 +++++ .../Definitions/activation-blueprint.json | 3 ++ .../Definitions/baseconfig-mapping.json | 39 ++++++++++++-- .../baseconfiguration/Definitions/node_types.json | 8 +++ .../Definitions/resources_dictionary_types.json | 62 ++++++++++++++++++++++ .../Definitions/resources_dictionaty_types.json | 3 -- .../node_type/component-resource-assignment.json | 12 ++++- .../resource/dict/ResourceAssignmentProcessor.kt | 57 -------------------- 8 files changed, 131 insertions(+), 65 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index f53f86154..40210142c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -121,6 +121,11 @@ object JacksonUtils { return objectMapper.writeValueAsString(any) } + @JvmStatic + fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + return getListFromJson(node.toString(), valueType) + } + @JvmStatic fun getListFromJson(content: String, valueType: Class): List? { val objectMapper = jacksonObjectMapper() @@ -148,6 +153,13 @@ object JacksonUtils { return objectMapper.readValue(content, typeRef) } + @JvmStatic + fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + return getMapFromJson(content, valueType) + } + @JvmStatic fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { if (BluePrintTypes.validPrimitiveTypes().contains(type)) { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index e5f0c9c02..446932d54 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -136,6 +136,9 @@ "resource-id": { "get_input": "hostname" }, + "artifact-prefix-names": [ + "baseconfig" + ], "template-content": { "get_artifact": [ "SELF", diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json index caee773bb..c457086cf 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json @@ -1,3 +1,36 @@ -{ - "assignments": "Sample Assignments" -} \ No newline at end of file +[ + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + ] + }, + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "vnf_name", + "input-param": false, + "property": { + "type": "string" + }, + "dictionary-name": "vnf_name", + "dictionary-source": "mdsal", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + } +] diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 2723510a0..6e8d839ee 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -69,6 +69,14 @@ "required": true, "type": "string" }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, "template-content": { "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", "required": true, diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json new file mode 100644 index 000000000..557f6efce --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json @@ -0,0 +1,62 @@ +{ + "service-instance-id": { + "name": "service-instance-id", + "tags": "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by": "Singal, Kapil ", + "property": { + "description": "To be provided", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf-id": { + "name": "vnf-id", + "tags": "vnf-id", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf-id", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf_name": { + "name": "vnf_name", + "tags": "vnf_name", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf_name", + "type": "string" + }, + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vnf_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json deleted file mode 100644 index 0e0dcd235..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json index a29a875cb..51d70ede9 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json @@ -11,12 +11,12 @@ "operations": { "process": { "inputs": { - "template-name": { + "template-name": { "description": "Service Template Name.", "required": true, "type": "string" }, - "template-version": { + "template-version": { "description": "Service Template Version.", "required": true, "type": "string" @@ -34,6 +34,14 @@ "type": "string" } }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, "request-id": { "description": "Request Id, Unique Id for the request.", "required": true, diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt deleted file mode 100644 index 327d50ac4..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.slf4j.LoggerFactory - -abstract class ResourceAssignmentProcessor : BlueprintFunctionNode { - - private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java) - - private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null - - open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { - this.bluePrintRuntimeService = bluePrintRuntimeService - } - - open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> { - return this.bluePrintRuntimeService!! - } - - override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment { - log.info("prepareRequest...") - return resourceAssignment - } - - override fun prepareResponse(): ResourceAssignment { - log.info("Preparing Response...") - return ResourceAssignment() - } - - override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment { - prepareRequest(executionServiceInput) - process(executionServiceInput) - return prepareResponse() - } - - override abstract fun process(executionRequest: ResourceAssignment) - - override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) -} \ No newline at end of file -- cgit 1.2.3-korg From 97fc5fa09de5e349ba1dee9a584a9d525c552d06 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 11 Dec 2018 19:40:51 -0500 Subject: Implement Enhancer Framework Interfaces Change-Id: Iff85dc50f87ab6d6f7d9ceb4a309ea6e4d55e362 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../controllerblueprints/core/BluePrintError.kt | 29 +++++ .../core/BluePrintValidationError.kt | 29 ----- .../core/interfaces/BluePrintEnhancer.kt | 122 +++++++++++++++++++++ .../core/interfaces/BlueprintValidator.kt | 28 ++--- .../core/service/BluePrintRepoService.kt | 32 +++--- .../core/utils/JacksonUtils.kt | 32 +++--- .../BluePrintArtifactTypeValidatorImpl.kt | 4 +- .../BluePrintAttributeDefinitionValidatorImpl.kt | 4 +- .../validation/BluePrintDataTypeValidatorImpl.kt | 4 +- .../BluePrintNodeTemplateValidatorImpl.kt | 6 +- .../validation/BluePrintNodeTypeValidatorImpl.kt | 6 +- .../BluePrintPropertyDefinitionValidatorImpl.kt | 6 +- .../BluePrintServiceTemplateValidatorImpl.kt | 6 +- .../BluePrintTopologyTemplateValidatorImpl.kt | 6 +- .../validation/BluePrintValidatorServiceImpl.kt | 4 +- .../validation/BluePrintWorkflowValidatorImpl.kt | 6 +- .../core/service/BluePrintRepoFileServiceTest.kt | 8 +- .../baseconfiguration/Definitions/data_types.json | 6 +- .../dict/service/ResourceDefinitionRepoService.kt | 10 +- .../service/ResourceDefinitionValidationService.kt | 13 +-- .../service/ResourceDefinitionRepoServiceTest.java | 6 +- 21 files changed, 246 insertions(+), 121 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt new file mode 100644 index 000000000..ea5bda42e --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt @@ -0,0 +1,29 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +class BluePrintError { + var errors: MutableList = arrayListOf() + + fun addError(type: String, name: String, error: String) { + this.errors.add("$type : $name : $error") + } + + fun addError(error: String) { + this.errors.add(error) + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt deleted file mode 100644 index 3ec0691f4..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintValidationError.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -class BluePrintValidationError { - var errors: MutableList = arrayListOf() - - fun addError(type: String, name: String, error: String) { - this.errors.add("$type : $name : $error") - } - - fun addError(error: String) { - this.errors.add(error) - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt new file mode 100644 index 000000000..989617bd3 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -0,0 +1,122 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +interface BluePrintEnhancer { + fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T) +} + +interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer + +interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer + +interface BluePrintWorkflowEnhancer : BluePrintEnhancer + +interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer + +interface BluePrintNodeTypeEnhancer : BluePrintEnhancer + +interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer + +interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer + +interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer + + +interface BluePrintEnhancerService { + + @Throws(BluePrintException::class) + fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext + + @Throws(BluePrintException::class) + fun enhance(basePath: String): BluePrintContext + + @Throws(BluePrintException::class) + fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate +} + +interface BluePrintTypeEnhancerService { + + fun getServiceTemplateEnhancers(): List + + fun getTopologyTemplateEnhancers(): List + + fun getWorkflowEnhancers(): List + + fun getNodeTemplateEnhancers(): List + + fun getNodeTypeEnhancers(): List + + fun getPolicyTypeEnhancers(): List + + fun getPropertyDefinitionEnhancers(): List + + fun getAttributeDefinitionEnhancers(): List + + fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) { + val enhancers = getServiceTemplateEnhancers() + doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers) + } + + fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) { + val enhancers = getTopologyTemplateEnhancers() + doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers) + } + + fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) { + val enhancers = getWorkflowEnhancers() + doEnhancement(bluePrintContext, error, name, workflow, enhancers) + } + + fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) { + val enhancers = getNodeTemplateEnhancers() + doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers) + } + + fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) { + val enhancers = getNodeTypeEnhancers() + doEnhancement(bluePrintContext, error, name, nodeType, enhancers) + } + + fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) { + val enhancers = getPolicyTypeEnhancers() + doEnhancement(bluePrintContext, error, name, policyType, enhancers) + } + + fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { + val enhancers = getPropertyDefinitionEnhancers() + doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers) + } + + fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) { + val enhancers = getAttributeDefinitionEnhancers() + doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers) + } + + private fun doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List>) { + if (enhancers.isNotEmpty()) { + enhancers.forEach { + it.enhance(bluePrintContext, error, name, definition as T) + } + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt index 322f65741..adc94c4c2 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -1,14 +1,14 @@ package org.onap.ccsdk.apps.controllerblueprints.core.interfaces +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext interface BluePrintValidator { - fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: T) + fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T) } @@ -61,64 +61,64 @@ interface BluePrintTypeValidatorService { fun getAttributeDefinitionValidators(): List - fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) { + fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) { val validators = getServiceTemplateValidators() doValidation(bluePrintContext, error, name, serviceTemplate, validators) } - fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) { + fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) { val validators = getArtifactTypeValidators() doValidation(bluePrintContext, error, name, artifactType, validators) } - fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) { + fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) { val validators = getDataTypeValidators() doValidation(bluePrintContext, error, name, dataType, validators) } - fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeType: NodeType) { + fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) { val validators = getNodeTypeValidators() doValidation(bluePrintContext, error, name, nodeType, validators) } - fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) { + fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) { val validators = getTopologyTemplateValidators() doValidation(bluePrintContext, error, name, topologyTemplate, validators) } - fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, nodeTemplate: NodeTemplate) { + fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) { val validators = getNodeTemplateValidators() doValidation(bluePrintContext, error, name, nodeTemplate, validators) } - fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, workflow: Workflow) { + fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) { val validators = getWorkflowValidators() doValidation(bluePrintContext, error, name, workflow, validators) } - fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, properties: MutableMap) { + fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap) { properties.forEach { propertyName, propertyDefinition -> validatePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition) } } - fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) { + fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { val validators = getPropertyDefinitionValidators() doValidation(bluePrintContext, error, name, propertyDefinition, validators) } - fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintValidationError, attributes: MutableMap) { + fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap) { attributes.forEach { attributeName, attributeDefinition -> validateAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition) } } - fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, attributeDefinition: AttributeDefinition) { + fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) { val validators = getAttributeDefinitionValidators() doValidation(bluePrintContext, error, name, attributeDefinition, validators) } - private fun doValidation(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, definition: Any, validators: List>) { + private fun doValidation(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, validators: List>) { validators.forEach { it.validate(bluePrintContext, error, name, definition as T) } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt index dec7a50df..5ca43952d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt @@ -17,13 +17,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils -import reactor.core.publisher.Mono +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import java.io.Serializable /** @@ -35,19 +34,19 @@ import java.io.Serializable interface BluePrintRepoService : Serializable { @Throws(BluePrintException::class) - fun getNodeType(nodeTypeName: String): Mono + fun getNodeType(nodeTypeName: String): NodeType @Throws(BluePrintException::class) - fun getDataType(dataTypeName: String): Mono + fun getDataType(dataTypeName: String): DataType @Throws(BluePrintException::class) - fun getArtifactType(artifactTypeName: String): Mono + fun getArtifactType(artifactTypeName: String): ArtifactType @Throws(BluePrintException::class) - fun getRelationshipType(relationshipTypeName: String): Mono + fun getRelationshipType(relationshipTypeName: String): RelationshipType @Throws(BluePrintException::class) - fun getCapabilityDefinition(capabilityDefinitionName: String): Mono + fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition } @@ -63,36 +62,37 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) private val extension = ".json" - override fun getDataType(dataTypeName: String): Mono { + override fun getDataType(dataTypeName: String): DataType { val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(dataTypeName).plus(extension) return getModelType(fileName, DataType::class.java) } - override fun getNodeType(nodeTypeName: String): Mono { + override fun getNodeType(nodeTypeName: String): NodeType { val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) return getModelType(fileName, NodeType::class.java) } - override fun getArtifactType(artifactTypeName: String): Mono { + override fun getArtifactType(artifactTypeName: String): ArtifactType { val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(artifactTypeName).plus(extension) return getModelType(fileName, ArtifactType::class.java) } - override fun getRelationshipType(relationshipTypeName: String): Mono { + override fun getRelationshipType(relationshipTypeName: String): RelationshipType { val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(relationshipTypeName).plus(extension) return getModelType(fileName, RelationshipType::class.java) } - override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono { + override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) .plus(capabilityDefinitionName).plus(extension) return getModelType(fileName, CapabilityDefinition::class.java) } - private fun getModelType(fileName: String, valueType: Class): Mono { - return JacksonReactorUtils.readValueFromFile(fileName, valueType) + private fun getModelType(fileName: String, valueType: Class): T { + return JacksonUtils.readValueFromFile(fileName, valueType) + ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 40210142c..be23172a7 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -24,12 +24,12 @@ import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.apache.commons.io.FileUtils +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.format import java.io.File import java.nio.charset.Charset @@ -56,19 +56,26 @@ object JacksonUtils { @JvmStatic fun getContent(fileName: String): String { - return File(fileName).readText(Charsets.UTF_8) + return runBlocking { + withContext(Dispatchers.Default) { + File(fileName).readText(Charsets.UTF_8) + } + } } @JvmStatic fun getClassPathFileContent(fileName: String): String { - return IOUtils.toString(JacksonUtils::class.java.classLoader - .getResourceAsStream(fileName), Charset.defaultCharset()) + return runBlocking { + withContext(Dispatchers.Default) { + IOUtils.toString(JacksonUtils::class.java.classLoader + .getResourceAsStream(fileName), Charset.defaultCharset()) + } + } } @JvmStatic fun readValueFromFile(fileName: String, valueType: Class): T? { - val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) - ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + val content: String = getContent(fileName) return readValue(content, valueType) } @@ -89,8 +96,7 @@ object JacksonUtils { @JvmStatic fun jsonNodeFromFile(fileName: String): JsonNode { - val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) - ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + val content: String = getContent(fileName) return jsonNode(content) } @@ -135,8 +141,7 @@ object JacksonUtils { @JvmStatic fun getListFromFile(fileName: String, valueType: Class): List? { - val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) - ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + val content: String = getContent(fileName) return getListFromJson(content, valueType) } @@ -155,8 +160,7 @@ object JacksonUtils { @JvmStatic fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { - val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) - ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + val content: String = getContent(fileName) return getMapFromJson(content, valueType) } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt index 9208bdac3..3fd318548 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -24,7 +24,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator { - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, artifactType: ArtifactType) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) { artifactType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!) } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt index d0faf1c25..98abc1e26 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -24,7 +24,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, type: AttributeDefinition) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) { //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt index c8d8a74d5..1241aa6dc 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -27,7 +27,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString()) - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, dataType: DataType) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) { log.trace("Validating DataType($name)") dataType.properties?.let { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt index 94d6251cc..26a246dd6 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -21,7 +21,7 @@ import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator @@ -36,10 +36,10 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) var bluePrintContext: BluePrintContext? = null - var error: BluePrintValidationError? = null + var error: BluePrintError? = null var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTemplateName: String, nodeTemplate: NodeTemplate) { log.trace("Validating NodeTemplate($nodeTemplateName)") this.bluePrintContext = bluePrintContext this.error = error diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt index 86bf521fa..e15724ae2 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -20,7 +20,7 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator @@ -33,10 +33,10 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) var bluePrintContext: BluePrintContext? = null - var error: BluePrintValidationError? = null + var error: BluePrintError? = null var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, nodeTypeName: String, nodeType: NodeType) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTypeName: String, nodeType: NodeType) { log.trace("Validating NodeType($nodeTypeName)") this.bluePrintContext = bluePrintContext this.error = error diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt index f4804d4c5..f7a1cbf4b 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -20,7 +20,7 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator @@ -32,9 +32,9 @@ open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeVal private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) var bluePrintContext: BluePrintContext? = null - var error: BluePrintValidationError? = null + var error: BluePrintError? = null - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, propertyDefinition: PropertyDefinition) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { this.bluePrintContext = bluePrintContext this.error = error diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt index 66c504dea..848dcc5f8 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -21,7 +21,7 @@ import com.att.eelf.configuration.EELFManager import com.google.common.base.Preconditions import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -32,10 +32,10 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) var bluePrintContext: BluePrintContext? = null - var error: BluePrintValidationError? = null + var error: BluePrintError? = null var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, serviceTemplate: ServiceTemplate) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) { log.trace("Validating Service Template..") try { this.bluePrintContext = bluePrintContext diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt index 411cdb4d3..2783e14ee 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate @@ -33,9 +33,9 @@ open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValid private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) var bluePrintContext: BluePrintContext? = null - var error: BluePrintValidationError? = null + var error: BluePrintError? = null - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, name: String, topologyTemplate: TopologyTemplate) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) { log.trace("Validating Topology Template..") this.bluePrintContext = bluePrintContext this.error = error diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt index 10e8d65bc..4ddf76b2b 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt @@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext @@ -30,7 +30,7 @@ open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorServi private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap): Boolean { - val error = BluePrintValidationError() + val error = BluePrintError() bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate) if (error.errors.size > 0) { throw BluePrintException("failed in blueprint validation : ${error.errors.joinToString("\n")}") diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt index 8ba6f7204..f4434a54a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt @@ -19,7 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintValidationError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator @@ -29,10 +29,10 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) var bluePrintContext: BluePrintContext? = null - var error: BluePrintValidationError? = null + var error: BluePrintError? = null var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintValidationError, workflowName: String, workflow: Workflow) { + override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, workflowName: String, workflow: Workflow) { log.info("Validating Workflow($workflowName)") this.bluePrintContext = bluePrintContext diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index b8cfdd408..f7f995fbb 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -33,25 +33,25 @@ class BluePrintRepoFileServiceTest { @Test fun testGetDataType() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate").block() + val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate") assertNotNull(dataType, "Failed to get DataType from repo") } @Test fun testGetNodeType() { - val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment").block() + val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment") assertNotNull(nodeType, "Failed to get NodeType from repo") } @Test fun testGetArtifactType() { - val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity").block() + val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity") assertNotNull(nodeType, "Failed to get ArtifactType from repo") } @Test(expected = FileNotFoundException::class) fun testModelNotFound() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found").block() + val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found") assertNotNull(dataType, "Failed to get DataType from repo") } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json index 569b668ac..3ea494ac4 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -41,7 +41,7 @@ "type": "string" } }, - "derived_from": "tosca.datatypes.Root" + "derived_from": "tosca.datatypes.Dynamic" }, "resource-assignment-properties": { "description": "This is Dynamically generated data type for workflow activate", @@ -64,7 +64,7 @@ "type": "string" } }, - "derived_from": "tosca.datatypes.Root" + "derived_from": "tosca.datatypes.Dynamic" }, "assign-activate-properties": { "description": "This is Dynamically generated data type for workflow assign-activate", @@ -87,7 +87,7 @@ "type": "string" } }, - "derived_from": "tosca.datatypes.Root" + "derived_from": "tosca.datatypes.Dynamic" } } } \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt index 6d186b598..bcb7e7da7 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt @@ -21,9 +21,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import reactor.core.publisher.Mono /** * ResourceDefinitionRepoService. @@ -33,7 +32,7 @@ import reactor.core.publisher.Mono interface ResourceDefinitionRepoService : BluePrintRepoService { @Throws(BluePrintException::class) - fun getResourceDefinition(resourceDefinitionName: String): Mono + fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition } /** @@ -57,11 +56,12 @@ open class ResourceDefinitionFileRepoService : BluePrintRepoFileService, resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary") } - override fun getResourceDefinition(resourceDefinitionName: String): Mono { + override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition { val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER) .plus(resourceDefinitionName).plus(extension) - return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java) + return JacksonUtils.readValueFromFile(fileName, ResourceDefinition::class.java) + ?: throw BluePrintException("couldn't get resource definition for file($fileName)") } } diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 9f45d1666..9ed077323 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.google.common.base.Preconditions import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -30,8 +31,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpression import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import com.att.eelf.configuration.EELFManager import java.io.Serializable + /** * ResourceDefinitionValidationService. * @@ -43,6 +44,7 @@ interface ResourceDefinitionValidationService : Serializable { fun validate(resourceDefinition: ResourceDefinition) } + /** * ResourceDefinitionValidationService. * @@ -59,8 +61,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS resourceDefinition.sources.forEach { (name, nodeTemplate) -> val sourceType = nodeTemplate.type - val sourceNodeType = bluePrintRepoService.getNodeType(sourceType).block() - ?: throw BluePrintException(format("Failed to get source({}) node type definition({})", name, sourceType)) + val sourceNodeType = bluePrintRepoService.getNodeType(sourceType) // Validate Property Name, expression, values and Data Type validateNodeTemplateProperties(nodeTemplate, sourceNodeType) @@ -91,7 +92,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) { val propertyType = propertyDefinition.type - val isValid : Boolean + val isValid: Boolean if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) @@ -100,9 +101,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) } else { - bluePrintRepoService.getDataType(propertyType).block() - ?: throw BluePrintException(format("property({}) defined of data type({}) is not in repository", - propertyName, propertyType)) + bluePrintRepoService.getDataType(propertyType) isValid = true } diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java index 6789c0e0e..ac8cbcb43 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java @@ -24,13 +24,13 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition public class ResourceDefinitionRepoServiceTest { @Test - public void testGetResourceDefinition() throws Exception{ + public void testGetResourceDefinition() throws Exception { ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog"); ResourceDefinition resourceDefinition = resourceDefinitionRepoService - .getResourceDefinition("db-source").block(); + .getResourceDefinition("db-source"); Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition); - NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db").block(); + NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db"); Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition); } } \ No newline at end of file -- cgit 1.2.3-korg From 5955693557579edc0c936fe35cb060991f0ee77a Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 12 Dec 2018 10:03:26 -0500 Subject: Decompose enhancer to multiple types. Change-Id: I508ce5919680f6e7f994776e58404729b55eace8 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/interfaces/BluePrintEnhancer.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt index 989617bd3..cb835d736 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -102,16 +102,29 @@ interface BluePrintTypeEnhancerService { doEnhancement(bluePrintContext, error, name, policyType, enhancers) } + fun enhancePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap) { + properties.forEach { propertyName, propertyDefinition -> + enhancePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition) + } + } + fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { val enhancers = getPropertyDefinitionEnhancers() doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers) } + fun enhanceAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap) { + attributes.forEach { attributeName, attributeDefinition -> + enhanceAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition) + } + } + fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) { val enhancers = getAttributeDefinitionEnhancers() doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers) } + @Suppress("UNCHECKED_CAST") private fun doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List>) { if (enhancers.isNotEmpty()) { enhancers.forEach { -- cgit 1.2.3-korg From 478a8a7a321556ed01ec757cde3c827ef10690c0 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 12 Dec 2018 16:49:04 -0500 Subject: Add multiple location repo for enhancer. Change-Id: I5333b30fad8d754caf8dc89956132e4637f28c26 Issue-ID: CCSDK-803 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/interfaces/BluePrintRepoService.kt | 47 +++++++++++ .../core/service/BluePrintRepoFileService.kt | 71 ++++++++++++++++ .../core/service/BluePrintRepoService.kt | 98 ---------------------- .../core/service/BluePrintRepoFileServiceTest.kt | 10 +-- .../core/service/BluePrintRuntimeServiceTest.kt | 2 - .../Definitions/activation-blueprint.json | 33 +------- .../baseconfiguration/Definitions/node_types.json | 13 +-- .../starter-type/node_type/dg-generic.json | 11 +++ .../dict/service/ResourceDefinitionRepoService.kt | 67 --------------- .../service/ResourceDefinitionValidationService.kt | 2 +- .../service/ResourceDefinitionRepoServiceTest.java | 36 -------- 11 files changed, 140 insertions(+), 250 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt create mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-generic.json delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt new file mode 100644 index 000000000..efcb0c38b --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt @@ -0,0 +1,47 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import java.io.Serializable + +/** + * BluePrintRepoFileService + * @author Brinda Santh + * + */ + +interface BluePrintRepoService : Serializable { + + @Throws(BluePrintException::class) + fun getNodeType(nodeTypeName: String): NodeType + + @Throws(BluePrintException::class) + fun getDataType(dataTypeName: String): DataType + + @Throws(BluePrintException::class) + fun getArtifactType(artifactTypeName: String): ArtifactType + + @Throws(BluePrintException::class) + fun getRelationshipType(relationshipTypeName: String): RelationshipType + + @Throws(BluePrintException::class) + fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition + +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt new file mode 100644 index 000000000..de338664c --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt @@ -0,0 +1,71 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + +open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) + + private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + private val extension = ".json" + + override fun getDataType(dataTypeName: String): DataType { + val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(dataTypeName).plus(extension) + return getModelType(fileName, DataType::class.java) + } + + override fun getNodeType(nodeTypeName: String): NodeType { + val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) + return getModelType(fileName, NodeType::class.java) + } + + override fun getArtifactType(artifactTypeName: String): ArtifactType { + val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(artifactTypeName).plus(extension) + return getModelType(fileName, ArtifactType::class.java) + } + + override fun getRelationshipType(relationshipTypeName: String): RelationshipType { + val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(relationshipTypeName).plus(extension) + return getModelType(fileName, RelationshipType::class.java) + } + + override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { + val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(capabilityDefinitionName).plus(extension) + return getModelType(fileName, CapabilityDefinition::class.java) + } + + private fun getModelType(fileName: String, valueType: Class): T { + return JacksonUtils.readValueFromFile(fileName, valueType) + ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt deleted file mode 100644 index 5ca43952d..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import java.io.Serializable - -/** - * BluePrintRepoFileService - * @author Brinda Santh - * - */ - -interface BluePrintRepoService : Serializable { - - @Throws(BluePrintException::class) - fun getNodeType(nodeTypeName: String): NodeType - - @Throws(BluePrintException::class) - fun getDataType(dataTypeName: String): DataType - - @Throws(BluePrintException::class) - fun getArtifactType(artifactTypeName: String): ArtifactType - - @Throws(BluePrintException::class) - fun getRelationshipType(relationshipTypeName: String): RelationshipType - - @Throws(BluePrintException::class) - fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition - -} - - -open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) - - private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) - private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) - private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) - private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) - private val extension = ".json" - - override fun getDataType(dataTypeName: String): DataType { - val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(dataTypeName).plus(extension) - return getModelType(fileName, DataType::class.java) - } - - override fun getNodeType(nodeTypeName: String): NodeType { - val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) - return getModelType(fileName, NodeType::class.java) - } - - override fun getArtifactType(artifactTypeName: String): ArtifactType { - val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(artifactTypeName).plus(extension) - return getModelType(fileName, ArtifactType::class.java) - } - - override fun getRelationshipType(relationshipTypeName: String): RelationshipType { - val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(relationshipTypeName).plus(extension) - return getModelType(fileName, RelationshipType::class.java) - } - - override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { - val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(capabilityDefinitionName).plus(extension) - return getModelType(fileName, CapabilityDefinition::class.java) - } - - private fun getModelType(fileName: String, valueType: Class): T { - return JacksonUtils.readValueFromFile(fileName, valueType) - ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index f7f995fbb..f7ffc3940 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -29,29 +29,29 @@ import kotlin.test.assertNotNull class BluePrintRepoFileServiceTest { private val basePath = "load/model_type" - private val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath) + private val bluePrintRepoFileService = BluePrintRepoFileService(basePath) @Test fun testGetDataType() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-v4-aggregate") + val dataType = bluePrintRepoFileService.getDataType("dt-v4-aggregate") assertNotNull(dataType, "Failed to get DataType from repo") } @Test fun testGetNodeType() { - val nodeType = bluePrintEnhancerRepoFileService.getNodeType("component-resource-assignment") + val nodeType = bluePrintRepoFileService.getNodeType("component-resource-assignment") assertNotNull(nodeType, "Failed to get NodeType from repo") } @Test fun testGetArtifactType() { - val nodeType = bluePrintEnhancerRepoFileService.getArtifactType("artifact-template-velocity") + val nodeType = bluePrintRepoFileService.getArtifactType("artifact-template-velocity") assertNotNull(nodeType, "Failed to get ArtifactType from repo") } @Test(expected = FileNotFoundException::class) fun testModelNotFound() { - val dataType = bluePrintEnhancerRepoFileService.getDataType("dt-not-found") + val dataType = bluePrintRepoFileService.getDataType("dt-not-found") assertNotNull(dataType, "Failed to get DataType from repo") } } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 2f519802d..cbcadeb39 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -53,8 +53,6 @@ class BluePrintRuntimeServiceTest { val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") assertNotNull(propContext, "Failed to populate interface property values") - assertEquals(propContext["process-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter process-name") - assertEquals(propContext["version"], jsonNodeFromObject("sample-action"), "Failed to populate parameter version") } @Test diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 446932d54..f756ef7ed 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -39,17 +39,8 @@ }, "node_templates": { "resource-assignment-process": { - "type": "dg-activate", + "type": "dg-generic", "properties": { - "process-name": { - "get_input": "action-name" - }, - "version": { - "get_property": [ - "SELF", - "process-name" - ] - }, "content": { "get_artifact": [ "SELF", @@ -65,17 +56,8 @@ } }, "activate-process": { - "type": "dg-activate", + "type": "dg-generic", "properties": { - "process-name": { - "get_input": "action-name" - }, - "version": { - "get_property": [ - "SELF", - "process-name" - ] - }, "content": { "get_artifact": [ "SELF", @@ -91,17 +73,8 @@ } }, "assign-activate-process": { - "type": "dg-activate", + "type": "dg-generic", "properties": { - "process-name": { - "get_input": "action-name" - }, - "version": { - "get_property": [ - "SELF", - "process-name" - ] - }, "content": { "get_artifact": [ "SELF", diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 6e8d839ee..8227b82f7 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -1,21 +1,12 @@ { "node_types": { - "dg-activate": { + "dg-generic": { "description": "This is Generic Directed Graph Type", "version": "1.0.0", "properties": { "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, + "required": true, "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" } }, "derived_from": "tosca.nodes.DG" diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json b/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json new file mode 100644 index 000000000..6274445ca --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json @@ -0,0 +1,11 @@ +{ + "description": "This is Generic Directed Graph Type", + "version": "1.0.0", + "properties": { + "content": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.nodes.DG" +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt deleted file mode 100644 index bcb7e7da7..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition - -/** - * ResourceDefinitionRepoService. - * - * @author Brinda Santh - */ -interface ResourceDefinitionRepoService : BluePrintRepoService { - - @Throws(BluePrintException::class) - fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition -} - -/** - * ResourceDefinitionFileRepoService. - * - * @author Brinda Santh - */ -open class ResourceDefinitionFileRepoService : BluePrintRepoFileService, - ResourceDefinitionRepoService { - - private var resourceDefinitionPath: String - private val extension = ".json" - - constructor(basePath: String) : this(basePath, - basePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE) - .plus(BluePrintConstants.PATH_DIVIDER) - .plus("starter-type")) - - constructor(basePath: String, modelTypePath: String) : super(modelTypePath) { - resourceDefinitionPath = basePath.plus("/resource-dictionary/starter-dictionary") - } - - override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition { - - val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(resourceDefinitionName).plus(extension) - - return JacksonUtils.readValueFromFile(fileName, ResourceDefinition::class.java) - ?: throw BluePrintException("couldn't get resource definition for file($fileName)") - } -} diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 9ed077323..2c66ff197 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -27,8 +27,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import java.io.Serializable diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java deleted file mode 100644 index ac8cbcb43..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoServiceTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; - -public class ResourceDefinitionRepoServiceTest { - - @Test - public void testGetResourceDefinition() throws Exception { - ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../model-catalog"); - ResourceDefinition resourceDefinition = resourceDefinitionRepoService - .getResourceDefinition("db-source"); - Assert.assertNotNull("Failed to get Resource Definition db-source", resourceDefinition); - - NodeType nodeType = resourceDefinitionRepoService.getNodeType("source-db"); - Assert.assertNotNull("Failed to get Node Type source-db", resourceDefinition); - } -} \ No newline at end of file -- cgit 1.2.3-korg From 2294f097df4a787eaa609cdeab24a6bc6d3b19ee Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Dec 2018 11:34:49 -0500 Subject: Implement Blueprint Workflow Enhancement Change-Id: I64d6e949e9a4bc2100b49fedb3781b04c1c03f43 Issue-ID: CCSDK-722 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/BluePrintConstants.kt | 1 + .../core/interfaces/BluePrintEnhancer.kt | 51 ++++++++++------------ .../core/service/BluePrintRuntimeService.kt | 23 ++++++++-- .../core/utils/BluePrintFileUtils.kt | 32 +++++++++----- .../Definitions/activation-blueprint.json | 41 +++++++++++++---- .../baseconfiguration/Definitions/data_types.json | 27 +----------- .../baseconfiguration/Definitions/node_types.json | 8 ++++ .../Definitions/policy_types.json | 4 ++ .../starter-type/node_type/dg-generic.json | 8 ++++ 9 files changed, 121 insertions(+), 74 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 167496ebc..fd6a8db10 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -55,6 +55,7 @@ object BluePrintConstants { const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" const val PATH_METADATA: String = "metadata" const val PATH_NODE_TYPES: String = "node_types" + const val PATH_POLICY_TYPES: String = "policy_types" const val PATH_ARTIFACT_TYPES: String = "artifact_types" const val PATH_DATA_TYPES: String = "data_types" const val PATH_INPUTS: String = "inputs" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt index cb835d736..f6659e7db 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -16,13 +16,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.interfaces -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService interface BluePrintEnhancer { - fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T) + fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) } interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer @@ -49,9 +49,6 @@ interface BluePrintEnhancerService { @Throws(BluePrintException::class) fun enhance(basePath: String): BluePrintContext - - @Throws(BluePrintException::class) - fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate } interface BluePrintTypeEnhancerService { @@ -72,63 +69,63 @@ interface BluePrintTypeEnhancerService { fun getAttributeDefinitionEnhancers(): List - fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) { + fun enhanceServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { val enhancers = getServiceTemplateEnhancers() - doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers) + doEnhancement(bluePrintRuntimeService, name, serviceTemplate, enhancers) } - fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) { + fun enhanceTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { val enhancers = getTopologyTemplateEnhancers() - doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers) + doEnhancement(bluePrintRuntimeService, name, topologyTemplate, enhancers) } - fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) { + fun enhanceWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { val enhancers = getWorkflowEnhancers() - doEnhancement(bluePrintContext, error, name, workflow, enhancers) + doEnhancement(bluePrintRuntimeService, name, workflow, enhancers) } - fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) { + fun enhanceNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { val enhancers = getNodeTemplateEnhancers() - doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers) + doEnhancement(bluePrintRuntimeService, name, nodeTemplate, enhancers) } - fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) { + fun enhanceNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { val enhancers = getNodeTypeEnhancers() - doEnhancement(bluePrintContext, error, name, nodeType, enhancers) + doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers) } - fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) { + fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) { val enhancers = getPolicyTypeEnhancers() - doEnhancement(bluePrintContext, error, name, policyType, enhancers) + doEnhancement(bluePrintRuntimeService, name, policyType, enhancers) } - fun enhancePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap) { + fun enhancePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap) { properties.forEach { propertyName, propertyDefinition -> - enhancePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition) + enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) } } - fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { + fun enhancePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { val enhancers = getPropertyDefinitionEnhancers() - doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers) + doEnhancement(bluePrintRuntimeService, name, propertyDefinition, enhancers) } - fun enhanceAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap) { + fun enhanceAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap) { attributes.forEach { attributeName, attributeDefinition -> - enhanceAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition) + enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) } } - fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) { + fun enhanceAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { val enhancers = getAttributeDefinitionEnhancers() - doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers) + doEnhancement(bluePrintRuntimeService, name, attributeDefinition, enhancers) } @Suppress("UNCHECKED_CAST") - private fun doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List>) { + private fun doEnhancement(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, enhancers: List>) { if (enhancers.isNotEmpty()) { enhancers.forEach { - it.enhance(bluePrintContext, error, name, definition as T) + it.enhance(bluePrintRuntimeService, name, definition as T) } } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 448a06a86..cf518bd14 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate @@ -55,6 +56,10 @@ interface BluePrintRuntimeService { fun getAsDouble(key: String): Double? + fun getBluePrintError(): BluePrintError + + fun setBluePrintError(bluePrintError: BluePrintError) + /* Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing */ @@ -113,6 +118,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl private var store: MutableMap = hashMapOf() + private var bluePrintError = BluePrintError() + override fun id(): String { return id } @@ -162,9 +169,17 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return get(key).asDouble() } + override fun getBluePrintError(): BluePrintError { + return this.bluePrintError + } + + override fun setBluePrintError(bluePrintError: BluePrintError) { + this.bluePrintError = bluePrintError + } + /* - Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing - */ + Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing + */ override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) val propertyAssignmentValue: MutableMap = hashMapOf() @@ -439,11 +454,11 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl setInputValue(propertyName, property, valueNode) } } - + // Load Dynamic data Types val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName) workflowDynamicInputs?.let { - bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property -> + bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.forEach { propertyName, property -> val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName) ?: NullNode.getInstance() setInputValue(propertyName, property, valueNode) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt index d9222d754..4cb247b5d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -89,25 +89,37 @@ class BluePrintFileUtils { throw BluePrintException("couldn't get definition file under path(${definitionDir.absolutePath})") } - blueprintContext.dataTypes.let { - val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, blueprintContext.dataTypes!!, true) - writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) + blueprintContext.serviceTemplate.dataTypes?.let { + val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it, true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) + } + blueprintContext.serviceTemplate.artifactTypes?.let { + val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it, true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) } - blueprintContext.artifactTypes.let { - val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, blueprintContext.artifactTypes!!, true) - writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) + blueprintContext.serviceTemplate.nodeTypes?.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it, true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) } - blueprintContext.nodeTypes.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, blueprintContext.nodeTypes!!, true) - writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) + blueprintContext.serviceTemplate.policyTypes?.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it, true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent) } + } + fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking { + val definitionFile = File(definitionFile) + + Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE) + check(definitionFile.exists()) { + throw BluePrintException("couldn't write definition file under path(${definitionFile.absolutePath})") + } } - private fun writeFile(definitionPath: String, type: String, content: String) = runBlocking { + private fun writeTypeFile(definitionPath: String, type: String, content: String) = runBlocking { val typeFile = File(definitionPath.plus(File.separator).plus("$type.json")) Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index f756ef7ed..ec229df2d 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -11,11 +11,14 @@ { "file": "Definitions/data_types.json" }, + { + "file": "Definitions/artifact_types.json" + }, { "file": "Definitions/node_types.json" }, { - "file": "Definitions/artifact_types.json" + "file": "Definitions/policy_types.json" } ], "topology_template": { @@ -46,7 +49,10 @@ "SELF", "dg-resource-assignment-process" ] - } + }, + "dependency-node-templates": [ + "resource-assignment" + ] }, "artifacts": { "dg-resource-assignment-process": { @@ -63,7 +69,10 @@ "SELF", "dg-activate-process" ] - } + }, + "dependency-node-templates": [ + "activate-jython" + ] }, "artifacts": { "dg-activate-process": { @@ -80,7 +89,11 @@ "SELF", "dg-assign-activate-process" ] - } + }, + "dependency-node-templates": [ + "resource-assignment", + "activate-jython" + ] }, "artifacts": { "dg-assign-activate-process": { @@ -217,7 +230,7 @@ "inputs": { "resource-assignment-properties": { "required": true, - "type": "resource-assignment-properties" + "type": "dt-resource-assignment-properties" } }, "steps": { @@ -234,9 +247,21 @@ }, "activate": { "inputs": { - "activate-properties": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { "required": true, - "type": "activate-properties" + "type": "string" } }, "steps": { @@ -255,7 +280,7 @@ "inputs": { "assign-activate-properties": { "required": true, - "type": "assign-activate-properties" + "type": "dt-assign-activate-properties" } }, "steps": { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json index 3ea494ac4..7d850f200 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -20,7 +20,7 @@ }, "derived_from": "tosca.datatypes.Root" }, - "activate-properties": { + "dt-resource-assignment-properties": { "description": "This is Dynamically generated data type for workflow activate", "version": "1.0.0", "properties": { @@ -43,30 +43,7 @@ }, "derived_from": "tosca.datatypes.Dynamic" }, - "resource-assignment-properties": { - "description": "This is Dynamically generated data type for workflow activate", - "version": "1.0.0", - "properties": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Dynamic" - }, - "assign-activate-properties": { + "dt-assign-activate-properties": { "description": "This is Dynamically generated data type for workflow assign-activate", "version": "1.0.0", "properties": { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 8227b82f7..8f242efb1 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -7,6 +7,14 @@ "content": { "required": true, "type": "string" + }, + "dependency-node-templates": { + "required": true, + "description": "Dependent Step Components", + "type": "list", + "entry_schema": { + "type": "string" + } } }, "derived_from": "tosca.nodes.DG" diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json new file mode 100644 index 000000000..0c9b99252 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json @@ -0,0 +1,4 @@ +{ + "policy_types": { + } +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json b/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json index 6274445ca..ec9904bf5 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json +++ b/components/model-catalog/definition-type/starter-type/node_type/dg-generic.json @@ -5,6 +5,14 @@ "content": { "required": true, "type": "string" + }, + "dependency-node-templates": { + "required": true, + "description": "Dependent Step Components NodeTemplate name.", + "type": "list", + "entry_schema": { + "type": "string" + } } }, "derived_from": "tosca.nodes.DG" -- cgit 1.2.3-korg From adcbf58a6c6cef14523ed1700e698769769027aa Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Dec 2018 15:10:35 -0500 Subject: Add blueprint runtime service to validator Change-Id: I0e4375e422b55002f1666ee9e61a1469482f77d2 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/interfaces/BlueprintValidator.kt | 59 ++++++++++++---------- .../core/utils/BluePrintFileUtils.kt | 8 +-- .../BluePrintArtifactTypeValidatorImpl.kt | 8 +-- .../BluePrintAttributeDefinitionValidatorImpl.kt | 7 ++- .../validation/BluePrintDataTypeValidatorImpl.kt | 7 ++- .../BluePrintNodeTemplateValidatorImpl.kt | 28 +++++----- .../validation/BluePrintNodeTypeValidatorImpl.kt | 20 ++++---- .../BluePrintPropertyDefinitionValidatorImpl.kt | 17 +++---- .../BluePrintServiceTemplateValidatorImpl.kt | 22 ++++---- .../BluePrintTopologyTemplateValidatorImpl.kt | 17 +++---- .../validation/BluePrintValidatorServiceImpl.kt | 22 +++++--- .../validation/BluePrintWorkflowValidatorImpl.kt | 13 +++-- .../core/service/BluePrintRuntimeServiceTest.kt | 3 +- .../BluePrintValidatorServiceImplTest.kt | 4 +- .../Definitions/activation-blueprint.json | 20 +------- .../baseconfiguration/Definitions/node_types.json | 10 ---- .../node_type/dg-activate-netconf.json | 52 ------------------- .../node_type/dg-config-generator.json | 51 ------------------- .../node_type/dg-resource-assign-activate.json | 56 -------------------- .../node_type/dg-resource-assignment.json | 51 ------------------- .../service/ResourceAssignmentValidationService.kt | 10 ++-- .../service/ResourceDefinitionValidationService.kt | 4 +- .../ResourceAssignmentValidationServiceTest.kt | 6 +-- .../ResourceDefinitionValidationServiceTest.java | 2 +- 24 files changed, 132 insertions(+), 365 deletions(-) delete mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json delete mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json delete mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json delete mode 100644 components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt index adc94c4c2..bea790fd3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -1,14 +1,13 @@ package org.onap.ccsdk.apps.controllerblueprints.core.interfaces -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService interface BluePrintValidator { - fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T) + fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) } @@ -37,7 +36,10 @@ interface BluePrintAttributeDefinitionValidator : BluePrintValidator) : Boolean + fun validateBluePrints(basePath: String): Boolean + + @Throws(BluePrintException::class) + fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean } @@ -61,66 +63,67 @@ interface BluePrintTypeValidatorService { fun getAttributeDefinitionValidators(): List - fun validateServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) { + fun validateServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { val validators = getServiceTemplateValidators() - doValidation(bluePrintContext, error, name, serviceTemplate, validators) + doValidation(bluePrintRuntimeService, name, serviceTemplate, validators) } - fun validateArtifactType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) { + fun validateArtifactType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { val validators = getArtifactTypeValidators() - doValidation(bluePrintContext, error, name, artifactType, validators) + doValidation(bluePrintRuntimeService, name, artifactType, validators) } - fun validateDataType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) { + fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { val validators = getDataTypeValidators() - doValidation(bluePrintContext, error, name, dataType, validators) + doValidation(bluePrintRuntimeService, name, dataType, validators) } - fun validateNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) { + fun validateNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { val validators = getNodeTypeValidators() - doValidation(bluePrintContext, error, name, nodeType, validators) + doValidation(bluePrintRuntimeService, name, nodeType, validators) } - fun validateTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) { + fun validateTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { val validators = getTopologyTemplateValidators() - doValidation(bluePrintContext, error, name, topologyTemplate, validators) + doValidation(bluePrintRuntimeService, name, topologyTemplate, validators) } - fun validateNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) { + fun validateNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { val validators = getNodeTemplateValidators() - doValidation(bluePrintContext, error, name, nodeTemplate, validators) + doValidation(bluePrintRuntimeService, name, nodeTemplate, validators) } - fun validateWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) { + fun validateWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { val validators = getWorkflowValidators() - doValidation(bluePrintContext, error, name, workflow, validators) + doValidation(bluePrintRuntimeService, name, workflow, validators) } - fun validatePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap) { + fun validatePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap) { properties.forEach { propertyName, propertyDefinition -> - validatePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition) + validatePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) } } - fun validatePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { + fun validatePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { val validators = getPropertyDefinitionValidators() - doValidation(bluePrintContext, error, name, propertyDefinition, validators) + doValidation(bluePrintRuntimeService, name, propertyDefinition, validators) } - fun validateAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap) { + fun validateAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap) { attributes.forEach { attributeName, attributeDefinition -> - validateAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition) + validateAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) } } - fun validateAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) { + fun validateAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { val validators = getAttributeDefinitionValidators() - doValidation(bluePrintContext, error, name, attributeDefinition, validators) + doValidation(bluePrintRuntimeService, name, attributeDefinition, validators) } - private fun doValidation(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, validators: List>) { + @Suppress("UNCHECKED_CAST") + private fun doValidation(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, validators: List>) { validators.forEach { - it.validate(bluePrintContext, error, name, definition as T) + it.validate(bluePrintRuntimeService, name, definition as T) } } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt index 4cb247b5d..f9ac87600 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -90,22 +90,22 @@ class BluePrintFileUtils { } blueprintContext.serviceTemplate.dataTypes?.let { - val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it, true) + val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) } blueprintContext.serviceTemplate.artifactTypes?.let { - val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it, true) + val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) } blueprintContext.serviceTemplate.nodeTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it, true) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) } blueprintContext.serviceTemplate.policyTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it, true) + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt index 3fd318548..e383588ee 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt @@ -16,17 +16,17 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator { - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, artifactType: ArtifactType) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { + artifactType.properties?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, artifactType.properties!!) + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, artifactType.properties!!) } // TODO ("Files Present ") } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt index 98abc1e26..53a27b53d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -16,15 +16,14 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { +open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) { //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt index 1241aa6dc..980302bf9 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt @@ -18,21 +18,20 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString()) - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, dataType: DataType) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { log.trace("Validating DataType($name)") dataType.properties?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, dataType.properties!!) + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, dataType.properties!!) } } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt index 26a246dd6..1449e63df 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -21,13 +21,13 @@ import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils @@ -35,14 +35,15 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) - var bluePrintContext: BluePrintContext? = null - var error: BluePrintError? = null + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var bluePrintContext: BluePrintContext var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - log.trace("Validating NodeTemplate($nodeTemplateName)") - this.bluePrintContext = bluePrintContext - this.error = error + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + log.info("Validating NodeTemplate($nodeTemplateName)") + + this.bluePrintRuntimeService = bluePrintRuntimeService + this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() paths.add(nodeTemplateName) @@ -156,7 +157,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator throw BluePrintException("Failed to get relationship type ($relationship) for NodeTemplate($nodeTemplateName)'s requirement($requirementAssignmentName)") } - val relationShipNodeTemplate = bluePrintContext!!.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) + val relationShipNodeTemplate = bluePrintContext.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)") @@ -212,16 +213,15 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)") - log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName, - interfaceAssignmentName, operationAssignmentName) + log.info("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation ($operationAssignmentName)") val inputs = operationAssignments.inputs val outputs = operationAssignments.outputs inputs?.forEach { propertyName, propertyAssignment -> val propertyDefinition = operationDefinition.inputs?.get(propertyName) - ?: throw BluePrintException("Failed to get NodeTemplate(nodeTemplateName) operation " + - "definition (operationAssignmentName) property definition(propertyName)") + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation " + + "definition ($operationAssignmentName) property definition($propertyName)") // Check the property values with property definition validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) } @@ -241,7 +241,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { - val artifactType = bluePrintContext!!.serviceTemplate.artifactTypes?.get(artifactTypeName) + val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) @@ -282,7 +282,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { - val dataType = bluePrintContext!!.serviceTemplate.dataTypes?.get(dataTypeName) + val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName) ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found") checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt index e15724ae2..2e4a733a8 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -20,26 +20,26 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - var bluePrintContext: BluePrintContext? = null - var error: BluePrintError? = null + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var bluePrintContext: BluePrintContext var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, nodeTypeName: String, nodeType: NodeType) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTypeName: String, nodeType: NodeType) { log.trace("Validating NodeType($nodeTypeName)") - this.bluePrintContext = bluePrintContext - this.error = error + this.bluePrintRuntimeService = bluePrintRuntimeService + this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() paths.add(nodeTypeName) @@ -52,7 +52,7 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ ?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)") } - nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext, error, nodeType.properties!!) } + nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) } nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } @@ -111,7 +111,7 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ throw BluePrintException("failed to get relationship($relationship) for NodeType($nodeTypeName)'s requirement($requirementDefinitionName)") } - val relationShipNodeType = bluePrintContext!!.serviceTemplate.nodeTypes?.get(requirementNodeTypeName) + val relationShipNodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(requirementNodeTypeName) ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s for requirement($requirementDefinitionName) ") relationShipNodeType.capabilities?.get(capabilityName) @@ -137,11 +137,11 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } operationDefinition.inputs?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, operationDefinition.inputs!!) + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, operationDefinition.inputs!!) } operationDefinition.outputs?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, operationDefinition.outputs!!) + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, operationDefinition.outputs!!) } paths.removeAt(paths.lastIndex) } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt index f7a1cbf4b..ca156190c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -20,23 +20,22 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - var bluePrintContext: BluePrintContext? = null - var error: BluePrintError? = null + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { + this.bluePrintRuntimeService = bluePrintRuntimeService - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) { - this.bluePrintContext = bluePrintContext - this.error = error log.trace("Validating PropertyDefinition($name)") @@ -66,14 +65,14 @@ open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeVal private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { - val dataType = bluePrintContext!!.serviceTemplate.dataTypes?.get(dataTypeName) + val dataType = bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.get(dataTypeName) ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) } private fun checkDataType(key: String): Boolean { - return bluePrintContext!!.serviceTemplate.dataTypes?.containsKey(key) ?: false + return bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.containsKey(key) ?: false } open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt index 848dcc5f8..61159cf8b 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -25,21 +25,22 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - var bluePrintContext: BluePrintContext? = null - var error: BluePrintError? = null + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var error: BluePrintError + var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { log.trace("Validating Service Template..") try { - this.bluePrintContext = bluePrintContext - this.error = error + this.bluePrintRuntimeService = bluePrintRuntimeService + this.error = bluePrintRuntimeService.getBluePrintError() serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } @@ -47,6 +48,7 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } } catch (e: Exception) { + log.error("failed in blueprint service template validation", e) error.addError(BluePrintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) } } @@ -74,7 +76,7 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida paths.add(BluePrintConstants.PATH_DATA_TYPES) dataTypes.forEach { dataTypeName, dataType -> // Validate Single Data Type - bluePrintTypeValidatorService.validateDataType(bluePrintContext!!, error!!, dataTypeName, dataType) + bluePrintTypeValidatorService.validateDataType(bluePrintRuntimeService, dataTypeName, dataType) } paths.removeAt(paths.lastIndex) } @@ -83,7 +85,7 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida paths.add(BluePrintConstants.PATH_ARTIFACT_TYPES) artifactTypes.forEach { artifactName, artifactType -> // Validate Single Artifact Type - bluePrintTypeValidatorService.validateArtifactType(bluePrintContext!!, error!!, artifactName, artifactType) + bluePrintTypeValidatorService.validateArtifactType(bluePrintRuntimeService, artifactName, artifactType) } paths.removeAt(paths.lastIndex) } @@ -92,14 +94,14 @@ open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValida paths.add(BluePrintConstants.PATH_NODE_TYPES) nodeTypes.forEach { nodeTypeName, nodeType -> // Validate Single Node Type - bluePrintTypeValidatorService.validateNodeType(bluePrintContext!!, error!!, nodeTypeName, nodeType) + bluePrintTypeValidatorService.validateNodeType(bluePrintRuntimeService, nodeTypeName, nodeType) } paths.removeAt(paths.lastIndex) } fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { paths.add(BluePrintConstants.PATH_TOPOLOGY_TEMPLATE) - bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintContext!!, error!!, "topologyTemplate", topologyTemplate) + bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintRuntimeService, "topologyTemplate", topologyTemplate) paths.removeAt(paths.lastIndex) } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt index 2783e14ee..b87666d2d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -19,26 +19,23 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - var bluePrintContext: BluePrintContext? = null - var error: BluePrintError? = null + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { log.trace("Validating Topology Template..") - this.bluePrintContext = bluePrintContext - this.error = error + this.bluePrintRuntimeService = bluePrintRuntimeService // Validate Inputs topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } @@ -50,7 +47,7 @@ open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValid @Throws(BluePrintException::class) fun validateInputs(inputs: MutableMap) { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintContext!!, error!!, inputs) + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, inputs) } @@ -59,7 +56,7 @@ open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValid nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> // Validate Single Node Template - bluePrintTypeValidatorService.validateNodeTemplate(bluePrintContext!!, error!!, nodeTemplateName, nodeTemplate) + bluePrintTypeValidatorService.validateNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeTemplate) } } @@ -68,7 +65,7 @@ open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValid workflows.forEach { workflowName, workflow -> // Validate Single workflow - bluePrintTypeValidatorService.validateWorkflow(bluePrintContext!!, error!!, workflowName, workflow) + bluePrintTypeValidatorService.validateWorkflow(bluePrintRuntimeService, workflowName, workflow) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt index 4ddf76b2b..4f68342eb 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt @@ -19,21 +19,29 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import java.util.* open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) - override fun validateBluePrints(bluePrintContext: BluePrintContext, properties: MutableMap): Boolean { - val error = BluePrintError() - bluePrintTypeValidatorService.validateServiceTemplate(bluePrintContext, error, "default", bluePrintContext.serviceTemplate) - if (error.errors.size > 0) { - throw BluePrintException("failed in blueprint validation : ${error.errors.joinToString("\n")}") + override fun validateBluePrints(basePath: String): Boolean { + + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) + return validateBluePrints(bluePrintRuntimeService) + } + + override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { + + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", + bluePrintRuntimeService.bluePrintContext().serviceTemplate) + if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") } return true } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt index f4434a54a..1a138c3a6 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt @@ -19,24 +19,23 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - var bluePrintContext: BluePrintContext? = null - var error: BluePrintError? = null + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + var paths: MutableList = arrayListOf() - override fun validate(bluePrintContext: BluePrintContext, error: BluePrintError, workflowName: String, workflow: Workflow) { + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, workflowName: String, workflow: Workflow) { log.info("Validating Workflow($workflowName)") - this.bluePrintContext = bluePrintContext - this.error = error + this.bluePrintRuntimeService = bluePrintRuntimeService + paths.add(workflowName) paths.joinToString(BluePrintConstants.PATH_DIVIDER) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index cbcadeb39..7ecf44b69 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -72,8 +72,7 @@ class BluePrintRuntimeServiceTest { assertNotNull(inContext, "Failed to populate interface input property values") assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - assertEquals(inContext["template-content"], jsonNodeFromObject("This is Sample Velocity Template"), "Failed to populate parameter action-name") - } + } @Test fun testResolveNodeTemplateInterfaceOperationOutputs() { diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt index ca238db53..c98f2ac3c 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt @@ -28,13 +28,13 @@ class BluePrintValidatorServiceImplTest { @Test fun testValidateOfType() { - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) - val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintContext, hashMapOf()) + val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime) assertTrue(valid, "failed in blueprint Validation") diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index ec229df2d..7d3a17a68 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -104,9 +104,6 @@ }, "resource-assignment": { "type": "component-resource-assignment", - "properties": { - "request-id": "1234" - }, "interfaces": { "ResourceAssignmentComponent": { "operations": { @@ -124,19 +121,7 @@ }, "artifact-prefix-names": [ "baseconfig" - ], - "template-content": { - "get_artifact": [ - "SELF", - "baseconfig-template" - ] - }, - "mapping-content": { - "get_artifact": [ - "SELF", - "baseconfig-mapping" - ] - } + ] }, "outputs": { "resource-assignment-params": { @@ -164,9 +149,6 @@ }, "resource-assignment-py": { "type": "component-resource-assignment", - "properties": { - "request-id": "1234" - }, "interfaces": { "ResourceAssignmentComponent": { "operations": { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 8f242efb1..7330663c4 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -75,16 +75,6 @@ "entry_schema": { "type": "string" } - }, - "template-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "mapping-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" } }, "outputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json b/components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json deleted file mode 100644 index 57667de98..000000000 --- a/components/model-catalog/definition-type/starter-type/node_type/dg-activate-netconf.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "description": "This is Download Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ActivateNetconf": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json b/components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json deleted file mode 100644 index e59c34b6e..000000000 --- a/components/model-catalog/definition-type/starter-type/node_type/dg-config-generator.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "This is Activate DG for Config Generator Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-config-generator", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "GenerateConfiguration": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json b/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json deleted file mode 100644 index ca703a793..000000000 --- a/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assign-activate.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "description": "This is Resource Assign and Activate Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "ra-component": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - }, - "netconf-component": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignAndActivate": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json deleted file mode 100644 index 9cce82a9e..000000000 --- a/components/model-catalog/definition-type/starter-type/node_type/dg-resource-assignment.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt index fc7f1092d..d71fbbf80 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -18,14 +18,14 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import org.apache.commons.collections.CollectionUtils import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory import java.io.Serializable @@ -41,12 +41,12 @@ interface ResourceAssignmentValidationService : Serializable { } /** - * ResourceAssignmentValidationDefaultService. + * ResourceAssignmentValidationServiceImpl. * * @author Brinda Santh */ -open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValidationService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) +open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceImpl::class.java) open var resourceAssignmentMap: Map = hashMapOf() open val validationMessage = StrBuilder() diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt index 2c66ff197..9541a7b89 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -50,7 +50,7 @@ interface ResourceDefinitionValidationService : Serializable { * * @author Brinda Santh */ -open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { +open class ResourceDefinitionValidationServiceImpl(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java) @@ -58,7 +58,7 @@ open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoS Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition") log.trace("Validating Resource Dictionary Definition {}", resourceDefinition.name) - resourceDefinition.sources.forEach { (name, nodeTemplate) -> + resourceDefinition.sources.forEach { name, nodeTemplate -> val sourceType = nodeTemplate.type val sourceNodeType = bluePrintRepoService.getNodeType(sourceType) diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt index 87ebb700b..191f568f1 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt @@ -43,7 +43,7 @@ class ResourceAssignmentValidationServiceTest { fun testValidateSuccess() { log.info("**************** testValidateSuccess *****************") val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService() + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() val result = resourceAssignmentValidator.validate(assignments!!) Assert.assertTrue("Failed to Validate", result) } @@ -52,7 +52,7 @@ class ResourceAssignmentValidationServiceTest { fun testValidateDuplicate() { log.info(" **************** testValidateDuplicate *****************") val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService() + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() resourceAssignmentValidator.validate(assignments!!) } @@ -60,7 +60,7 @@ class ResourceAssignmentValidationServiceTest { fun testValidateCyclic() { log.info(" **************** testValidateCyclic *****************") val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService() + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() resourceAssignmentValidator.validate(assignments!!) } } \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java index ef305627f..2b68585fa 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java @@ -49,7 +49,7 @@ public class ResourceDefinitionValidationServiceTest { Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition); ResourceDefinitionValidationService resourceDictionaryValidationService = - new ResourceDefinitionDefaultValidationService(bluePrintRepoFileService); + new ResourceDefinitionValidationServiceImpl(bluePrintRepoFileService); resourceDictionaryValidationService.validate(resourceDefinition); Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition); } -- cgit 1.2.3-korg From 6cc20f9e35f95d397d36f79a51f97ba6488b1c99 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 14 Dec 2018 12:30:51 -0500 Subject: Add blueprint artifact definition enrichment. Change-Id: I3b03a1f76472ce6b44929457a42805d281950ff7 Issue-ID: CCSDK-839 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/interfaces/BluePrintEnhancer.kt | 9 +++++++++ .../core/service/BluePrintRuntimeService.kt | 7 +++++++ .../controllerblueprints/core/utils/BluePrintArchiveUtils.kt | 12 ++++++++++++ .../controllerblueprints/core/utils/JacksonReactorUtils.kt | 1 + .../apps/controllerblueprints/core/utils/JacksonUtils.kt | 12 ++++++++---- .../core/validation/BluePrintNodeTemplateValidatorImpl.kt | 2 +- .../core/service/BluePrintRepoFileServiceTest.kt | 4 ++-- .../core/utils/JacksonReactorUtilsTest.kt | 5 +++-- 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt index f6659e7db..f01f12620 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -35,6 +35,8 @@ interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer interface BluePrintNodeTypeEnhancer : BluePrintEnhancer +interface BluePrintArtifactDefinitionEnhancer : BluePrintEnhancer + interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer @@ -63,6 +65,8 @@ interface BluePrintTypeEnhancerService { fun getNodeTypeEnhancers(): List + fun getArtifactDefinitionEnhancers(): List + fun getPolicyTypeEnhancers(): List fun getPropertyDefinitionEnhancers(): List @@ -94,6 +98,11 @@ interface BluePrintTypeEnhancerService { doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers) } + fun enhanceArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) { + val enhancers = getArtifactDefinitionEnhancers() + doEnhancement(bluePrintRuntimeService, name, artifactDefinition, enhancers) + } + fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) { val enhancers = getPolicyTypeEnhancers() doEnhancement(bluePrintRuntimeService, name, policyType, enhancers) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index cf518bd14..5540047c1 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -46,6 +46,8 @@ interface BluePrintRuntimeService { fun get(key: String): JsonNode? + fun check(key: String): Boolean + fun cleanRuntime() fun getAsString(key: String): String? @@ -114,6 +116,7 @@ interface BluePrintRuntimeService { open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) : BluePrintRuntimeService> { + @Transient private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString()) private var store: MutableMap = hashMapOf() @@ -145,6 +148,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)") } + override fun check(key: String): Boolean { + return store.containsKey(key) + } + override fun cleanRuntime() { store.clear() } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt index f02524ffa..c1ab4fc6e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -16,9 +16,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking import org.apache.commons.compress.archivers.zip.ZipArchiveEntry import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.io.IOUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import java.io.* import java.nio.charset.Charset @@ -28,6 +31,15 @@ class BluePrintArchiveUtils { companion object { + fun getFileContent(fileName: String): String = runBlocking { + async { + try { + File(fileName).readText(Charsets.UTF_8) + } catch (e: Exception) { + throw BluePrintException("couldn't find file($fileName)") + } + }.await() + } fun compress(source: String, destination: String, absolute: Boolean): Boolean { val rootDir = File(source) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt index 0ed901702..e3c2a710b 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import reactor.core.publisher.Mono import reactor.core.publisher.toMono +@Deprecated("Reactor will be replaced by coroutines by default") object JacksonReactorUtils { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index be23172a7..01874455a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -25,10 +25,12 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import java.io.File import java.nio.charset.Charset @@ -55,12 +57,14 @@ object JacksonUtils { } @JvmStatic - fun getContent(fileName: String): String { - return runBlocking { - withContext(Dispatchers.Default) { + fun getContent(fileName: String): String = runBlocking { + async { + try { File(fileName).readText(Charsets.UTF_8) + } catch (e: Exception) { + throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") } - } + }.await() } @JvmStatic diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt index 1449e63df..0ed87f813 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -242,7 +242,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") + ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) } diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index f7ffc3940..9348a237e 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -18,7 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service import org.junit.Test -import java.io.FileNotFoundException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import kotlin.test.assertNotNull /** @@ -49,7 +49,7 @@ class BluePrintRepoFileServiceTest { assertNotNull(nodeType, "Failed to get ArtifactType from repo") } - @Test(expected = FileNotFoundException::class) + @Test(expected = BluePrintException::class) fun testModelNotFound() { val dataType = bluePrintRepoFileService.getDataType("dt-not-found") assertNotNull(dataType, "Failed to get DataType from repo") diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt index be76593d8..ad55c7761 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt @@ -19,11 +19,12 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import java.io.FileNotFoundException import kotlin.test.assertEquals import kotlin.test.assertNotNull +@Deprecated("Reactor will be replacecd by coroutines by default.") class JacksonReactorUtilsTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) @Test @@ -43,7 +44,7 @@ class JacksonReactorUtilsTest { assertNotNull(jsonContent, "Failed to get json Node") } - @Test(expected = FileNotFoundException::class) + @Test(expected = BluePrintException::class) fun testReadValuesFailure() { JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json") .block() -- cgit 1.2.3-korg From 8dbad933b82bb9b77ab46ede03f86a6a91c3d89d Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 14 Dec 2018 16:41:37 -0500 Subject: Add blueprint resource definition enrichment. Change-Id: I01234093028ffdc8bf1688e41baba20fae7da5ce Issue-ID: CCSDK-747 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/utils/BluePrintMetadataUtils.kt | 43 ++++++++++++++++++---- .../resource/dict/ResourceDictionaryConstants.kt | 2 + .../resource/dict/utils/ResourceDictionaryUtils.kt | 20 +++++++++- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index 0092b7026..9dbe15ef1 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -64,20 +64,24 @@ object BluePrintMetadataUtils { } @JvmStatic - fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { + fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() - return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(context) + + return bluePrintRuntimeService } @JvmStatic - fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - - val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { + val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) val context: MutableMap = hashMapOf() context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() @@ -96,6 +100,31 @@ object BluePrintMetadataUtils { return bluePrintRuntimeService } + @JvmStatic + fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { + + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + + log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") + + return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) + } + + fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + // Clean Type files + BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) + val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) + val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + + // Clean the Import Definitions + rootServiceTemplate.imports?.clear() + + val blueprintContext = BluePrintContext(rootServiceTemplate) + blueprintContext.rootPath = blueprintBasePath + return blueprintContext + } + @JvmStatic fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index aa6a9fb65..a39139edc 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -31,4 +31,6 @@ object ResourceDictionaryConstants { const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies" + + const val PATH_RESOURCE_DEFINITION_TYPE = "resource_definition_types" } \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt index a3456cd43..1aeda0ba1 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -17,16 +17,20 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.NullNode import org.apache.commons.collections.MapUtils import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants -import com.att.eelf.configuration.EELFManager +import java.io.File object ResourceDictionaryUtils { @@ -49,7 +53,7 @@ object ResourceDictionaryUtils { resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT } log.info("auto map resourceAssignment : {}", resourceAssignment) - }else { + } else { resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT } } @@ -75,4 +79,16 @@ object ResourceDictionaryUtils { context[path] = valueNode } } + + fun getResourceAssignmentFromFile(filePath: String): List { + return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) + ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") + } + + fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map) { + val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json") + val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true) + BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent) + } } \ No newline at end of file -- cgit 1.2.3-korg From 6439b4c86e4161e0c36a58e6deb2f529e64ffd28 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 14 Dec 2018 20:38:44 -0500 Subject: Add multiple path load service. Change-Id: Ib2e5f60663991d097b7446106bb883a45db1bdb8 Issue-ID: CCSDK-746 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/interfaces/BluePrintCatalogService.kt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt new file mode 100644 index 000000000..d07d4daba --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt @@ -0,0 +1,35 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +interface BluePrintCatalogService { + + /** + * Upload the CBA Zip fle to data base and return the Database identifier + */ + fun uploadToDataBase(file: String): String + + /** + * Download the CBA zip file from the data base and place it in a path and return the CBA zip absolute path + */ + fun downloadFromDataBase(name: String, version: String, path: String): String + + /** + * Get the Blueprint from Data Base and Download it under working directory and return the path path + */ + fun prepareBluePrint(name: String, version: String): String +} \ No newline at end of file -- cgit 1.2.3-korg From 61f774846a79bd63ad5e1f8999740b556ef49aa3 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 18 Dec 2018 08:16:28 -0500 Subject: Add attribute definition enhancer. Change-Id: Ie8ac60910f04dfca477d0276aa451821cfcd8510 Issue-ID: CCSDK-718 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/ConfigModelConstant.kt | 8 - .../core/data/BluePrintModel.kt | 12 +- .../core/service/BluePrintContext.kt | 4 + .../core/utils/BluePrintFileUtils.kt | 63 +++++++- .../core/utils/BluePrintMetadataUtils.kt | 165 +++++++++++---------- .../baseconfiguration/Definitions/node_types.json | 5 +- .../Definitions/resources_definition_types.json | 62 ++++++++ .../Definitions/resources_dictionary_types.json | 62 -------- .../node_type/component-resource-assignment.json | 6 + 9 files changed, 231 insertions(+), 156 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt index 8bfa2db7e..5461798de 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt @@ -26,13 +26,5 @@ object ConfigModelConstant { const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON" const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE" - - const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" - - const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" - const val CAPABILITY_PROPERTY_MAPPING = "mapping" - - const val PROPERTY_RECIPE_NAMES = "action-names" - } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 9b6fbbf19..19f09432d 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.data import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonPropertyOrder import com.fasterxml.jackson.databind.JsonNode import io.swagger.annotations.ApiModelProperty @@ -183,12 +184,14 @@ class AttributeDefinition { @get:JsonIgnore var id: String? = null var description: String? = null + var required: Boolean? = null lateinit var type: String @JsonProperty("default") var defaultValue: JsonNode? = null var status: String? = null + var constraints: MutableList? = null @JsonProperty("entry_schema") - var entrySchema: String? = null + var entrySchema: EntrySchema? = null } /* @@ -579,7 +582,8 @@ class ConditionClause { A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document. */ -class ServiceTemplate { +@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"]) +class ServiceTemplate : Cloneable { @get:JsonIgnore var id: String? = null @get:JsonProperty("tosca_definitions_version") @@ -600,6 +604,10 @@ class ServiceTemplate { var policyTypes: MutableMap? = null @get:JsonProperty("topology_template") var topologyTemplate: TopologyTemplate? = null + + override public fun clone(): ServiceTemplate { + return super.clone() as ServiceTemplate + } } class ToscaMetaData { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 84af3f988..bc1f4b437 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -36,6 +36,10 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { * Blueprint CBA extracted file location */ var rootPath = "." + /** + * Root Definition file path + */ + var entryDefinition = "" val imports: List? = serviceTemplate.imports diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt index f9ac87600..67ae39870 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -22,6 +22,8 @@ import kotlinx.coroutines.runBlocking import org.apache.commons.io.FileUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import java.io.File import java.io.FileFilter @@ -79,6 +81,46 @@ class BluePrintFileUtils { } } + fun populateDefaultImports(blueprintContext: BluePrintContext) { + // Get the Default Types + val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_ARTIFACT_TYPES, + BluePrintConstants.PATH_NODE_TYPES, BluePrintConstants.PATH_POLICY_TYPES) + + // Clean Type Imports + cleanImportTypes(blueprintContext.serviceTemplate) + + val imports = mutableListOf() + types.forEach { typeName -> + val import = ImportDefinition() + import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") + imports.add(import) + } + + blueprintContext.serviceTemplate.imports = imports + } + + fun cleanImportTypes(serviceTemplate: ServiceTemplate) { + // Clean the Type imports + val toDeleteTypes = serviceTemplate.imports?.filter { + it.file.endsWith("_types.json") + } + + if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) { + serviceTemplate.imports?.removeAll(toDeleteTypes) + } + } + + fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) { + + // Write Blueprint Types + writeBluePrintTypes(blueprintContext) + // Re Populate the Imports + populateDefaultImports(blueprintContext) + // Rewrite the Entry Definition Files + writeEntryDefinitionFile(blueprintContext) + + } + fun writeBluePrintTypes(blueprintContext: BluePrintContext) { val basePath = blueprintContext.rootPath @@ -110,10 +152,29 @@ class BluePrintFileUtils { } } + fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { + + val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition) + + val serviceTemplate = blueprintContext.serviceTemplate + + // Clone the Service Template + val writeServiceTemplate = serviceTemplate.clone() + writeServiceTemplate.dataTypes = null + writeServiceTemplate.artifactTypes = null + writeServiceTemplate.policyTypes = null + writeServiceTemplate.nodeTypes = null + + // Write the Serivice Template + writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true)) + } + fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking { val definitionFile = File(definitionFile) + // Delete the File If exists + Files.deleteIfExists(definitionFile.toPath()) - Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE) + Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(definitionFile.exists()) { throw BluePrintException("couldn't write definition file under path(${definitionFile.absolutePath})") } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index 9dbe15ef1..5b5561f64 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -31,109 +31,114 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRun import java.io.File import java.nio.charset.Charset -object BluePrintMetadataUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) +class BluePrintMetadataUtils { + companion object { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - @JvmStatic - fun toscaMetaData(basePath: String): ToscaMetaData { - val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus("TOSCA-Metadata/TOSCA.meta") - return toscaMetaDataFromMetaFile(toscaMetaPath) - } - @JvmStatic - fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData { - val toscaMetaData = ToscaMetaData() - val lines: MutableList = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset()) - lines.forEach { line -> - if (line.contains(":")) { - val keyValue = line.split(":") - if (keyValue.size == 2) { - val value: String = keyValue[1].trim() - when (keyValue[0]) { - "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value - "CSAR-Version" -> toscaMetaData.csarVersion = value - "Created-By" -> toscaMetaData.createdBy = value - "Entry-Definitions" -> toscaMetaData.entityDefinitions = value - "Template-Tags" -> toscaMetaData.templateTags = value + fun toscaMetaData(basePath: String): ToscaMetaData { + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + return toscaMetaDataFromMetaFile(toscaMetaPath) + } + + fun entryDefinitionFile(basePath: String): String { + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions + } + + fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData { + val toscaMetaData = ToscaMetaData() + val lines: MutableList = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset()) + lines.forEach { line -> + if (line.contains(":")) { + val keyValue = line.split(":") + if (keyValue.size == 2) { + val value: String = keyValue[1].trim() + when (keyValue[0]) { + "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value + "CSAR-Version" -> toscaMetaData.csarVersion = value + "Created-By" -> toscaMetaData.createdBy = value + "Entry-Definitions" -> toscaMetaData.entityDefinitions = value + "Template-Tags" -> toscaMetaData.templateTags = value + } } } - } + } + return toscaMetaData } - return toscaMetaData - } - @JvmStatic - fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { + fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() - context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.setExecutionContext(context) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(context) - return bluePrintRuntimeService - } + return bluePrintRuntimeService + } - @JvmStatic - fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { + fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() - context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() + val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.setExecutionContext(context) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(context) - return bluePrintRuntimeService - } + return bluePrintRuntimeService + } - @JvmStatic - fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap): BluePrintRuntimeService> { - val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.setExecutionContext(executionContext) - return bluePrintRuntimeService - } + fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap): BluePrintRuntimeService> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(executionContext) + return bluePrintRuntimeService + } - @JvmStatic - fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { + fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { - val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) - log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") + log.info("Reading blueprint path($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") - return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) - } + return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) + } - fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { - val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) - // Clean Type files - BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) - val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) - val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + private fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + // Clean Type files + BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) + val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) + val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) - // Clean the Import Definitions - rootServiceTemplate.imports?.clear() + // Clean the Import Definitions + BluePrintFileUtils.cleanImportTypes(rootServiceTemplate) - val blueprintContext = BluePrintContext(rootServiceTemplate) - blueprintContext.rootPath = blueprintBasePath - return blueprintContext - } + val blueprintContext = BluePrintContext(rootServiceTemplate) + blueprintContext.rootPath = blueprintBasePath + blueprintContext.entryDefinition = toscaMetaData.entityDefinitions + return blueprintContext + } - @JvmStatic - fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { - val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) - val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) - // Recursively Import Template files - val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath) - val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() - val blueprintContext = BluePrintContext(completeServiceTemplate) - blueprintContext.rootPath = basePath - return blueprintContext + private fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { + val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) + val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + // Recursively Import Template files + val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath) + val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() + val blueprintContext = BluePrintContext(completeServiceTemplate) + blueprintContext.rootPath = basePath + blueprintContext.entryDefinition = entityDefinitions + return blueprintContext + } } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 7330663c4..6a156ff16 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -37,9 +37,8 @@ "component-resource-assignment": { "description": "This is Resource Assignment Component API", "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "attributes": { + "assignment-params": { "required": true, "type": "string" } diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json new file mode 100644 index 000000000..557f6efce --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json @@ -0,0 +1,62 @@ +{ + "service-instance-id": { + "name": "service-instance-id", + "tags": "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by": "Singal, Kapil ", + "property": { + "description": "To be provided", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf-id": { + "name": "vnf-id", + "tags": "vnf-id", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf-id", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf_name": { + "name": "vnf_name", + "tags": "vnf_name", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf_name", + "type": "string" + }, + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vnf_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json deleted file mode 100644 index 557f6efce..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "service-instance-id": { - "name": "service-instance-id", - "tags": "service-instance-id, tosca.datatypes.Root, data_type", - "updated-by": "Singal, Kapil ", - "property": { - "description": "To be provided", - "type": "string" - }, - "sources": { - "input": { - "type": "source-input", - "properties": {} - } - } - }, - "vnf-id": { - "name": "vnf-id", - "tags": "vnf-id", - "updated-by": "Singal, Kapil ", - "property": { - "description": "vnf-id", - "type": "string" - }, - "sources": { - "input": { - "type": "source-input", - "properties": {} - } - } - }, - "vnf_name": { - "name": "vnf_name", - "tags": "vnf_name", - "updated-by": "Singal, Kapil ", - "property": { - "description": "vnf_name", - "type": "string" - }, - "sources": { - "mdsal": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "vnf_name": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } - } -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json index 51d70ede9..38fc97d70 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json @@ -1,6 +1,12 @@ { "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" -- cgit 1.2.3-korg From df390dc4cdff621b56f8f00d01c7b021d480cd24 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 20 Dec 2018 11:16:31 -0500 Subject: Add modelType service reactive compatible. Change-Id: I0058a8136fe9ad62781f3d4556d2b95d11507f3f Issue-ID: CCSDK-864 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- components/parent/pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 03656ebd7..1330279e4 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -119,6 +119,11 @@ kotlinx-coroutines-core ${kotlin.couroutines.version} + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + ${kotlin.couroutines.version} + org.jetbrains.kotlin kotlin-reflect @@ -258,6 +263,10 @@ org.jetbrains.kotlinx kotlinx-coroutines-core + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + com.fasterxml.jackson.module jackson-module-kotlin -- cgit 1.2.3-korg From e84581567488cad47892c156996ae4464fd33373 Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Fri, 21 Dec 2018 10:31:48 -0500 Subject: Applied comments from review: Change 74622 - Draft Change-Id: I8ec37a628af98a332f568dc254e499dfdcf886ce Issue-ID: CCSDK-418 Signed-off-by: Steve Alphonse Siani --- .../core/utils/BluePrintFileUtils.kt | 46 +++++++++++++++++++++ .../test-blueprints/CBA_Zip_Test.zip | Bin 0 -> 5382 bytes 2 files changed, 46 insertions(+) mode change 100644 => 100755 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt create mode 100755 components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt old mode 100644 new mode 100755 index 67ae39870..2be9f19ca --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -20,6 +20,7 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import kotlinx.coroutines.runBlocking import org.apache.commons.io.FileUtils +import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition @@ -28,7 +29,16 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext import java.io.File import java.io.FileFilter import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths import java.nio.file.StandardOpenOption +import java.text.MessageFormat +import java.time.Instant +import java.time.temporal.ChronoUnit +import java.time.ZoneId +import java.time.format.DateTimeFormatter + + class BluePrintFileUtils { companion object { @@ -196,6 +206,42 @@ class BluePrintFileUtils { "\nEntry-Definitions: Definitions/.json" + "\nTemplate-Tags: " } + + fun getBluePrintFile(fileName: String, targetPath: Path) : File { + val filePath = targetPath.resolve(fileName).toString() + val file = File(filePath) + check(file.exists()) { + throw BluePrintException("couldn't get definition file under path(${file.absolutePath})") + } + return file + } + + fun getCBAGeneratedFileName(fileName: String, prefix: String): String { + val DATE_FORMAT = "yyyyMMddHHmmss" + val formatter = DateTimeFormatter.ofPattern(DATE_FORMAT) + val datePrefix = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter) + return MessageFormat.format(prefix, datePrefix, fileName) + } + + fun getCbaStorageDirectory(path: String): Path { + check(StringUtils.isNotBlank(path)) { + throw BluePrintException("CBA Path is missing.") + } + + val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize() + + if (!Files.exists(fileStorageLocation)) + Files.createDirectories(fileStorageLocation) + + return fileStorageLocation + } + + fun stripFileExtension(fileName: String): String { + val dotIndexe = fileName.lastIndexOf('.') + + // In case dot is in first position, we are dealing with a hidden file rather than an extension + return if (dotIndexe > 0) fileName.substring(0, dotIndexe) else fileName + } } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip new file mode 100755 index 000000000..77882ef14 Binary files /dev/null and b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip differ -- cgit 1.2.3-korg From b7fee464da925ee6b6146b2eab31512f8b39cd91 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 3 Jan 2019 16:53:40 -0500 Subject: Add Sonar Kotlin support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework parent pom so configuration can be inherited for all modules from root ccsdk-apps/pom.xml. Also updated some pom description so it is better presented within Sonar. These commands can be used locally to publish report to Sonar: mvn clean install -e -Dsonar mvn sonar:sonar -e -Dsonar -Dsonar.host.url=https://sonar.onap.org Note: kotlin code coverage is not fully functional due to https://github.com/jacoco/jacoco/issues/763 That issue has been fixed in jacoco master branch, but hasn't been released. Once released, in version 0.8.3, we can override version of jacoco plugin for ccsdk-apps. Change-Id: Ic382a4d0df9d14a82536993d2dfa55d7f105f951 Issue-ID: CCSDK-725 Signed-off-by: Alexis de Talhouët --- components/parent/pom.xml | 2 +- components/pom.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 1330279e4..2307a0dc1 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -26,7 +26,7 @@ org.onap.ccsdk.apps.components parent - App Components Parent + Components Parent pom 2.1.1.RELEASE diff --git a/components/pom.xml b/components/pom.xml index 181a7810f..6a2aa31d6 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -23,9 +23,8 @@ 0.4.0-SNAPSHOT 4.0.0 - org.onap.ccsdk.apps components - App Components Root + Components Root pom UTF-8 -- cgit 1.2.3-korg From a62d8c91ff858810aeba77d6c925495160b486e4 Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Fri, 28 Dec 2018 14:58:27 -0500 Subject: 1st drop integration with BluePrintCatalogService Change-Id: I0824dcaf0a36e4616c12f3ac53530e6863bee290 Issue-ID: CCSDK-418 Signed-off-by: Steve Alphonse Siani --- .../core/interfaces/BluePrintCatalogService.kt | 7 ++++++- .../core/utils/BluePrintArchiveUtils.kt | 17 +++++++++++++++++ .../core/utils/BluePrintFileUtils.kt | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) mode change 100644 => 100755 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt mode change 100644 => 100755 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt old mode 100644 new mode 100755 index d07d4daba..9186635ee --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt @@ -21,7 +21,7 @@ interface BluePrintCatalogService { /** * Upload the CBA Zip fle to data base and return the Database identifier */ - fun uploadToDataBase(file: String): String + fun uploadToDataBase(file: String, validate : Boolean): String /** * Download the CBA zip file from the data base and place it in a path and return the CBA zip absolute path @@ -32,4 +32,9 @@ interface BluePrintCatalogService { * Get the Blueprint from Data Base and Download it under working directory and return the path path */ fun prepareBluePrint(name: String, version: String): String + + /** + * Get blueprint archive with zip file from Data Base + */ + fun downloadFromDataBase(uuid: String, path: String): String } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt old mode 100644 new mode 100755 index c1ab4fc6e..beb649134 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +22,13 @@ import kotlinx.coroutines.runBlocking import org.apache.commons.compress.archivers.zip.ZipArchiveEntry import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.io.IOUtils +import org.apache.commons.io.filefilter.DirectoryFileFilter import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import reactor.core.publisher.zip import java.io.* import java.nio.charset.Charset +import java.nio.file.Files import java.util.zip.ZipFile class BluePrintArchiveUtils { @@ -139,8 +143,10 @@ class BluePrintArchiveUtils { val entry = enumeration.nextElement() val destFilePath = File(targetPath, entry.name) destFilePath.parentFile.mkdirs() + if (entry.isDirectory) continue + val bufferedIs = BufferedInputStream(zip.getInputStream(entry)) bufferedIs.use { destFilePath.outputStream().buffered(1024).use { bos -> @@ -153,8 +159,19 @@ class BluePrintArchiveUtils { check(destinationDir.isDirectory && destinationDir.exists()) { throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ") } + return destinationDir } + + /** + * Get the first item in directory + * + * @param zipFile + * @return string + */ + fun getFirstItemInDirectory(dir: File): String { + return dir.walk().map { it.name }.elementAt(1) + } } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt index 2be9f19ca..18896f51d 100755 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit 1.2.3-korg From f9a15b74e4dd0bb9262d194483d0ba9aaee713e3 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 7 Jan 2019 16:33:02 -0500 Subject: Add support for blueprintprocessor runtime DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - created db-resources module to store controller blueprint related controller blueprint repository and entities. Also create an abstract BlueprintCatalogServiceImpl so it can be used both by controllerblueprint and blueprintprocessor - created blueprint-validation to store the implementation of the validation interface. - change controllerblueprint service to levrage db-resources - implement CatalogService for blueprintprocessor db-lib by using db-resources. Change-Id: I0539e414e4ff3b7a6edf0f6304d6cbc5e6eac404 Issue-ID: CCSDK-664 Signed-off-by: Alexis de Talhouët --- components/core/pom.xml | 7 ++--- .../core/common/ApplicationConstants.kt | 23 +++++++++++++++ .../core/config/BluePrintLoadConfiguration.kt | 34 ++++++++++++++++++++++ .../core/utils/BluePrintArchiveUtils.kt | 3 -- 4 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt diff --git a/components/core/pom.xml b/components/core/pom.xml index 2e0ab54af..8b6c524d0 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -1,7 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 org.onap.ccsdk.apps.components diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt new file mode 100644 index 000000000..994ea5b7b --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt @@ -0,0 +1,23 @@ +/* + * Copyright © 2019 Bell Canada + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.common + +object ApplicationConstants { + const val ACTIVE_Y = "Y" + const val ACTIVE_N = "N" + const val ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL" +} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt new file mode 100644 index 000000000..235cfd56b --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt @@ -0,0 +1,34 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.config + +open class BluePrintLoadConfiguration { + + lateinit var blueprintDeployPath: String + lateinit var blueprintArchivePath: String + lateinit var blueprintEnrichmentPath: String + + var loadInitialData: Boolean = false + var loadBluePrint: Boolean = false + var loadBluePrintPaths: String? = null + + var loadModelType: Boolean = false + var loadModeTypePaths: String? = null + + var loadResourceDictionary: Boolean = false + var loadResourceDictionaryPaths: String? = null +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt index beb649134..ab5175dea 100755 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -22,13 +22,10 @@ import kotlinx.coroutines.runBlocking import org.apache.commons.compress.archivers.zip.ZipArchiveEntry import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.io.IOUtils -import org.apache.commons.io.filefilter.DirectoryFileFilter import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import reactor.core.publisher.zip import java.io.* import java.nio.charset.Charset -import java.nio.file.Files import java.util.zip.ZipFile class BluePrintArchiveUtils { -- cgit 1.2.3-korg From 980a624d8af8bd0d3993522c52864102e3df2d60 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 8 Jan 2019 14:40:54 -0500 Subject: Prepare for release build Prepare for release of early ODL-Oxygen based CCSDK Dublin Change-Id: I63929ef52de41309905ee31e3fbcf49b64063059 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- components/parent/pom.xml | 3 +- components/pom.xml | 5 +-- components/resource-dict/pom.xml | 93 +++++++++++++++++++--------------------- 3 files changed, 46 insertions(+), 55 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 2307a0dc1..1c49aed33 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -16,8 +16,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps diff --git a/components/pom.xml b/components/pom.xml index 6a2aa31d6..6310c588e 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -14,9 +14,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + org.onap.ccsdk.apps ccsdk-apps @@ -41,4 +39,3 @@ resource-dict - diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml index 517895cb4..0fd2cc504 100644 --- a/components/resource-dict/pom.xml +++ b/components/resource-dict/pom.xml @@ -1,49 +1,44 @@ - - - - - 4.0.0 - - org.onap.ccsdk.apps.components - parent - 0.4.0-SNAPSHOT - ../parent - - org.onap.ccsdk.apps.controllerblueprints - resource-dict - Controller Blueprints Resource Dictionary - - - - org.onap.ccsdk.apps.controllerblueprints - core - - - org.jetbrains.kotlin - kotlin-test-junit - test - - - - - - + + + + 4.0.0 + + org.onap.ccsdk.apps.components + parent + 0.4.0-SNAPSHOT + ../parent + + org.onap.ccsdk.apps.controllerblueprints + resource-dict + Controller Blueprints Resource Dictionary + + + + org.onap.ccsdk.apps.controllerblueprints + core + + + org.jetbrains.kotlin + kotlin-test-junit + test + + + + + -- cgit 1.2.3-korg From 07603763ab93f4ad57587430e96a3bd82b7eab80 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 7 Jan 2019 23:15:01 -0500 Subject: Add Java Capability resource assignment processor Change-Id: I21cea850d8fbe1c9f0a01fdc72f7147a2827ae03 Issue-ID: CCSDK-665 Signed-off-by: Muthuramalingam, Brinda Santh --- .../starter-type/node_type/source-capability.json | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-capability.json diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json new file mode 100644 index 000000000..241b69953 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json @@ -0,0 +1,49 @@ +{ + "description": "This is Component Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "default": "JAVA-COMPONENT", + "constraints": [ + { + "valid_values": [ + "JAVA-COMPONENT", + "JYTHON-COMPONENT" + ] + } + ] + }, + "instance-name": { + "description": "Capability component instance reference name.", + "required": true, + "type": "string" + }, + "input-key-mapping": { + "description": "Context name to input parameters name mapping.", + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "output-key-mapping": { + "description": "Context name to output parameters name mapping.", + "required": false, + "type": "map", + "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" +} \ No newline at end of file -- cgit 1.2.3-korg From 07d02ef8e38763d753dbf412a59c0fa7a6fb80e3 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Tue, 8 Jan 2019 11:17:05 -0500 Subject: Add relationships type files load structure. Change-Id: I1be3ba493956674b476058094e05d681ce358711 Issue-ID: CCSDK-746 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/service/BluePrintExpressionService.kt | 22 ++--- .../core/service/BluePrintRuntimeService.kt | 38 ++++++--- .../core/service/PropertyAssignmentService.kt | 2 +- .../core/service/BluePrintRuntimeServiceTest.kt | 14 +++- .../Definitions/activation-blueprint.json | 51 +++++++++++ .../baseconfiguration/Definitions/node_types.json | 98 ++++++++++++++++++++++ .../node_type/component-netconf-executor.json | 44 ++-------- .../starter-type/node_type/vnf-netconf-device.json | 1 - .../tosca.relationships.ConnectsTo.json | 5 ++ .../tosca.relationships.DependsOn.json | 5 ++ 10 files changed, 214 insertions(+), 66 deletions(-) create mode 100644 components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json create mode 100644 components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt index 6a50680e6..8caec75fd 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -16,15 +16,15 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager /** * @@ -34,12 +34,6 @@ import com.att.eelf.configuration.EELFManager object BluePrintExpressionService { val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - @JvmStatic - fun getExpressionData(propertyAssignment: Any): ExpressionData { - val propertyAssignmentNode: JsonNode = JacksonUtils.jsonNodeFromObject(propertyAssignment) - return getExpressionData(propertyAssignmentNode) - } - @JvmStatic fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData { log.trace("Assignment Data/Expression : {}", propertyAssignmentNode) @@ -53,19 +47,19 @@ object BluePrintExpressionService { expressionData.expressionNode = propertyAssignmentNode when (expressionData.command) { - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT -> { + BluePrintConstants.EXPRESSION_GET_INPUT -> { expressionData.inputExpression = populateInputExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY -> { + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode) } - org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode) } } diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index 5540047c1..bd19ae47e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -67,6 +67,12 @@ interface BluePrintRuntimeService { */ fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap + fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capability: String): MutableMap + + fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap + fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap @@ -193,17 +199,15 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - val propertyAssignments: MutableMap = - nodeTemplate.properties as MutableMap + val propertyAssignments: MutableMap = nodeTemplate.properties!! // Get the Node Type Definitions - val nodeTypeProperties: MutableMap = - bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!! + val nodeTypeProperties: MutableMap = bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!! // Iterate Node Type Properties nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template - val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { @@ -223,6 +227,18 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return propertyAssignmentValue } + override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): + MutableMap { + log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " + + "($capabilityName)") + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap { + log.info("resolveNodeTemplateRequirementProperties for node template($nodeTemplateName) requirement ($requirementName)") + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap { log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " + @@ -230,8 +246,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignmentValue: MutableMap = hashMapOf() - val propertyAssignments: MutableMap = - bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) ?: hashMapOf() val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type @@ -245,7 +261,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl // Iterate Node Type Properties nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template - val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { @@ -275,8 +291,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val propertyAssignmentValue: MutableMap = hashMapOf() - val propertyAssignments: MutableMap = - bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) ?: hashMapOf() val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type @@ -289,7 +305,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template - val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName] + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] var resolvedValue: JsonNode = NullNode.getInstance() if (propertyAssignment != null) { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 36c141f5e..17380fc0f 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -47,7 +47,7 @@ If Property Assignment is Expression. */ fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String, - assignment: Any): JsonNode { + assignment: JsonNode): JsonNode { val valueNode: JsonNode log.trace("Assignment ({})", assignment) val expressionData = BluePrintExpressionService.getExpressionData(assignment) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 7ecf44b69..1dfb89a5d 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -55,6 +55,18 @@ class BluePrintRuntimeServiceTest { assertNotNull(propContext, "Failed to populate interface property values") } + @Test + fun testResolveNodeTemplateCapabilityProperties() { + log.info("************************ testResolveNodeTemplateRequirementProperties **********************") + //TODO + } + + @Test + fun testResolveNodeTemplateRequirementProperties() { + log.info("************************ testResolveNodeTemplateRequirementProperties **********************") + //TODO + } + @Test fun testResolveNodeTemplateInterfaceOperationInputs() { log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") @@ -72,7 +84,7 @@ class BluePrintRuntimeServiceTest { assertNotNull(inContext, "Failed to populate interface input property values") assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - } + } @Test fun testResolveNodeTemplateInterfaceOperationOutputs() { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 7d3a17a68..6a446355f 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -205,6 +205,57 @@ "file": "Scripts/SamplePythonComponentNode.py" } } + }, + "activate-netconf": { + "type": "component-netconf-executor", + "interfaces": { + "NetconfExecutorComponent": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "instance-dependencies": [ + "json-parser-service", + "netconf-rpc-service" + ] + }, + "outputs": { + "response-data": "", + "status": "" + } + } + } + } + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "sample-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-jython", + "file": "Scripts/SamplePythonComponentNode.py" + } + } + }, + "sample-netconf-device": { + "type": "vnf-netconf-device", + "capabilities": { + "netconf": { + "properties": { + "login-key": "sample-key", + "login-account": "sample-account", + "target-ip-address": "localhost", + "port-number": 830, + "connection-time-out": 30 + } + } + } } }, "workflows": { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json index 6a156ff16..f7970bfbd 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json @@ -29,11 +29,68 @@ "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.Vnf" : { + "description" : "This is VNF Node Type", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, "tosca.nodes.component.Jython": { "description": "This is Resource Assignment Jython Component API", "version": "1.0.0", "derived_from": "tosca.nodes.Root" }, + "component-netconf-executor": { + "description": "This is Netconf Transaction Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "vnf-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "NetconfExecutorComponent": { + "operations": { + "process": { + "inputs": { + "instance-dependencies": { + "description": "Instance Names to Inject to Jython Script.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "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.Jython" + }, "component-resource-assignment": { "description": "This is Resource Assignment Component API", "version": "1.0.0", @@ -131,6 +188,47 @@ } }, "derived_from": "tosca.nodes.component.Jython" + }, + "vnf-netconf-device": { + "description": "This is VNF Device with Netconf Capability", + "version": "1.0.0", + "capabilities": { + "netconf": { + "type": "tosca.capabilities.Netconf", + "properties": { + "login-key": { + "required": true, + "type": "string", + "default": "sdnc" + }, + "login-account": { + "required": true, + "type": "string", + "default": "sdnc-tacacs" + }, + "source": { + "required": true, + "type": "string", + "default": "npm" + }, + "target-ip-address": { + "required": true, + "type": "string" + }, + "port-number": { + "required": true, + "type": "integer", + "default": 830 + }, + "connection-time-out": { + "required": false, + "type": "integer", + "default": 30 + } + } + } + }, + "derived_from": "tosca.nodes.Vnf" } } } \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index 7e1d81343..b8ac762e5 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -18,45 +18,13 @@ "operations": { "process": { "inputs": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "instance-dependencies": { "required": true, - "type": "string" - }, - "template-name": { - "description": "Service Template Name", - "required": true, - "type": "string" - }, - "template-version": { - "description": "Service Template Version", - "required": true, - "type": "string" - }, - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-id": { - "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "reservation-id": { - "description": "Reservation Id used to send to NPM", - "required": false, - "type": "string" - }, - "execution-script": { - "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.", - "required": true, - "type": "string" + "description": "Instance Names to Inject to Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } } }, "outputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json index 246f17706..c6f512dfb 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json +++ b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json @@ -38,5 +38,4 @@ } }, "derived_from": "tosca.nodes.Vnf" - } diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json new file mode 100644 index 000000000..4abb94832 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json @@ -0,0 +1,5 @@ +{ + "description": "Relationship tosca.relationships.ConnectsTo", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json new file mode 100644 index 000000000..89987ff51 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json @@ -0,0 +1,5 @@ +{ + "description": "Relationship tosca.relationships.DependsOn", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" +} \ No newline at end of file -- cgit 1.2.3-korg From cb46b4b6df0431ad32e80ec501feecb7037cd6f5 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Tue, 8 Jan 2019 20:59:31 -0500 Subject: Add relationships type enhancement logic. Change-Id: If8f072f49ccc74502052055bce0c90dd43ebd495 Issue-ID: CCSDK-920 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/BluePrintConstants.kt | 6 +- .../core/data/BluePrintModel.kt | 2 + .../core/service/BluePrintImportService.kt | 6 +- .../core/utils/BluePrintFileUtils.kt | 103 +++++++++------------ .../Definitions/activation-blueprint.json | 3 + .../Definitions/relationship_types.json | 9 ++ .../tosca.relationships.AttachesTo.json | 5 + .../tosca.relationships.HostedOn.json | 5 + .../tosca.relationships.RoutesTo.json | 5 + 9 files changed, 80 insertions(+), 64 deletions(-) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json create mode 100644 components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json create mode 100644 components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json create mode 100644 components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index fd6a8db10..102e2ebd3 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -45,17 +45,13 @@ object BluePrintConstants { const val USER_SYSTEM: String = "System" - const val MODEL_CONTENT_TYPE_JSON: String = "JSON" - const val MODEL_CONTENT_TYPE_YAML: String = "YAML" - const val MODEL_CONTENT_TYPE_YANG: String = "YANG" - const val MODEL_CONTENT_TYPE_SCHEMA: String = "SCHEMA" - const val PATH_DIVIDER: String = "/" const val PATH_SERVICE_TEMPLATE: String = "service_template" const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" const val PATH_METADATA: String = "metadata" const val PATH_NODE_TYPES: String = "node_types" const val PATH_POLICY_TYPES: String = "policy_types" + const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" const val PATH_ARTIFACT_TYPES: String = "artifact_types" const val PATH_DATA_TYPES: String = "data_types" const val PATH_INPUTS: String = "inputs" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 19f09432d..9767b2e17 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -598,6 +598,8 @@ class ServiceTemplate : Cloneable { var artifactTypes: MutableMap? = null @get:JsonProperty("data_types") var dataTypes: MutableMap? = null + @get:JsonProperty("relationship_types") + var relationshipTypes: MutableMap? = null @get:JsonProperty("node_types") var nodeTypes: MutableMap? = null @get:JsonProperty("policy_types") diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt index fce06f3f5..26eb19de1 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt @@ -28,11 +28,13 @@ import java.net.URLDecoder import java.nio.charset.Charset class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { + companion object { + private const val PARENT_SERVICE_TEMPLATE: String = "parent" + } private val log: Logger = LoggerFactory.getLogger(this::class.toString()) - val PARENT_SERVICE_TEMPLATE: String = "parent" - var importServiceTemplateMap: MutableMap = hashMapOf() + private var importServiceTemplateMap: MutableMap = hashMapOf() fun getImportResolvedServiceTemplate(): ServiceTemplate { diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt index 18896f51d..5a10e43f4 100755 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -33,12 +33,6 @@ import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardOpenOption -import java.text.MessageFormat -import java.time.Instant -import java.time.temporal.ChronoUnit -import java.time.ZoneId -import java.time.format.DateTimeFormatter - class BluePrintFileUtils { @@ -56,8 +50,9 @@ class BluePrintFileUtils { val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR)) Files.createDirectories(metaDataDir.toPath()) - val metafile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)) - Files.write(metafile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) + val metaFile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants + .TOSCA_METADATA_ENTRY_DEFINITION_FILE)) + Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)) Files.createDirectories(definitionsDir.toPath()) @@ -92,35 +87,6 @@ class BluePrintFileUtils { } } - fun populateDefaultImports(blueprintContext: BluePrintContext) { - // Get the Default Types - val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_ARTIFACT_TYPES, - BluePrintConstants.PATH_NODE_TYPES, BluePrintConstants.PATH_POLICY_TYPES) - - // Clean Type Imports - cleanImportTypes(blueprintContext.serviceTemplate) - - val imports = mutableListOf() - types.forEach { typeName -> - val import = ImportDefinition() - import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") - imports.add(import) - } - - blueprintContext.serviceTemplate.imports = imports - } - - fun cleanImportTypes(serviceTemplate: ServiceTemplate) { - // Clean the Type imports - val toDeleteTypes = serviceTemplate.imports?.filter { - it.file.endsWith("_types.json") - } - - if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) { - serviceTemplate.imports?.removeAll(toDeleteTypes) - } - } - fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) { // Write Blueprint Types @@ -147,6 +113,11 @@ class BluePrintFileUtils { writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) } + blueprintContext.serviceTemplate.relationshipTypes?.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) + } + blueprintContext.serviceTemplate.artifactTypes?.let { val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) @@ -163,7 +134,40 @@ class BluePrintFileUtils { } } - fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { + private fun populateDefaultImports(blueprintContext: BluePrintContext) { + // Get the Default Types + val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES, + BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES, + BluePrintConstants.PATH_POLICY_TYPES) + + // Clean Type Imports + cleanImportTypes(blueprintContext.serviceTemplate) + + val imports = mutableListOf() + types.forEach { typeName -> + val import = ImportDefinition() + import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") + imports.add(import) + } + + blueprintContext.serviceTemplate.imports = imports + } + + fun cleanImportTypes(serviceTemplate: ServiceTemplate) { + // Clean the Type imports + val toDeleteTypes = serviceTemplate.imports?.filter { + it.file.endsWith("_types.json") + } + + if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) { + serviceTemplate.imports?.removeAll(toDeleteTypes) + } + } + + /** + * Re Generate the Blueprint Service Template Definition file based on BluePrint Context. + */ + private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition) @@ -174,14 +178,15 @@ class BluePrintFileUtils { writeServiceTemplate.dataTypes = null writeServiceTemplate.artifactTypes = null writeServiceTemplate.policyTypes = null + writeServiceTemplate.relationshipTypes = null writeServiceTemplate.nodeTypes = null - // Write the Serivice Template + // Write the Service Template writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true)) } - fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking { - val definitionFile = File(definitionFile) + fun writeDefinitionFile(definitionFileName: String, content: String) = runBlocking { + val definitionFile = File(definitionFileName) // Delete the File If exists Files.deleteIfExists(definitionFile.toPath()) @@ -207,22 +212,6 @@ class BluePrintFileUtils { "\nEntry-Definitions: Definitions/.json" + "\nTemplate-Tags: " } - - fun getBluePrintFile(fileName: String, targetPath: Path) : File { - val filePath = targetPath.resolve(fileName).toString() - val file = File(filePath) - check(file.exists()) { - throw BluePrintException("couldn't get definition file under path(${file.absolutePath})") - } - return file - } - - fun getCBAGeneratedFileName(fileName: String, prefix: String): String { - val DATE_FORMAT = "yyyyMMddHHmmss" - val formatter = DateTimeFormatter.ofPattern(DATE_FORMAT) - val datePrefix = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter) - return MessageFormat.format(prefix, datePrefix, fileName) - } fun getCbaStorageDirectory(path: String): Path { check(StringUtils.isNotBlank(path)) { diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index 6a446355f..a3bf546d6 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -11,6 +11,9 @@ { "file": "Definitions/data_types.json" }, + { + "file": "Definitions/relationship_types.json" + }, { "file": "Definitions/artifact_types.json" }, diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json new file mode 100644 index 000000000..87d2dc586 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json @@ -0,0 +1,9 @@ +{ + "relationship_types": { + "tosca.relationships.ConnectsTo": { + "description": "Relationship tosca.relationships.ConnectsTo", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json new file mode 100644 index 000000000..bcfb65eee --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json @@ -0,0 +1,5 @@ +{ + "description": "Relationship tosca.relationships.AttachesTo", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json new file mode 100644 index 000000000..a8337cd15 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json @@ -0,0 +1,5 @@ +{ + "description": "Relationship tosca.relationships.HostedOn", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json new file mode 100644 index 000000000..1da73cdea --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json @@ -0,0 +1,5 @@ +{ + "description": "Relationship tosca.relationships.RoutesTo", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" +} \ No newline at end of file -- cgit 1.2.3-korg From 1770b8f348ef7b4b087012d29496c21cbc169dca Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Wed, 9 Jan 2019 14:34:06 -0500 Subject: Blueprint exception handler and REST responses Change-Id: I5727238cd4c3f3f5475c3f3022e56f1acc0d73bf Issue-ID: CCSDK-418 Signed-off-by: Steve Alphonse Siani Signed-off-by: Balazinski --- .../core/data/BlueprintErrorCode.kt | 97 ++++++++++++++++++++++ .../core/utils/BluePrintFileUtils.kt | 24 +++++- 2 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt new file mode 100644 index 000000000..bef174b9d --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt @@ -0,0 +1,97 @@ +/* + * Copyright © 2018-2019 Bell Canada Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.ccsdk.apps.controllerblueprints.core.data + +import java.util.HashMap + +/** + * ErrorCode.java Purpose: Maintain a list of HTTP status codes + * + * @author Steve Siani + * @version 1.0 + */ +enum class ErrorCode (val value: Int, val httpCode: Int) { + + /// TODO: Add more attribute for each needed application protocol + // TODO: Example: INVALID_FILE_EXTENSION(2, 415, 25) + GENERIC_FAILURE(1, 500) { + override fun message(detailMsg: String): String { + return "Generic failure. Details : {$detailMsg}" + } + }, + INVALID_FILE_EXTENSION(2, 415) { + override fun message(detailMsg: String): String { + return "Unexpected file extension. Details : {$detailMsg}" + } + }, + BLUEPRINT_PATH_MISSING(3, 503) { + override fun message(detailMsg: String): String { + return "Blueprint path missing or wrong. Details : {$detailMsg}" + } + }, + BLUEPRINT_WRITING_FAIL(4, 503) { + override fun message(detailMsg: String): String { + return "Fail to write blueprint files. Details : {$detailMsg}" + } + }, + IO_FILE_INTERRUPT(5, 503) { + override fun message(detailMsg: String): String { + return "IO file system interruption. Details : {$detailMsg}" + } + }, + INVALID_REQUEST_FORMAT(6, 400) { + override fun message(detailMsg: String): String { + return "Bad request. Details : {$detailMsg}" + } + }, + UNAUTHORIZED_REQUEST(7, 401) { + override fun message(detailMsg: String): String { + return "The request requires user authentication. Details : {$detailMsg}" + } + }, + REQUEST_NOT_FOUND(8, 404) { + override fun message(detailMsg: String): String { + return "Request mapping doesn't exist. Details : {$detailMsg}" + } + }, + RESOURCE_NOT_FOUND(9, 404) { + override fun message(detailMsg: String): String { + return "No response was found for this request in the server. Details : {$detailMsg}" + } + }, + CONFLICT_ADDING_RESOURCE(10, 409) { + override fun message(detailMsg: String): String { + return "Duplicated entry while saving Blueprint. Details : {$detailMsg}" + } + }; + + abstract fun message(detailMsg: String): String + + companion object { + + private val map = HashMap() + + init { + for (errorCode in ErrorCode.values()) { + map[errorCode.value] = errorCode + } + } + + fun valueOf(value: Int): ErrorCode? { + return if (map.containsKey(value)) map[value] else map[1] + } + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt index 5a10e43f4..9746bf579 100755 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -24,6 +24,7 @@ import org.apache.commons.io.FileUtils import org.apache.commons.lang3.StringUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ErrorCode import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext @@ -105,7 +106,8 @@ class BluePrintFileUtils { val definitionDir = File(definitionPath) check(definitionDir.exists()) { - throw BluePrintException("couldn't get definition file under path(${definitionDir.absolutePath})") + throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + + "path(${definitionDir.absolutePath})") } blueprintContext.serviceTemplate.dataTypes?.let { @@ -192,7 +194,8 @@ class BluePrintFileUtils { Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(definitionFile.exists()) { - throw BluePrintException("couldn't write definition file under path(${definitionFile.absolutePath})") + throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " + + "path(${definitionFile.absolutePath})") } } @@ -201,7 +204,8 @@ class BluePrintFileUtils { Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) check(typeFile.exists()) { - throw BluePrintException("couldn't write $type.json file under path(${typeFile.absolutePath})") + throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " + + "path(${typeFile.absolutePath})") } } @@ -213,9 +217,21 @@ class BluePrintFileUtils { "\nTemplate-Tags: " } + + fun getBluePrintFile(fileName: String, targetPath: Path) : File { + val filePath = targetPath.resolve(fileName).toString() + val file = File(filePath) + check(file.exists()) { + throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + + "path(${file.absolutePath})") + } + return file + } + fun getCbaStorageDirectory(path: String): Path { check(StringUtils.isNotBlank(path)) { - throw BluePrintException("CBA Path is missing.") + throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " + + "Blueprint folder under path($path)") } val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize() -- cgit 1.2.3-korg From 47a0cd9376cec2b676c844eb7e491eb4b022b3d6 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Wed, 9 Jan 2019 16:57:48 -0500 Subject: Add support for workflow validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, add support for mock in Kotlin using https://mockk.io/ Change-Id: Ia85e1180e09e9d08a02de515b1cc4158c3bccd5c Issue-ID: CCSDK-717 Signed-off-by: Alexis de Talhouët --- components/core/pom.xml | 6 ++ .../core/data/BluePrintModel.kt | 2 +- .../core/service/BluePrintContext.kt | 2 +- .../validation/BluePrintWorkflowValidatorImpl.kt | 28 ++++++++- .../BluePrintValidatorServiceImplTest.kt | 72 +++++++++++++++++++--- components/parent/pom.xml | 11 ++-- 6 files changed, 105 insertions(+), 16 deletions(-) diff --git a/components/core/pom.xml b/components/core/pom.xml index 8b6c524d0..631ee0072 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -52,11 +52,17 @@ org.yaml snakeyaml + org.jetbrains.kotlin kotlin-test-junit test + + io.mockk + mockk + test + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 9767b2e17..663c1fe6c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -502,7 +502,7 @@ class InterfaceAssignment { A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations. */ -class NodeTemplate { +open class NodeTemplate { @get:JsonIgnore var id: String? = null var description: String? = null diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index bc1f4b437..1a6d096d8 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -148,7 +148,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { val nodeTemplates: MutableMap? = serviceTemplate.topologyTemplate?.nodeTemplates fun nodeTemplateByName(name: String): NodeTemplate = - nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name) ") + nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") fun nodeTemplateForNodeType(name: String): MutableMap? { return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt index 1a138c3a6..f55449efa 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt @@ -19,7 +19,10 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService @@ -42,14 +45,35 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ // Step Validation Start paths.add("steps") - workflow.steps?.forEach { stepName, _ -> + workflow.steps?.forEach { stepName, step -> paths.add(stepName) paths.joinToString(BluePrintConstants.PATH_DIVIDER) - // TODO("Step Validation") + + // Validate target + step.target?.let { + try { + val nodeTemplate = bluePrintRuntimeService.bluePrintContext().nodeTemplateByName(it) + + val nodeTypeDerivedFrom = bluePrintRuntimeService.bluePrintContext().nodeTemplateNodeType(it).derivedFrom + + check(nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_DG) { + "NodeType(${nodeTemplate.type}) derived from is '$nodeTypeDerivedFrom', Expected is " + + "'${BluePrintConstants.MODEL_TYPE_NODE_DG}'" + } + } catch (e: Exception) { + bluePrintRuntimeService.getBluePrintError() + .addError("Failed to validate Workflow($workflowName)'s step($stepName)'s " + + "definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) + } + } paths.removeAt(paths.lastIndex) } paths.removeAt(paths.lastIndex) // Step Validation Ends paths.removeAt(paths.lastIndex) + + workflow.inputs?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!) + } } } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt index c98f2ac3c..344b0cca8 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt @@ -16,28 +16,86 @@ package org.onap.ccsdk.apps.controllerblueprints.core.validation +import io.mockk.every +import io.mockk.mockk +import org.junit.Ignore import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.apps.controllerblueprints.core.data.Step +import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import kotlin.test.assertEquals import kotlin.test.assertTrue class BluePrintValidatorServiceImplTest { - val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") - + private val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) + private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() + private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) + private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService) @Test fun testValidateOfType() { - val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) + val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime) + assertTrue(valid, "failed in blueprint Validation") + } + + @Test + fun testValidateWorkflowFailToFoundNodeTemplate() { + val workflowName = "resource-assignment" - val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() + val step = Step() + step.target = "TestCaseFailNoNodeTemplate" + val workflow = Workflow() + workflow.steps = mutableMapOf("test" to step) + workflowValidator.validate(bluePrintRuntime, workflowName, workflow) - val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) + assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size) + assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : could't get node template for the name(TestCaseFailNoNodeTemplate)", bluePrintRuntime.getBluePrintError().errors[0]) + } - val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime) + @Test + fun testValidateWorkflowFailNodeTemplateNotDgGeneric() { + val workflowName = "resource-assignment" + val nodeTemplateName = "resource-assignment-process" - assertTrue(valid, "failed in blueprint Validation") + val nodeTemplate = mockk() + every { nodeTemplate.type } returns "TestNodeType" + val nodeType = mockk() + every { nodeType.derivedFrom } returns "tosca.nodes.TEST" + + val blueprintContext = mockk() + every { blueprintContext.nodeTemplateByName(nodeTemplateName) } returns nodeTemplate + every { blueprintContext.nodeTemplateNodeType(nodeTemplateName) } returns nodeType + + val bluePrintRuntime = mockk("1234") + + every { bluePrintRuntime.getBluePrintError() } returns BluePrintError() + every { bluePrintRuntime.bluePrintContext() } returns blueprintContext + + val step = Step() + step.target = nodeTemplateName + val workflow = Workflow() + workflow.steps = mutableMapOf("test" to step) + workflowValidator.validate(bluePrintRuntime, workflowName, workflow) + + assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size) + assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', Expected is 'tosca.nodes.DG'", bluePrintRuntime.getBluePrintError().errors[0]) } + + @Test + fun testValidateWorkflowSuccess() { + val workflowName = "resource-assignment" + workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName)) + } + } diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 1c49aed33..71e2bec0a 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -16,7 +16,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps @@ -40,7 +41,7 @@ 2.9.2 1.4.197 1.2.2 - 1.7.4 + 1.9 @@ -189,9 +190,9 @@ - org.powermock - powermock-api-mockito2 - ${powermock.version} + io.mockk + mockk + ${mockk.version} test -- cgit 1.2.3-korg From bf19a3a88eac9220051453180614edb4d146a134 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 10 Jan 2019 12:50:06 -0500 Subject: Resource Resoulution Service Implement Input Resource Resolution Processor Service along with Resource Resolution Utilities Change-Id: Ibb4899e415f4b79cd6cd1b190b0f4969b09c3fe4 Issue-ID: CCSDK-936 Signed-off-by: Singal, Kapil (ks220y) --- .../core/utils/JacksonUtils.kt | 364 ++++++++++----------- .../core/service/BluePrintRuntimeServiceTest.kt | 15 +- .../baseconfiguration/Definitions/data_types.json | 12 + .../resource/dict/ResourceDefinitionTest.java | 8 +- .../ResourceDefinitionValidationServiceTest.java | 2 +- .../utils/BulkResourceSequencingUtilsTest.java | 2 +- .../dict/utils/ResourceDictionaryUtilsTest.java | 2 +- 7 files changed, 193 insertions(+), 212 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 01874455a..58a820791 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.onap.ccsdk.apps.controllerblueprints.core.utils import com.att.eelf.configuration.EELFLogger @@ -22,6 +21,9 @@ import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ArrayNode +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import kotlinx.coroutines.Dispatchers @@ -40,241 +42,209 @@ import java.nio.charset.Charset * * @author Brinda Santh */ -object JacksonUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - inline fun readValue(content: String): T = - jacksonObjectMapper().readValue(content, T::class.java) +class JacksonUtils { + companion object { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + inline fun readValue(content: String): T = + jacksonObjectMapper().readValue(content, T::class.java) + + fun readValue(content: String, valueType: Class): T? { + return jacksonObjectMapper().readValue(content, valueType) + } - @JvmStatic - fun readValue(content: String, valueType: Class): T? { - return jacksonObjectMapper().readValue(content, valueType) - } + fun readValue(node: JsonNode, valueType: Class): T? { + return jacksonObjectMapper().treeToValue(node, valueType) + } - @JvmStatic - fun readValue(node: JsonNode, valueType: Class): T? { - return jacksonObjectMapper().treeToValue(node, valueType) - } + fun getContent(fileName: String): String = runBlocking { + async { + try { + File(fileName).readText(Charsets.UTF_8) + } catch (e: Exception) { + throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") + } + }.await() + } - @JvmStatic - fun getContent(fileName: String): String = runBlocking { - async { - try { - File(fileName).readText(Charsets.UTF_8) - } catch (e: Exception) { - throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") + fun getClassPathFileContent(fileName: String): String { + return runBlocking { + withContext(Dispatchers.Default) { + IOUtils.toString(JacksonUtils::class.java.classLoader + .getResourceAsStream(fileName), Charset.defaultCharset()) + } } - }.await() - } + } - @JvmStatic - fun getClassPathFileContent(fileName: String): String { - return runBlocking { - withContext(Dispatchers.Default) { - IOUtils.toString(JacksonUtils::class.java.classLoader - .getResourceAsStream(fileName), Charset.defaultCharset()) - } + fun readValueFromFile(fileName: String, valueType: Class): T? { + val content: String = getContent(fileName) + return readValue(content, valueType) } - } - @JvmStatic - fun readValueFromFile(fileName: String, valueType: Class): T? { - val content: String = getContent(fileName) - return readValue(content, valueType) - } + fun readValueFromClassPathFile(fileName: String, valueType: Class): T? { + val content: String = getClassPathFileContent(fileName) + return readValue(content, valueType) + } - @JvmStatic - fun readValueFromClassPathFile(fileName: String, valueType: Class): T? { - val content: String = getClassPathFileContent(fileName) - return readValue(content, valueType) - } + fun jsonNodeFromObject(from: kotlin.Any): JsonNode { + return jacksonObjectMapper().convertValue(from, JsonNode::class.java) + } - @JvmStatic - fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java) + fun jsonNodeFromClassPathFile(fileName: String): JsonNode { + val content: String = getClassPathFileContent(fileName) + return jsonNode(content) + } - @JvmStatic - fun jsonNodeFromClassPathFile(fileName: String): JsonNode { - val content: String = getClassPathFileContent(fileName) - return jsonNode(content) - } + fun jsonNodeFromFile(fileName: String): JsonNode { + val content: String = getContent(fileName) + return jsonNode(content) + } - @JvmStatic - fun jsonNodeFromFile(fileName: String): JsonNode { - val content: String = getContent(fileName) - return jsonNode(content) - } + fun jsonNode(content: String): JsonNode { + return jacksonObjectMapper().readTree(content) + } - @JvmStatic - fun jsonNode(content: String): JsonNode { - return jacksonObjectMapper().readTree(content) - } + fun getJson(any: kotlin.Any): String { + return getJson(any, false) + } - @JvmStatic - fun getJson(any: kotlin.Any): String { - return getJson(any, false) - } + fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String { + val wrapperMap = hashMapOf() + wrapperMap[wrapper] = any + return getJson(wrapperMap, pretty) + } - @JvmStatic - fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String { - val wrapperMap = hashMapOf() - wrapperMap[wrapper] = any - return getJson(wrapperMap, pretty) - } + fun getJson(any: kotlin.Any, pretty: Boolean = false): String { + val objectMapper = jacksonObjectMapper() + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + if (pretty) { + objectMapper.enable(SerializationFeature.INDENT_OUTPUT) + } + return objectMapper.writeValueAsString(any) + } - @JvmStatic - fun getJson(any: kotlin.Any, pretty: Boolean = false): String { - val objectMapper = jacksonObjectMapper() - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) - if (pretty) { - objectMapper.enable(SerializationFeature.INDENT_OUTPUT) + fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode { + val objectMapper = jacksonObjectMapper() + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + if (pretty) { + objectMapper.enable(SerializationFeature.INDENT_OUTPUT) + } + return objectMapper.valueToTree(any) } - return objectMapper.writeValueAsString(any) - } - @JvmStatic - fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { - return getListFromJson(node.toString(), valueType) - } + fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + return getListFromJson(node.toString(), valueType) + } - @JvmStatic - fun getListFromJson(content: String, valueType: Class): List? { - val objectMapper = jacksonObjectMapper() - val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) - return objectMapper.readValue>(content, javaType) - } + fun getListFromJson(content: String, valueType: Class): List? { + val objectMapper = jacksonObjectMapper() + val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) + return objectMapper.readValue>(content, javaType) + } - @JvmStatic - fun getListFromFile(fileName: String, valueType: Class): List? { - val content: String = getContent(fileName) - return getListFromJson(content, valueType) - } + fun getListFromFile(fileName: String, valueType: Class): List? { + val content: String = getContent(fileName) + return getListFromJson(content, valueType) + } - @JvmStatic - fun getListFromClassPathFile(fileName: String, valueType: Class): List? { - val content: String = getClassPathFileContent(fileName) - return getListFromJson(content, valueType) - } + fun getListFromClassPathFile(fileName: String, valueType: Class): List? { + val content: String = getClassPathFileContent(fileName) + return getListFromJson(content, valueType) + } - @JvmStatic - fun getMapFromJson(content: String, valueType: Class): MutableMap? { - val objectMapper = jacksonObjectMapper() - val typeRef = object : TypeReference>() {} - return objectMapper.readValue(content, typeRef) - } + fun getMapFromJson(content: String, valueType: Class): MutableMap? { + val objectMapper = jacksonObjectMapper() + val typeRef = object : TypeReference>() {} + return objectMapper.readValue(content, typeRef) + } - @JvmStatic - fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { - val content: String = getContent(fileName) - return getMapFromJson(content, valueType) - } + fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { + val content: String = getContent(fileName) + return getMapFromJson(content, valueType) + } - @JvmStatic - fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { - if (BluePrintTypes.validPrimitiveTypes().contains(type)) { - return checkJsonNodeValueOfPrimitiveType(type, jsonNode) - } else if (BluePrintTypes.validCollectionTypes().contains(type)) { - return checkJsonNodeValueOfCollectionType(type, jsonNode) + fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + return checkJsonNodeValueOfPrimitiveType(type, jsonNode) + } else if (BluePrintTypes.validCollectionTypes().contains(type)) { + return checkJsonNodeValueOfCollectionType(type, jsonNode) + } + return false } - return false - } - @JvmStatic - fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { - when (primitiveType) { - BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual - BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean - BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt - BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble - BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual - else -> return false + fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { + when (primitiveType) { + BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual + BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean + BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt + BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble + BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual + else -> return false + } } - } - @JvmStatic - fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { - when (type) { - BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray - BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode - else -> return false + fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { + when (type) { + BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray + BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode + else -> return false + } } - } -/* - @JvmStatic - fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) { - if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { - objectNode.put(key, value as Boolean) - } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { - objectNode.put(key, value as Int) - } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { - objectNode.put(key, value as Float) - } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) { - objectNode.put(key, value as String) - } else { - objectNode.put(key, value as String) + fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) { + when (primitiveType) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean) + BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int) + BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float) + BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String) + else -> objectNode.put(key, value as String) + } } - } - @JvmStatic - fun populatePrimitiveValues(value: Any, primitiveType: String, objectNode: ArrayNode) { - if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { - objectNode.add(value as Boolean) - } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { - objectNode.add(value as Int) - } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { - objectNode.add(value as Float) - } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == primitiveType) { - objectNode.add(value as String) - } else { - objectNode.add(value as String) + fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) { + when (primitiveType) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean) + BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int) + BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float) + BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String) + else -> arrayNode.add(value as String) + } } - } - @JvmStatic - fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { - if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { - objectNode.put(key, false) - } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { - objectNode.put(key, 0) - } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { - objectNode.put(key, 0.0) - } else { - objectNode.put(key, "") + fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { + when (primitiveType) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false) + BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0) + BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0) + else -> objectNode.put(key, "") + } } - } - @JvmStatic - fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { - if (BluePrintConstants.DATA_TYPE_BOOLEAN == primitiveType) { - arrayNode.add(false) - } else if (BluePrintConstants.DATA_TYPE_INTEGER == primitiveType) { - arrayNode.add(0) - } else if (BluePrintConstants.DATA_TYPE_FLOAT == primitiveType) { - arrayNode.add(0.0) - } else { - arrayNode.add("") + fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { + when (primitiveType) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false) + BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0) + BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0) + else -> arrayNode.add("") + } } - } - @JvmStatic - fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { - if (nodeValue == null || nodeValue is NullNode) { - objectNode.set(key, nodeValue) - } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { - if (BluePrintConstants.DATA_TYPE_BOOLEAN == type) { - objectNode.put(key, nodeValue.asBoolean()) - } else if (BluePrintConstants.DATA_TYPE_INTEGER == type) { - objectNode.put(key, nodeValue.asInt()) - } else if (BluePrintConstants.DATA_TYPE_FLOAT == type) { - objectNode.put(key, nodeValue.floatValue()) - } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP == type) { - objectNode.put(key, nodeValue.asText()) + fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { + if (nodeValue == null || nodeValue is NullNode) { + objectNode.set(key, nodeValue) + } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + populatePrimitiveValues(key, nodeValue, type, objectNode) } else { - objectNode.put(key, nodeValue.asText()) + objectNode.set(key, nodeValue) + } + } + + fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? { + when (type) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean) + BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int) + BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float) + else -> return JacksonUtils.getJsonNode(value) } - } else { - objectNode.set(key, nodeValue) } } - */ } \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index 1dfb89a5d..c01b14b31 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -26,8 +26,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromFile -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils.jsonNodeFromObject +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -47,7 +46,7 @@ class BluePrintRuntimeServiceTest { val inputDataPath = "src/test/resources/data/default-context.json" - val inputNode: JsonNode = jsonNodeFromFile(inputDataPath) + val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath) bluePrintRuntimeService.assignInputs(inputNode) val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") @@ -82,9 +81,9 @@ class BluePrintRuntimeServiceTest { "ResourceAssignmentComponent", "process") assertNotNull(inContext, "Failed to populate interface input property values") - assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") - assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - } + assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") + assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name") + } @Test fun testResolveNodeTemplateInterfaceOperationOutputs() { @@ -113,9 +112,9 @@ class BluePrintRuntimeServiceTest { val bluePrintRuntimeService = getBluePrintRuntimeService() bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1", - jsonNodeFromObject("context1-value")) + JacksonUtils.jsonNodeFromObject("context1-value")) bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2", - jsonNodeFromObject("context2-value")) + JacksonUtils.jsonNodeFromObject("context2-value")) val keys = listOf("context1", "context2") diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json index 7d850f200..6d771cd68 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json @@ -28,6 +28,14 @@ "required": true, "type": "string" }, + "service-instance-id": { + "required": true, + "type": "string" + }, + "vnf-id": { + "required": true, + "type": "string" + }, "action-name": { "required": true, "type": "string" @@ -39,6 +47,10 @@ "hostname": { "required": true, "type": "string" + }, + "vnf_name": { + "required": true, + "type": "string" } }, "derived_from": "tosca.datatypes.Dynamic" diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java index fde800057..cb39200f3 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -31,7 +31,7 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionInputSource(){ String fileName = basePath + "/input-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); } @@ -39,7 +39,7 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionDefaultSource(){ String fileName = basePath + "/default-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); } @@ -47,14 +47,14 @@ public class ResourceDefinitionTest { public void testDictionaryDefinitionDBSource(){ String fileName = basePath + "/db-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition); } @Test public void testDictionaryDefinitionMDSALSource(){ String fileName = basePath + "/mdsal-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); } } diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java index 2b68585fa..f5c3567fa 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java @@ -45,7 +45,7 @@ public class ResourceDefinitionValidationServiceTest { private void testValidate(String fileName) throws Exception { - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile(fileName, ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition); ResourceDefinitionValidationService resourceDictionaryValidationService = diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java index c7444dbae..a2c2310be 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java @@ -30,7 +30,7 @@ public class BulkResourceSequencingUtilsTest { @Test public void testProcess(){ - List assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); + List assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); BulkResourceSequencingUtils.process(assignments); } diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index 13bf8195e..fa2413805 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -86,7 +86,7 @@ public class ResourceDictionaryUtilsTest { @Test public void testAssignInputs() { - JsonNode data = JacksonUtils.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); + JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); Map context = new HashMap<>(); ResourceDictionaryUtils.assignInputs(data, context); String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue"); -- cgit 1.2.3-korg From 32e90cd22a5e2fb21ca369102dfa063f2db9e93f Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Fri, 11 Jan 2019 13:58:38 -0500 Subject: Resource Resolution Service : 2 Changes for Primary-DB Resource Resolution Processor Service Change-Id: Iaf6ad6277d36787d87881819ae530de1d7038a2e Issue-ID: CCSDK-942 Signed-off-by: Singal, Kapil (ks220y) --- .../core/BluePrintConstants.kt | 342 ++++++++++----------- .../resources/dictionary/dictionary_schema.json | 4 +- .../vFW/Definitions/vFW_spinup.json | 82 ++--- .../starter-dictionary/db-source.json | 24 -- .../starter-dictionary/nf-role.json | 4 +- .../starter-dictionary/nfc-naming-code.json | 4 +- .../starter-dictionary/onap_private_net_cidr.json | 4 +- .../starter-dictionary/primary-db-source.json | 24 ++ .../starter-dictionary/private-prefix-id.json | 4 +- .../starter-dictionary/protected-prefix-id.json | 4 +- .../protected_private_net_cidr.json | 4 +- .../starter-dictionary/sample-db-source.json | 24 -- .../sample-primary-db-source.json | 24 ++ .../starter-dictionary/unprotected-prefix-id.json | 4 +- .../unprotected_private_net_cidr.json | 4 +- .../starter-dictionary/vf-module-label.json | 4 +- .../starter-dictionary/vf-module-type.json | 4 +- .../starter-dictionary/vf-naming-policy.json | 4 +- .../starter-dictionary/vf-nf-code.json | 4 +- .../starter-dictionary/vfccustomizationuuid.json | 4 +- .../starter-dictionary/vm-type.json | 4 +- .../vnfc-model-invariant-uuid.json | 4 +- .../starter-dictionary/vnfc-model-version.json | 4 +- .../load/model_type/node_type/source-db.json | 44 --- .../model_type/node_type/source-primary-db.json | 44 +++ .../load/resource_dictionary/db-source.json | 24 -- .../load/resource_dictionary/nf-role.json | 4 +- .../load/resource_dictionary/nfc-naming-code.json | 4 +- .../resource_dictionary/onap_private_net_cidr.json | 4 +- .../resource_dictionary/primary-db-source.json | 24 ++ .../resource_dictionary/private-prefix-id.json | 4 +- .../resource_dictionary/protected-prefix-id.json | 4 +- .../protected_private_net_cidr.json | 4 +- .../resource_dictionary/unprotected-prefix-id.json | 4 +- .../unprotected_private_net_cidr.json | 4 +- .../load/resource_dictionary/vf-module-label.json | 4 +- .../load/resource_dictionary/vf-module-type.json | 4 +- .../load/resource_dictionary/vf-naming-policy.json | 4 +- .../load/resource_dictionary/vf-nf-code.json | 4 +- .../resource_dictionary/vfccustomizationuuid.json | 4 +- .../load/resource_dictionary/vm-type.json | 4 +- .../vnfc-model-invariant-uuid.json | 4 +- .../resource_dictionary/vnfc-model-version.json | 4 +- .../resource/dict/ResourceDictionaryConstants.kt | 2 +- .../resource/dict/utils/ResourceAssignmentUtils.kt | 156 ++++++++++ .../dict/utils/ResourceDictionaryTestUtils.kt | 30 -- .../resource/dict/ResourceDefinitionTest.java | 4 +- .../factory/ResourceSourceMappingFactoryTest.java | 6 +- .../ResourceDefinitionValidationServiceTest.java | 4 +- .../dict/utils/ResourceDictionaryTestUtils.kt | 30 ++ .../src/test/resources/validation/cyclic.json | 2 +- .../src/test/resources/validation/duplicate.json | 2 +- .../src/test/resources/validation/success.json | 2 +- 53 files changed, 591 insertions(+), 435 deletions(-) delete mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/db-source.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json delete mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json create mode 100644 components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json delete mode 100644 components/resource-dict/load/model_type/node_type/source-db.json create mode 100644 components/resource-dict/load/model_type/node_type/source-primary-db.json delete mode 100644 components/resource-dict/load/resource_dictionary/db-source.json create mode 100644 components/resource-dict/load/resource_dictionary/primary-db-source.json create mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt create mode 100644 components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 102e2ebd3..4c2d6e2fc 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -1,172 +1,172 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -/** - * BluePrintConstants - * - * @author Brinda Santh - */ -object BluePrintConstants { - - const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" - const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" - const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" - const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" - - const val STATUS_SUCCESS: String = "success" - const val STATUS_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" - - const val DATA_TYPE_STRING: String = "string" - const val DATA_TYPE_INTEGER: String = "integer" - const val DATA_TYPE_FLOAT: String = "float" - const val DATA_TYPE_BOOLEAN: String = "boolean" - const val DATA_TYPE_TIMESTAMP: String = "timestamp" - const val DATA_TYPE_NULL: String = "null" - const val DATA_TYPE_LIST: String = "list" - const val DATA_TYPE_MAP: String = "map" - - const val USER_SYSTEM: String = "System" - - const val PATH_DIVIDER: String = "/" - const val PATH_SERVICE_TEMPLATE: String = "service_template" - const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" - const val PATH_METADATA: String = "metadata" - const val PATH_NODE_TYPES: String = "node_types" - const val PATH_POLICY_TYPES: String = "policy_types" - const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" - const val PATH_ARTIFACT_TYPES: String = "artifact_types" - const val PATH_DATA_TYPES: String = "data_types" - const val PATH_INPUTS: String = "inputs" - const val PATH_NODE_WORKFLOWS: String = "workflows" - const val PATH_NODE_TEMPLATES: String = "node_templates" - const val PATH_CAPABILITIES: String = "capabilities" - const val PATH_REQUIREMENTS: String = "requirements" - const val PATH_INTERFACES: String = "interfaces" - const val PATH_OPERATIONS: String = "operations" - const val PATH_OUTPUTS: String = "outputs" - const val PATH_PROPERTIES: String = "properties" - const val PATH_ATTRIBUTES: String = "attributes" - const val PATH_ARTIFACTS: String = "artifacts" - - const val MODEL_DIR_MODEL_TYPE: String = "definition-type" - - const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" - const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" - const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" - const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" - const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" - - const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" - const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" - const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" - const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" - const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" - const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" - const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" - - const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" - const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" - const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" - const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" - const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" - - const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" - const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" - const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" - @Deprecated("Artifacts will be attached to Node Template") - const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" - const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" - - const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" - const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" - const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" - const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" - const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" - const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" - - const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" - - const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" - - const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" - const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" - const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" - const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" - const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" - const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" - const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" - // Custom capabilities - const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" - const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" - const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" - const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" - const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" - - const val EXPRESSION_GET_INPUT: String = "get_input" - const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" - const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" - const val EXPRESSION_GET_PROPERTY: String = "get_property" - const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" - const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" - - const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" - const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" - const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" - const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" - const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" - const val PROPERTY_BLUEPRINT_NAME: String = "template_name" - const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" - - const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" - const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" - const val TOSCA_DEFINITIONS_DIR: String = "Definitions" - const val TOSCA_PLANS_DIR: String = "Plans" - const val TOSCA_SCRIPTS_DIR: String = "Scripts" - const val TOSCA_MAPPINGS_DIR: String = "Mappings" - const val TOSCA_TEMPLATES_DIR: String = "Templates" - - const val METADATA_USER_GROUPS = "user-groups" - const val METADATA_TEMPLATE_NAME = "template_name" - const val METADATA_TEMPLATE_VERSION = "template_version" - const val METADATA_TEMPLATE_AUTHOR = "template_author" - const val METADATA_TEMPLATE_TAGS = "template_tags" - const val METADATA_WORKFLOW_NAME = "workflow_name" - - const val PAYLOAD_DATA = "payload-data" - const val PROPERTY_CURRENT_STEP = "current-step" - const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" - const val PROPERTY_CURRENT_INTERFACE = "current-interface" - const val PROPERTY_CURRENT_OPERATION = "current-operation" - const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" - const val PROPERTY_EXECUTION_REQUEST = "execution-request" - - const val OPERATION_PROCESS = "process" - const val OPERATION_PREPARE = "prepare" - - const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" - const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" - const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" - +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +/** + * BluePrintConstants + * + * @author Brinda Santh + */ +object BluePrintConstants { + + const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" + const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" + const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + + const val STATUS_SUCCESS: String = "success" + const val STATUS_FAILURE: String = "failure" + + const val TYPE_DEFAULT: String = "default" + + const val DATA_TYPE_STRING: String = "string" + const val DATA_TYPE_INTEGER: String = "integer" + const val DATA_TYPE_FLOAT: String = "float" + const val DATA_TYPE_BOOLEAN: String = "boolean" + const val DATA_TYPE_TIMESTAMP: String = "timestamp" + const val DATA_TYPE_NULL: String = "null" + const val DATA_TYPE_LIST: String = "list" + const val DATA_TYPE_MAP: String = "map" + + const val USER_SYSTEM: String = "System" + + const val PATH_DIVIDER: String = "/" + const val PATH_SERVICE_TEMPLATE: String = "service_template" + const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" + const val PATH_METADATA: String = "metadata" + const val PATH_NODE_TYPES: String = "node_types" + const val PATH_POLICY_TYPES: String = "policy_types" + const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" + const val PATH_ARTIFACT_TYPES: String = "artifact_types" + const val PATH_DATA_TYPES: String = "data_types" + const val PATH_INPUTS: String = "inputs" + const val PATH_NODE_WORKFLOWS: String = "workflows" + const val PATH_NODE_TEMPLATES: String = "node_templates" + const val PATH_CAPABILITIES: String = "capabilities" + const val PATH_REQUIREMENTS: String = "requirements" + const val PATH_INTERFACES: String = "interfaces" + const val PATH_OPERATIONS: String = "operations" + const val PATH_OUTPUTS: String = "outputs" + const val PATH_PROPERTIES: String = "properties" + const val PATH_ATTRIBUTES: String = "attributes" + const val PATH_ARTIFACTS: String = "artifacts" + + const val MODEL_DIR_MODEL_TYPE: String = "definition-type" + + const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" + const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" + const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" + const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" + const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" + + const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" + const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" + const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" + const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" + const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" + const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" + const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" + + const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" + const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" + const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" + const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" + const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" + + const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" + const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" + const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" + @Deprecated("Artifacts will be attached to Node Template") + const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" + const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" + + const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" + const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" + const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" + const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" + const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" + const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" + + const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" + + const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" + + const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" + const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" + const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" + const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" + const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" + const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" + const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" + // Custom capabilities + const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" + const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" + const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" + const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" + const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" + + const val EXPRESSION_GET_INPUT: String = "get_input" + const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" + const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" + const val EXPRESSION_GET_PROPERTY: String = "get_property" + const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" + const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" + + const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" + const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" + const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" + const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" + const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" + const val PROPERTY_BLUEPRINT_NAME: String = "template_name" + const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" + + const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" + const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" + const val TOSCA_DEFINITIONS_DIR: String = "Definitions" + const val TOSCA_PLANS_DIR: String = "Plans" + const val TOSCA_SCRIPTS_DIR: String = "Scripts" + const val TOSCA_MAPPINGS_DIR: String = "Mappings" + const val TOSCA_TEMPLATES_DIR: String = "Templates" + + const val METADATA_USER_GROUPS = "user-groups" + const val METADATA_TEMPLATE_NAME = "template_name" + const val METADATA_TEMPLATE_VERSION = "template_version" + const val METADATA_TEMPLATE_AUTHOR = "template_author" + const val METADATA_TEMPLATE_TAGS = "template_tags" + const val METADATA_WORKFLOW_NAME = "workflow_name" + + const val PAYLOAD_DATA = "payload-data" + const val PROPERTY_CURRENT_STEP = "current-step" + const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" + const val PROPERTY_CURRENT_INTERFACE = "current-interface" + const val PROPERTY_CURRENT_OPERATION = "current-operation" + const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" + const val PROPERTY_EXECUTION_REQUEST = "execution-request" + + const val OPERATION_PROCESS = "process" + const val OPERATION_PREPARE = "prepare" + + const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" + const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" + const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" + } \ No newline at end of file diff --git a/components/core/src/test/resources/dictionary/dictionary_schema.json b/components/core/src/test/resources/dictionary/dictionary_schema.json index d03170050..f9ef9eeed 100644 --- a/components/core/src/test/resources/dictionary/dictionary_schema.json +++ b/components/core/src/test/resources/dictionary/dictionary_schema.json @@ -104,7 +104,7 @@ } } }, - "db": { + "primary-db": { "type": "object", "properties": { "query": { @@ -210,7 +210,7 @@ } } }, - "db": { + "primary-db": { "type": "object", "properties": { "names": { diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json index 1137c1d58..13847bbb4 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json @@ -411,7 +411,7 @@ }, "input-param": false, "dictionary-name": "nf-role", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vnf-model-customization-uuid" ], @@ -531,7 +531,7 @@ }, "input-param": false, "dictionary-name": "protected-prefix-id", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -555,7 +555,7 @@ }, "input-param": false, "dictionary-name": "unprotected-prefix-id", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -579,7 +579,7 @@ }, "input-param": false, "dictionary-name": "vf-nf-code", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vnf-model-customization-uuid" ], @@ -740,7 +740,7 @@ }, "input-param": false, "dictionary-name": "vf-module-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -788,7 +788,7 @@ }, "input-param": false, "dictionary-name": "vfccustomizationuuid", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -836,7 +836,7 @@ }, "input-param": false, "dictionary-name": "vm-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -860,7 +860,7 @@ }, "input-param": false, "dictionary-name": "vnfc-model-invariant-uuid", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -884,7 +884,7 @@ }, "input-param": false, "dictionary-name": "vnfc-model-version", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -933,7 +933,7 @@ }, "input-param": false, "dictionary-name": "nfc-naming-code", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -1107,7 +1107,7 @@ }, "input-param": false, "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -1131,7 +1131,7 @@ }, "input-param": false, "dictionary-name": "protected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -1205,7 +1205,7 @@ }, "input-param": false, "dictionary-name": "onap_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -1302,7 +1302,7 @@ }, "input-param": false, "dictionary-name": "vf-module-label", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -1326,7 +1326,7 @@ }, "input-param": false, "dictionary-name": "private-prefix-id", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -1535,7 +1535,7 @@ }, "input-param": false, "dictionary-name": "vf-module-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -1583,7 +1583,7 @@ }, "input-param": false, "dictionary-name": "vfccustomizationuuid", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -1631,7 +1631,7 @@ }, "input-param": false, "dictionary-name": "vm-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -1655,7 +1655,7 @@ }, "input-param": false, "dictionary-name": "vnfc-model-invariant-uuid", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -1679,7 +1679,7 @@ }, "input-param": false, "dictionary-name": "vnfc-model-version", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -1728,7 +1728,7 @@ }, "input-param": false, "dictionary-name": "nfc-naming-code", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -1902,7 +1902,7 @@ }, "input-param": false, "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -1926,7 +1926,7 @@ }, "input-param": false, "dictionary-name": "onap_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -2148,7 +2148,7 @@ }, "input-param": false, "dictionary-name": "vf-module-label", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -2172,7 +2172,7 @@ }, "input-param": false, "dictionary-name": "private-prefix-id", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -2357,7 +2357,7 @@ }, "input-param": false, "dictionary-name": "vf-module-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -2405,7 +2405,7 @@ }, "input-param": false, "dictionary-name": "vfccustomizationuuid", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -2453,7 +2453,7 @@ }, "input-param": false, "dictionary-name": "vm-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -2477,7 +2477,7 @@ }, "input-param": false, "dictionary-name": "vnfc-model-invariant-uuid", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -2501,7 +2501,7 @@ }, "input-param": false, "dictionary-name": "vnfc-model-version", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -2550,7 +2550,7 @@ }, "input-param": false, "dictionary-name": "nfc-naming-code", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vfccustomizationuuid" ], @@ -2725,7 +2725,7 @@ }, "input-param": false, "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -2749,7 +2749,7 @@ }, "input-param": false, "dictionary-name": "protected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -2773,7 +2773,7 @@ }, "input-param": false, "dictionary-name": "onap_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -2946,7 +2946,7 @@ }, "input-param": false, "dictionary-name": "vf-module-label", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -2970,7 +2970,7 @@ }, "input-param": false, "dictionary-name": "private-prefix-id", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -3018,7 +3018,7 @@ }, "input-param": false, "dictionary-name": "protected-prefix-id", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -3082,7 +3082,7 @@ }, "input-param": false, "dictionary-name": "vf-module-type", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vf-module-model-customization-uuid" ], @@ -3226,7 +3226,7 @@ }, "input-param": false, "dictionary-name": "nf-role", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "vnf-model-customization-uuid" ], @@ -3275,7 +3275,7 @@ }, "input-param": false, "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], @@ -3299,7 +3299,7 @@ }, "input-param": false, "dictionary-name": "protected_private_net_cidr", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ ], diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json deleted file mode 100755 index de46524ce..000000000 --- a/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "db-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "bundle-id, brindasanth@onap.com", - "sources": { - "db": { - "type": "source-db", - "properties": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - } - } - } - } -} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json b/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json index 819c7e602..6da5ea22f 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/nf-role.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json b/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json index b82791877..4e1ba2b0a 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/nfc-naming-code.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json index cee060153..42765ee94 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_cidr.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private\"", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json new file mode 100644 index 000000000..26e62e85d --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/primary-db-source.json @@ -0,0 +1,24 @@ +{ + "name": "primary-db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "bundle-id, brindasanth@onap.com", + "sources": { + "primary-db": { + "type": "source-primary-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json index 5dea3e316..0685401d3 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/private-prefix-id.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private\"", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json index fb572741c..f6120f3fd 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected-prefix-id.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"protected\"", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json index 261920feb..bb477dcb6 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/protected_private_net_cidr.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"protected\"", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json deleted file mode 100644 index 90775aee0..000000000 --- a/components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "sample-db-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "db-source, brindasanth@onap.com", - "sources": { - "db": { - "type": "source-db", - "properties": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - } - } - } - } -} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json new file mode 100644 index 000000000..656841f2e --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json @@ -0,0 +1,24 @@ +{ + "name": "sample-db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "primary-db-source, brindasanth@onap.com", + "sources": { + "primary-db": { + "type": "source-primary-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json index 3cb732056..c1fc541bd 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected-prefix-id.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"unprotected\"", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json index d2a339e7c..604875500 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/unprotected_private_net_cidr.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"unprotected\"", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json index ac5e21a6a..faa7ea49e 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-label.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json index 147425c33..dbd51bbd9 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-module-type.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json index f68cc3746..70792f86f 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-naming-policy.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json b/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json index 1865d47ff..a21982c0c 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vf-nf-code.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json index 463f8480b..9f3e7cf17 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfccustomizationuuid.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json b/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json index 0204c64bb..9744316c0 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vm-type.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select VFC_MODEL.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json index c894fb531..3d89d9dd2 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-invariant-uuid.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select VFC_MODEL.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json index 45eb07f79..d7fb50169 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnfc-model-version.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select VFC_MODEL.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/resource-dict/load/model_type/node_type/source-db.json b/components/resource-dict/load/model_type/node_type/source-db.json deleted file mode 100644 index 661a9503b..000000000 --- a/components/resource-dict/load/model_type/node_type/source-db.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "description": "This is Database Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": true, - "type": "string", - "constraints": [ - { - "valid_values": [ - "SQL", - "PLSQL" - ] - } - ] - }, - "query": { - "required": true, - "type": "string" - }, - "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" -} \ No newline at end of file diff --git a/components/resource-dict/load/model_type/node_type/source-primary-db.json b/components/resource-dict/load/model_type/node_type/source-primary-db.json new file mode 100644 index 000000000..661a9503b --- /dev/null +++ b/components/resource-dict/load/model_type/node_type/source-primary-db.json @@ -0,0 +1,44 @@ +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "query": { + "required": true, + "type": "string" + }, + "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" +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/db-source.json b/components/resource-dict/load/resource_dictionary/db-source.json deleted file mode 100644 index b96dc63f7..000000000 --- a/components/resource-dict/load/resource_dictionary/db-source.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "db-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "bundle-id, brindasanth@onap.com", - "sources": { - "db": { - "type": "source-db", - "properties": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - } - } - } - } -} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/nf-role.json b/components/resource-dict/load/resource_dictionary/nf-role.json index 0e108c5cb..df6b5df4d 100644 --- a/components/resource-dict/load/resource_dictionary/nf-role.json +++ b/components/resource-dict/load/resource_dictionary/nf-role.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid", diff --git a/components/resource-dict/load/resource_dictionary/nfc-naming-code.json b/components/resource-dict/load/resource_dictionary/nfc-naming-code.json index f0f2b7f0f..7c521a7c0 100644 --- a/components/resource-dict/load/resource_dictionary/nfc-naming-code.json +++ b/components/resource-dict/load/resource_dictionary/nfc-naming-code.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json index 07c5cbc18..f2067a19c 100644 --- a/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json +++ b/components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = private", diff --git a/components/resource-dict/load/resource_dictionary/primary-db-source.json b/components/resource-dict/load/resource_dictionary/primary-db-source.json new file mode 100644 index 000000000..dfac66aee --- /dev/null +++ b/components/resource-dict/load/resource_dictionary/primary-db-source.json @@ -0,0 +1,24 @@ +{ + "name": "primary-db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "bundle-id, brindasanth@onap.com", + "sources": { + "primary-db": { + "type": "source-primary-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/components/resource-dict/load/resource_dictionary/private-prefix-id.json b/components/resource-dict/load/resource_dictionary/private-prefix-id.json index a95bae308..309647d79 100644 --- a/components/resource-dict/load/resource_dictionary/private-prefix-id.json +++ b/components/resource-dict/load/resource_dictionary/private-prefix-id.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = private", diff --git a/components/resource-dict/load/resource_dictionary/protected-prefix-id.json b/components/resource-dict/load/resource_dictionary/protected-prefix-id.json index 56b0d6d21..816405b4e 100644 --- a/components/resource-dict/load/resource_dictionary/protected-prefix-id.json +++ b/components/resource-dict/load/resource_dictionary/protected-prefix-id.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = protected", diff --git a/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json index db0a43dc5..bf46fb3a6 100644 --- a/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json +++ b/components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = protected", diff --git a/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json b/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json index a0d966a2c..8a09b1498 100644 --- a/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json +++ b/components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = unprotected", diff --git a/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json b/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json index 8f9385d87..241147c3f 100644 --- a/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json +++ b/components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = unprotected", diff --git a/components/resource-dict/load/resource_dictionary/vf-module-label.json b/components/resource-dict/load/resource_dictionary/vf-module-label.json index a9543722c..01355c201 100644 --- a/components/resource-dict/load/resource_dictionary/vf-module-label.json +++ b/components/resource-dict/load/resource_dictionary/vf-module-label.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", diff --git a/components/resource-dict/load/resource_dictionary/vf-module-type.json b/components/resource-dict/load/resource_dictionary/vf-module-type.json index 805d834b5..ead69d46a 100644 --- a/components/resource-dict/load/resource_dictionary/vf-module-type.json +++ b/components/resource-dict/load/resource_dictionary/vf-module-type.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", diff --git a/components/resource-dict/load/resource_dictionary/vf-naming-policy.json b/components/resource-dict/load/resource_dictionary/vf-naming-policy.json index ceed3186c..cde861f8a 100644 --- a/components/resource-dict/load/resource_dictionary/vf-naming-policy.json +++ b/components/resource-dict/load/resource_dictionary/vf-naming-policy.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", diff --git a/components/resource-dict/load/resource_dictionary/vf-nf-code.json b/components/resource-dict/load/resource_dictionary/vf-nf-code.json index 0d25d0e94..adbd22af8 100644 --- a/components/resource-dict/load/resource_dictionary/vf-nf-code.json +++ b/components/resource-dict/load/resource_dictionary/vf-nf-code.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid", diff --git a/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json b/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json index a34a9a783..b3485791a 100644 --- a/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json +++ b/components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", diff --git a/components/resource-dict/load/resource_dictionary/vm-type.json b/components/resource-dict/load/resource_dictionary/vm-type.json index 7bb5ef1cc..e559f9b55 100644 --- a/components/resource-dict/load/resource_dictionary/vm-type.json +++ b/components/resource-dict/load/resource_dictionary/vm-type.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select vfc_model.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json b/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json index b2ccd45da..9eb94cffc 100644 --- a/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json +++ b/components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select vfc_model.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/resource-dict/load/resource_dictionary/vnfc-model-version.json b/components/resource-dict/load/resource_dictionary/vnfc-model-version.json index fb59eea7f..e4e662291 100644 --- a/components/resource-dict/load/resource_dictionary/vnfc-model-version.json +++ b/components/resource-dict/load/resource_dictionary/vnfc-model-version.json @@ -7,8 +7,8 @@ "type" : "string" }, "sources" : { - "db" : { - "type" : "source-db", + "primary-db" : { + "type" : "source-primary-db", "properties" : { "type" : "SQL", "query" : "select vfc_model.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index a39139edc..e4219c139 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -23,7 +23,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict object ResourceDictionaryConstants { const val SOURCE_INPUT = "input" const val SOURCE_DEFAULT = "default" - const val SOURCE_DB = "db" + const val SOURCE_DB = "primary-db" const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt new file mode 100644 index 000000000..a234a89ee --- /dev/null +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt @@ -0,0 +1,156 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils + +import java.util.Date +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.controllerblueprints.core.* +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment + +class ResourceAssignmentUtils { + companion object { + + private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString()) + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) { + + val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" } + checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment") + + if (checkNotEmpty(resourceAssignment.dictionaryName)) { + resourceAssignment.dictionaryName = resourceAssignment.name + logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})") + } + + try { + if (checkNotEmpty(resourceProp.type)) { + val convertedValue = convertResourceValue(resourceProp.type, value) + logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})") + resourceProp.value = convertedValue + resourceAssignment.updatedDate = Date() + resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM + resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS + } + } catch (e: Exception) { + throw BluePrintProcessorException("Failed in setting value for template key (%s) and " + + "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e) + } + } + + private fun convertResourceValue(type: String, value: Any?): JsonNode? { + var convertedValue: JsonNode? + + if (value == null || value is NullNode) { + logger.info("Returning {} value from convertResourceValue", value) + return null + } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) { + convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value) + } else { + // Case where Resource is non-primitive type + if (value is String) { + convertedValue = JacksonUtils.jsonNode(value) + } else { + convertedValue = JacksonUtils.getJsonNode(value) + } + } + return convertedValue + } + + @Synchronized + fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) { + if (checkNotEmpty(resourceAssignment.name)) { + resourceAssignment.updatedDate = Date() + resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM + resourceAssignment.status = BluePrintConstants.STATUS_FAILURE + resourceAssignment.message = message + } + } + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) { + val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" } + if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) { + logger.error("failed to populate mandatory resource mapping ($resourceAssignment)") + throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)") + } + } + + @Synchronized + @Throws(BluePrintProcessorException::class) + fun generateResourceDataForAssignments(assignments: List): String { + var result = "{}" + try { + val mapper = ObjectMapper() + val root = mapper.readTree(result) + + assignments.forEach { + if (checkNotEmpty(it.name) && it.property != null) { + + val type = it.property?.type + val value = it.property?.value + logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type, + value) + if (value == null) { + (root as ObjectNode).set(it.name, null) + } else if (value is JsonNode) { + (root as ObjectNode).put(it.name, value as JsonNode) + } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as String) + } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as Boolean) + } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as Int) + } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as Float) + } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) { + (root as ObjectNode).put(it.name, value as String) + } else { + val jsonNode = JacksonUtils.getJsonNode(value) + if (jsonNode != null) { + (root as ObjectNode).put(it.name, jsonNode) + } else { + (root as ObjectNode).set(it.name, null) + } + } + } + } + result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root) + logger.info("Generated Resource Param Data ({})", result) + } catch (e: Exception) { + throw BluePrintProcessorException("kapil is failing with $e.message", e) + } + + return result + } + + fun transformResourceSource(properties: MutableMap, classType: Class): T { + val content = JacksonUtils.getJson(properties) + return JacksonUtils.readValue(content, classType) + ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)") + } + + } +} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt deleted file mode 100644 index bebe27d8c..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory - -object ResourceDictionaryTestUtils { - - @JvmStatic - fun setUpResourceSourceMapping() { - ResourceSourceMappingFactory.registerSourceMapping("db", "source-db") - ResourceSourceMappingFactory.registerSourceMapping("input", "source-input") - ResourceSourceMappingFactory.registerSourceMapping("default", "source-default") - ResourceSourceMappingFactory.registerSourceMapping("mdsal", "source-rest") - } -} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java index cb39200f3..1ed306e21 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -46,9 +46,9 @@ public class ResourceDefinitionTest { @Test public void testDictionaryDefinitionDBSource(){ - String fileName = basePath + "/db-source.json"; + String fileName = basePath + "/primary-db-source.json"; ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", resourceDefinition); + Assert.assertNotNull("Failed to populate dictionaryDefinition for primary-db type", resourceDefinition); } @Test diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java index b67aa7998..3f5aef43d 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java @@ -25,13 +25,13 @@ public class ResourceSourceMappingFactoryTest { @Test public void testRegisterResourceMapping() { - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db"); ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); - String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("db"); - Assert.notNull(nodeTypeName, "Failed to get db mapping"); + String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db"); + Assert.notNull(nodeTypeName, "Failed to get primary-db mapping"); ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java index f5c3567fa..7f040b2e2 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java @@ -30,10 +30,10 @@ public class ResourceDefinitionValidationServiceTest { @Test public void testValidateSource() throws Exception { - String inputFileName = dictionaryPath + "/db-source.json"; + String inputFileName = dictionaryPath + "/input-source.json"; testValidate(inputFileName); - String dbFileName = dictionaryPath + "/db-source.json"; + String dbFileName = dictionaryPath + "/primary-db-source.json"; testValidate(dbFileName); String defaultFileName = dictionaryPath + "/default-source.json"; diff --git a/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt new file mode 100644 index 000000000..50e5c3290 --- /dev/null +++ b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt @@ -0,0 +1,30 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory + +object ResourceDictionaryTestUtils { + + @JvmStatic + fun setUpResourceSourceMapping() { + ResourceSourceMappingFactory.registerSourceMapping("primary-db", "source-primary-db") + ResourceSourceMappingFactory.registerSourceMapping("input", "source-input") + ResourceSourceMappingFactory.registerSourceMapping("default", "source-default") + ResourceSourceMappingFactory.registerSourceMapping("mdsal", "source-rest") + } +} \ No newline at end of file diff --git a/components/resource-dict/src/test/resources/validation/cyclic.json b/components/resource-dict/src/test/resources/validation/cyclic.json index d837dc5d8..7e6472f5a 100644 --- a/components/resource-dict/src/test/resources/validation/cyclic.json +++ b/components/resource-dict/src/test/resources/validation/cyclic.json @@ -102,7 +102,7 @@ "type": "string" }, "dictionary-name": "loopback-ip", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "bundle-mac", "managed-ip1" diff --git a/components/resource-dict/src/test/resources/validation/duplicate.json b/components/resource-dict/src/test/resources/validation/duplicate.json index 330324cda..28ab71fca 100644 --- a/components/resource-dict/src/test/resources/validation/duplicate.json +++ b/components/resource-dict/src/test/resources/validation/duplicate.json @@ -102,7 +102,7 @@ "type": "string" }, "dictionary-name": "loopback-ip", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "bundle-mac" ] diff --git a/components/resource-dict/src/test/resources/validation/success.json b/components/resource-dict/src/test/resources/validation/success.json index 3215d06d7..5d0e89805 100644 --- a/components/resource-dict/src/test/resources/validation/success.json +++ b/components/resource-dict/src/test/resources/validation/success.json @@ -102,7 +102,7 @@ "type": "string" }, "dictionary-name": "loopback-ip", - "dictionary-source": "db", + "dictionary-source": "primary-db", "dependencies": [ "bundle-mac" ] -- cgit 1.2.3-korg From 4e08795acadc769817fac2250804a8fa33d36aea Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 4 Jan 2019 10:43:33 -0500 Subject: Update to use correct parent pom Updated neng microservice to use springboot v1 parent as opposed to odlparent. Without that change, javadoc was failing when compiled with Fluorine version of odlparent-lite parent pom. Change-Id: I677278d90869f493c281c7c5432b271dd43e7513 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- components/core/pom.xml | 126 +++++++++++++++++++-------------------- components/parent/pom.xml | 2 +- components/pom.xml | 2 +- components/resource-dict/pom.xml | 2 +- 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/components/core/pom.xml b/components/core/pom.xml index 631ee0072..84063fd57 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -1,69 +1,69 @@ - - - - - 4.0.0 - - org.onap.ccsdk.apps.components - parent - 0.4.0-SNAPSHOT - ../parent - - org.onap.ccsdk.apps.controllerblueprints - core - Controller Blueprints Core - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - - - io.projectreactor - reactor-core - - - org.yaml - snakeyaml - + + + + + 4.0.0 + + org.onap.ccsdk.apps.components + parent + 0.4.1-SNAPSHOT + ../parent + + org.onap.ccsdk.apps.controllerblueprints + core + Controller Blueprints Core + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.module + jackson-module-jsonSchema + + + io.projectreactor + reactor-core + + + org.yaml + snakeyaml + - - org.jetbrains.kotlin - kotlin-test-junit - test - + + org.jetbrains.kotlin + kotlin-test-junit + test + io.mockk mockk test - - - - + + + + diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 71e2bec0a..c9da403ca 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -22,7 +22,7 @@ org.onap.ccsdk.apps components - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT org.onap.ccsdk.apps.components parent diff --git a/components/pom.xml b/components/pom.xml index 6310c588e..5b8768cea 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -18,7 +18,7 @@ org.onap.ccsdk.apps ccsdk-apps - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT 4.0.0 components diff --git a/components/resource-dict/pom.xml b/components/resource-dict/pom.xml index 0fd2cc504..a3602ac99 100644 --- a/components/resource-dict/pom.xml +++ b/components/resource-dict/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.components parent - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT ../parent org.onap.ccsdk.apps.controllerblueprints -- cgit 1.2.3-korg From a3450eb629c88e8fe7f2a0a2d9b241004fd45442 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 11 Jan 2019 11:30:40 -0500 Subject: Add blueprint Kotlin script support. Change-Id: I92b8e9850ea07c7f671e7aada9770713854534c3 Issue-ID: CCSDK-941 Signed-off-by: Muthuramalingam, Brinda Santh --- components/core/pom.xml | 5 ++ .../core/script/BluePrintScriptConfiguration.kt | 86 ++++++++++++++++++++ .../core/script/BluePrintScriptService.kt | 78 ++++++++++++++++++ .../core/script/BlueprintScriptingHost.kt | 93 ++++++++++++++++++++++ .../services/javax.script.ScriptEngineFactory | 17 ++++ .../core/script/BluePrintScriptServiceTest.kt | 49 ++++++++++++ .../core/utils/JacksonReactorUtilsTest.kt | 52 ------------ .../scripts/SampleBlueprintFunctionNode.kts | 44 ++++++++++ .../artifact_type/artifact-script-kotlin.json | 8 ++ .../starter-type/node_type/source-capability.json | 3 +- .../node_type/tosca.nodes.component.Kotlin.json | 5 ++ components/parent/pom.xml | 45 +++++++++-- 12 files changed, 427 insertions(+), 58 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt create mode 100644 components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt create mode 100644 components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts create mode 100644 components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json diff --git a/components/core/pom.xml b/components/core/pom.xml index 84063fd57..f33146b6a 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -63,6 +63,11 @@ mockk test + + org.jetbrains.kotlinx + kotlinx-coroutines-test + test + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt new file mode 100644 index 000000000..f7bfb857c --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptConfiguration.kt @@ -0,0 +1,86 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.script + +import org.jetbrains.kotlin.script.util.LocalFilesResolver +import java.io.File +import kotlin.script.dependencies.ScriptContents +import kotlin.script.dependencies.ScriptDependenciesResolver +import kotlin.script.experimental.annotations.KotlinScript +import kotlin.script.experimental.api.* +import kotlin.script.experimental.jvm.JvmDependency +import kotlin.script.experimental.jvm.dependenciesFromCurrentContext +import kotlin.script.experimental.jvm.jvm + + +@KotlinScript(fileExtension = "kts", + compilationConfiguration = ComponentScriptConfiguration::class) +abstract class ComponentScript { + +} + +object ComponentScriptConfiguration : ScriptCompilationConfiguration( + { + // defaultImports(DependsOn::class, Repository::class) + jvm { + dependenciesFromCurrentContext( + wholeClasspath = true + ) + } +// refineConfiguration { +// onAnnotations(DependsOn::class, Repository::class, handler = ::configureLocalFileDepsOnAnnotations) +// } + } +) + + +private val resolver = LocalFilesResolver() + +fun configureLocalFileDepsOnAnnotations(context: ScriptConfigurationRefinementContext): + ResultWithDiagnostics { + + val annotations = context.collectedData?.get(ScriptCollectedData.foundAnnotations)?.takeIf { it.isNotEmpty() } + ?: return context.compilationConfiguration.asSuccess() + + val scriptContents = object : ScriptContents { + override val annotations: Iterable = annotations + override val file: File? = null + override val text: CharSequence? = null + } + + val diagnostics = arrayListOf() + + fun report(severity: ScriptDependenciesResolver.ReportSeverity, message: String, position: ScriptContents.Position?) { + //TODO + } + + return try { + val newDepsFromResolver = resolver.resolve(scriptContents, emptyMap(), ::report, null).get() + ?: return context.compilationConfiguration.asSuccess(diagnostics) + + val resolvedClasspath = newDepsFromResolver.classpath.toList().takeIf { it.isNotEmpty() } + ?: return context.compilationConfiguration.asSuccess(diagnostics) + + ScriptCompilationConfiguration(context.compilationConfiguration) { + dependencies.append(JvmDependency(resolvedClasspath)) + + }.asSuccess(diagnostics) + + } catch (e: Throwable) { + ResultWithDiagnostics.Failure(*diagnostics.toTypedArray(), e.asDiagnostics()) + } +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt new file mode 100644 index 000000000..8ae091511 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptService.kt @@ -0,0 +1,78 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.script + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import java.io.File +import java.io.InputStream +import java.io.Reader +import javax.script.ScriptEngineManager +import kotlin.script.experimental.api.ResultValue +import kotlin.script.experimental.api.ResultWithDiagnostics +import kotlin.script.experimental.api.resultOrNull +import kotlin.script.experimental.host.toScriptSource +import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate + + +open class BluePrintScriptService(classLoader: ClassLoader? = Thread.currentThread().contextClassLoader) { + + /** + * Get the Script Class instance + */ + inline fun scriptClassNewInstance(scriptFile: File, scriptClassName: String): T { + + val compilationConfiguration = createJvmCompilationConfigurationFromTemplate() + + val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName) + + val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptFile.toScriptSource(), compilationConfiguration, + null) + + when (evalResponse) { + is ResultWithDiagnostics.Success -> { + val returnValue = evalResponse.resultOrNull()?.returnValue as ResultValue.Value + return returnValue.value.castOrError() + } + is ResultWithDiagnostics.Failure -> { + throw BluePrintProcessorException(evalResponse.reports.joinToString("\n")) + } + else -> { + throw BluePrintProcessorException("Failed to process script ${scriptFile.absolutePath}") + } + } + + } + + val engine = ScriptEngineManager(classLoader).getEngineByExtension("kts") + + inline fun safeEval(evaluation: () -> R?) = try { + evaluation() + } catch (e: Exception) { + throw BluePrintProcessorException("Cannot load script", e) + } + + inline fun Any?.castOrError() = takeIf { it is T }?.let { it as T } + ?: throw IllegalArgumentException("Cannot cast $this to expected type ${T::class}") + + inline fun load(script: String): T = safeEval { engine.eval(script) }.castOrError() + + inline fun load(reader: Reader): T = safeEval { engine.eval(reader) }.castOrError() + + inline fun load(inputStream: InputStream): T = load(inputStream.reader()) + + inline fun loadAll(vararg inputStream: InputStream): List = inputStream.map(::load) +} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt new file mode 100644 index 000000000..bda20a444 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BlueprintScriptingHost.kt @@ -0,0 +1,93 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.script + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.slf4j.LoggerFactory +import kotlin.script.experimental.api.* +import kotlin.script.experimental.host.BasicScriptingHost +import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration +import kotlin.script.experimental.jvmhost.JvmScriptCompiler + +val defaultBlueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfiguration) + +open class BlueprintScriptingHost(evaluator: ScriptEvaluator +) : BasicScriptingHost(defaultBlueprintScriptCompiler, evaluator) { + + override fun eval( + script: SourceCode, + scriptCompilationConfiguration: ScriptCompilationConfiguration, + configuration: ScriptEvaluationConfiguration? + ): ResultWithDiagnostics = + + runInCoroutineContext { + + compiler(script, scriptCompilationConfiguration) + .onSuccess { + evaluator(it, configuration) + } + } +} + + +open class BluePrintScriptEvaluator(private val scriptClassName: String) : ScriptEvaluator { + + val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!! + + override suspend operator fun invoke( + compiledScript: CompiledScript<*>, + scriptEvaluationConfiguration: ScriptEvaluationConfiguration? + ): ResultWithDiagnostics = + try { + val res = compiledScript.getClass(scriptEvaluationConfiguration) + when (res) { + is ResultWithDiagnostics.Failure -> res + is ResultWithDiagnostics.Success -> { + val scriptClass = res.value + val args = ArrayList() + scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach { + args.add(it.value) + } + scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.implicitReceivers)?.let { + args.addAll(it) + } + scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.constructorArgs)?.let { + args.addAll(it) + } + + val completeScriptClass = "Script\$$scriptClassName" + log.info("Searching for class type($completeScriptClass)") + /** + * Search for Class Name + */ + val instanceClass = scriptClass.java.classes + .single { it.name == completeScriptClass } + //.single { it.name == "Script\$SampleBlueprintsFunctionNode" } + + + val instance = instanceClass.newInstance() + ?: throw BluePrintProcessorException("failed to create instance from the script") + + ResultWithDiagnostics.Success(EvaluationResult(ResultValue.Value(completeScriptClass, + instance, instance.javaClass.typeName), + scriptEvaluationConfiguration)) + } + } + } catch (e: Throwable) { + ResultWithDiagnostics.Failure(e.asDiagnostics("Error evaluating script")) + } +} \ No newline at end of file diff --git a/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory new file mode 100644 index 000000000..89838f44f --- /dev/null +++ b/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory @@ -0,0 +1,17 @@ +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt new file mode 100644 index 000000000..5c5ad3ba1 --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/script/BluePrintScriptServiceTest.kt @@ -0,0 +1,49 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.script + +import org.junit.Ignore +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import java.io.File +import kotlin.test.assertEquals +import kotlin.test.assertNotNull + +class BluePrintScriptServiceTest { + + @Test + fun `invoke script`() { + val scriptContent = "11 + 11" + val value = BluePrintScriptService() + .load(scriptContent) + assertEquals(22, value, "failed to execute command") + } + + @Test + @Ignore + fun `invoke script component node`() { + + //println(classpathFromClasspathProperty()?.joinToString("\n")) + + val scriptFile = File("src/test/resources/scripts/SampleBlueprintFunctionNode.kts") + + val functionNode = BluePrintScriptService() + .scriptClassNewInstance>(scriptFile, + "SampleBlueprintFunctionNode") + assertNotNull(functionNode, "failed to get instance from script") + } +} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt deleted file mode 100644 index ad55c7761..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - -@Deprecated("Reactor will be replacecd by coroutines by default.") -class JacksonReactorUtilsTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - @Test - fun testReadValues() { - - val serviceTemplate = JacksonReactorUtils.readValueFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json", - ServiceTemplate::class.java).block() - - assertNotNull(serviceTemplate, "Failed to simple transform Service Template") - assertEquals(true, serviceTemplate is ServiceTemplate, "failed to get Service Template instance") - - val jsonContent = JacksonReactorUtils.getJson(serviceTemplate, true).block() - assertNotNull(jsonContent, "Failed to get json content") - - val jsonNode = JacksonReactorUtils.jsonNodeFromFile("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json") - .block() - assertNotNull(jsonContent, "Failed to get json Node") - } - - @Test(expected = BluePrintException::class) - fun testReadValuesFailure() { - JacksonReactorUtils.jsonNodeFromFile("load/blueprints/not-found.json") - .block() - } -} \ No newline at end of file diff --git a/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts b/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts new file mode 100644 index 000000000..44cc957d2 --- /dev/null +++ b/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode + +open class SampleBlueprintFunctionNode : BlueprintFunctionNode{ + + override fun getName(): String { + return "Kotlin-Script-Function-Node" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "$t-status" + } +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json new file mode 100644 index 000000000..cf19ac615 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/artifact_type/artifact-script-kotlin.json @@ -0,0 +1,8 @@ +{ + "description": "Kotlin Script file", + "version": "1.0.0", + "file_ext": [ + "kts" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json index 241b69953..e4eb90e7b 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json +++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json @@ -5,10 +5,11 @@ "type": { "required": true, "type": "string", - "default": "JAVA-COMPONENT", + "default": "KOTLIN-COMPONENT", "constraints": [ { "valid_values": [ + "KOTLIN-COMPONENT", "JAVA-COMPONENT", "JYTHON-COMPONENT" ] diff --git a/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json new file mode 100644 index 000000000..381ed59e2 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/tosca.nodes.component.Kotlin.json @@ -0,0 +1,5 @@ +{ + "description": "This is Kotlin Component", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/components/parent/pom.xml b/components/parent/pom.xml index c9da403ca..8ecb2c1a2 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -31,13 +31,13 @@ 2.1.1.RELEASE 5.1.3.RELEASE - 1.3.10 - 1.3.10 - 1.0.1 - 1.16.1 + 1.3.11 + 1.3.11 + 1.1.0 + 1.17.1 3.6.1 1.0.0 - 26.0-jre + 27.0.1-jre 2.9.2 1.4.197 1.2.2 @@ -77,6 +77,7 @@ ${springfox.swagger2.version} + org.apache.commons commons-lang3 @@ -114,6 +115,26 @@ kotlin-stdlib ${kotlin.version} + + org.jetbrains.kotlin + kotlin-scripting-jvm-host + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-compiler-embeddable + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-script-util + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-script-runtime + ${kotlin.version} + org.jetbrains.kotlinx kotlinx-coroutines-core @@ -201,6 +222,12 @@ ${kotlin.version} test + + org.jetbrains.kotlinx + kotlinx-coroutines-test + ${kotlin.couroutines.version} + test + io.grpc grpc-testing @@ -255,6 +282,10 @@ org.jetbrains.kotlin kotlin-stdlib + + org.jetbrains.kotlin + kotlin-script-util + org.jetbrains.kotlin kotlin-stdlib-jdk8 @@ -271,6 +302,10 @@ com.fasterxml.jackson.module jackson-module-kotlin + + org.jetbrains.kotlin + kotlin-scripting-jvm-host + io.grpc -- cgit 1.2.3-korg From 908e62722ab29a2c91b4b3f4194554c5319fe54a Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 14 Jan 2019 17:08:01 -0500 Subject: Add velocity engine template service Change-Id: Idde39b587b41328e5a5e2e32ab32c29cd27d4855 Issue-ID: CCSDK-941 Signed-off-by: Muthuramalingam, Brinda Santh --- components/core/pom.xml | 4 + .../core/service/BluePrintTemplateService.kt | 94 ++++++++++++++++++++++ .../core/utils/JacksonUtils.kt | 14 +++- .../core/service/BluePrintTemplateServiceTest.kt | 35 ++++++++ .../test/resources/templates/base-config-data.json | 36 +++++++++ .../resources/templates/base-config-template.vtl | 61 ++++++++++++++ 6 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt create mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt create mode 100755 components/core/src/test/resources/templates/base-config-data.json create mode 100755 components/core/src/test/resources/templates/base-config-template.vtl diff --git a/components/core/pom.xml b/components/core/pom.xml index f33146b6a..03d46f493 100644 --- a/components/core/pom.xml +++ b/components/core/pom.xml @@ -52,6 +52,10 @@ org.yaml snakeyaml + + org.apache.velocity + velocity + org.jetbrains.kotlin diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt new file mode 100644 index 000000000..d175fddea --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt @@ -0,0 +1,94 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.fasterxml.jackson.core.io.CharTypes +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.JsonNodeFactory +import com.fasterxml.jackson.databind.node.TextNode +import org.apache.commons.lang3.BooleanUtils +import org.apache.commons.lang3.StringUtils +import org.apache.velocity.VelocityContext +import org.apache.velocity.app.Velocity +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import java.io.StringWriter + +open class BluePrintTemplateService { + + companion object { + + /** + * Generate Content from Velocity Template and JSON Content. + */ + fun generateContent(template: String, json: String, + ignoreJsonNull: Boolean = false, + additionalContext: MutableMap = hashMapOf()): String { + Velocity.init() + val mapper = ObjectMapper() + val nodeFactory = BluePrintJsonNodeFactory() + mapper.setNodeFactory(nodeFactory) + + val jsonNode = mapper.readValue(json, JsonNode::class.java) + ?: throw BluePrintProcessorException("couldn't get json node from json") + + if (ignoreJsonNull) + JacksonUtils.removeJsonNullNode(jsonNode) + + val velocityContext = VelocityContext() + velocityContext.put("StringUtils", StringUtils::class.java) + velocityContext.put("BooleanUtils", BooleanUtils::class.java) + /** + * Add the Custom Velocity Context API + */ + additionalContext.forEach { name, value -> velocityContext.put(name, value) } + /** + * Add the JSON Data to the context + */ + jsonNode.fields().forEach { entry -> + velocityContext.put(entry.key, entry.value) + } + + val stringWriter = StringWriter() + Velocity.evaluate(velocityContext, stringWriter, "TemplateData", template) + stringWriter.flush() + return stringWriter.toString() + } + } +} + +/** + * Customise JsonNodeFactory adn TextNode, Since it introduces quotes for string data. + */ +open class BluePrintJsonNodeFactory : JsonNodeFactory() { + override fun textNode(text: String): TextNode { + return BluePrintTextNode(text) + } +} + +open class BluePrintTextNode(v: String) : TextNode(v) { + override fun toString(): String { + var len = this._value.length + len = len + 2 + (len shr 4) + val sb = StringBuilder(len) + CharTypes.appendQuoted(sb, this._value) + return sb.toString() + } + +} + diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 58a820791..6321a8385 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -21,10 +21,10 @@ import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.node.ArrayNode import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode -import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -56,6 +56,18 @@ class JacksonUtils { return jacksonObjectMapper().treeToValue(node, valueType) } + fun removeJsonNullNode(node: JsonNode) { + val it = node.iterator() + while (it.hasNext()) { + val child = it.next() + if (child.isNull) { + it.remove() + } else { + removeJsonNullNode(child) + } + } + } + fun getContent(fileName: String): String = runBlocking { async { try { diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt new file mode 100644 index 000000000..663a3751a --- /dev/null +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt @@ -0,0 +1,35 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import kotlin.test.assertNotNull + +class BluePrintTemplateServiceTest { + + @Test + fun testGenerateContent() { + + val template = JacksonUtils.getClassPathFileContent("templates/base-config-template.vtl") + val json = JacksonUtils.getClassPathFileContent("templates/base-config-data.json") + + val content = BluePrintTemplateService.generateContent(template, json) + assertNotNull(content, "failed to generate content for velocity template") + + } +} \ No newline at end of file diff --git a/components/core/src/test/resources/templates/base-config-data.json b/components/core/src/test/resources/templates/base-config-data.json new file mode 100755 index 000000000..2acc6fcdd --- /dev/null +++ b/components/core/src/test/resources/templates/base-config-data.json @@ -0,0 +1,36 @@ +{ + "node0_hostname": "sdnc-host", + "node0_backup_router_address": "2001:1890:1253::192:168:100:1", + "servers": [ + "Server1", + "Server2", + "Server3" + ], + "tacplus-servers": [ + { + "tacplus-server-name": "tacplus-server-name1", + "tacplus-server-source-address": "enc-dsdsasa1" + }, + { + "tacplus-server-name": "tacplus-server-name2", + "tacplus-server-source-address": "enc-dsdsasa2" + } + ], + "classes": [ + { + "name": "superuser-class", + "idle-timeout": 5, + "permissions": "all" + }, + { + "name": "tacacs-adv-class", + "idle-timeout": 5 + }, + { + "name": "tacacs-base-class", + "idle-timeout": 5 + } + ], + "system-password": "teamops-system-password", + "root-password": "teamops-root-password" +} diff --git a/components/core/src/test/resources/templates/base-config-template.vtl b/components/core/src/test/resources/templates/base-config-template.vtl new file mode 100755 index 000000000..f7b1269b3 --- /dev/null +++ b/components/core/src/test/resources/templates/base-config-template.vtl @@ -0,0 +1,61 @@ + + 15.1X49-D50.3 + + node0 + + #foreach($server in ${servers}) + $StringUtils.upperCase("$server") + #end + + + ${node0_hostname} + +
${node0_backup_router_address}
+ $node0_backup_router_address +
+ #foreach($tacplus-server in ${tacplus-servers}) + + $tacplus-server.tacplus-server-name + $tacplus-server.tacplus-server-source-address + + #end + + ONAP information assets + #foreach($class in ${classes}) + + $class.name + $class.idle-timeout + #if ($class.permissions) + $class.permissions + #end + + #end + + readonly + Read Only Account Access + 1001 + tacacs-base-class + + + readwrite + Read - Write Account Access + 1002 + tacacs-adv-class + + ${system-password} + + + + readwrite + Emergency Access Only + 1000 + superuser-class + + ${root-password} + + + +
+
+
\ No newline at end of file -- cgit 1.2.3-korg From 31517e5189a5c0c95dfed89689312fb27ad9065c Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 16 Jan 2019 20:17:24 -0500 Subject: Implement resolve NodeTemplate Capability property Change-Id: I2e1de34d5c2465f1f59eeab044f1883e2d1d4ff6 Issue-ID: CCSDK-959 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/service/BluePrintRuntimeService.kt | 271 ++++++++++----------- .../core/service/BluePrintRuntimeServiceTest.kt | 37 +-- 2 files changed, 152 insertions(+), 156 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt index bd19ae47e..60318659b 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -62,20 +62,20 @@ interface BluePrintRuntimeService { fun setBluePrintError(bluePrintError: BluePrintError) - /* - Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing - */ - fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap + fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, + propertyDefinitions: MutableMap, + propertyAssignments: MutableMap): MutableMap - fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capability: String): MutableMap + fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap - fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap - fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap + fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, + operationName: String): MutableMap - fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap + fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, + operationName: String): MutableMap fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String @@ -89,24 +89,24 @@ interface BluePrintRuntimeService { fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) - fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) + fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) - fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) + fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) - fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) + fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) fun getInputValue(propertyName: String): JsonNode - fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode + fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String): JsonNode fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? - fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: String): JsonNode? - - fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: String): JsonNode? - fun assignInputs(jsonNode: JsonNode) fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) @@ -190,22 +190,17 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl this.bluePrintError = bluePrintError } - /* - Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing - */ - override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { - log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) - val propertyAssignmentValue: MutableMap = hashMapOf() + /** + * Resolve any property assignments for the node + */ + override fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, + propertyDefinitions: MutableMap, + propertyAssignments: MutableMap) + : MutableMap { - val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - - val propertyAssignments: MutableMap = nodeTemplate.properties!! - - // Get the Node Type Definitions - val nodeTypeProperties: MutableMap = bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!! + val propertyAssignmentValue: MutableMap = hashMapOf() - // Iterate Node Type Properties - nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty -> + propertyDefinitions.forEach { nodeTypePropertyName, nodeTypeProperty -> // Get the Express or Value for the Node Template val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] @@ -213,38 +208,61 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl if (propertyAssignment != null) { // Resolve the Expressing val propertyAssignmentExpression = PropertyAssignmentService(this) - resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) + resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, + nodeTypePropertyName, propertyAssignment) } else { // Assign default value to the Operation - nodeTypeProperty.defaultValue?.let { defaultValue -> - resolvedValue = defaultValue + nodeTypeProperty.defaultValue?.let { + resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) } } // Set for Return of method propertyAssignmentValue[nodeTypePropertyName] = resolvedValue } - log.info("resolved property definition for node template ({}), values ({})", nodeTemplateName, propertyAssignmentValue) return propertyAssignmentValue } + override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { + log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) + + val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + val propertyAssignments: MutableMap = nodeTemplate.properties!! + + // Get the Node Type Definitions + val nodeTypePropertieDefinitions: MutableMap = bluePrintContext + .nodeTypeChainedProperties(nodeTemplate.type)!! + + /** + * Resolve the NodeTemplate Property Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypePropertieDefinitions, + propertyAssignments) + } + override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): MutableMap { log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " + "($capabilityName)") - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } + val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + val propertyAssignments = nodeTemplate.capabilities?.get(capabilityName)?.properties ?: hashMapOf() - override fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap { - log.info("resolveNodeTemplateRequirementProperties for node template($nodeTemplateName) requirement ($requirementName)") - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + val propertyDefinitions = bluePrintContext.nodeTemplateNodeType(nodeTemplateName) + .capabilities?.get(capabilityName)?.properties ?: hashMapOf() + + /** + * Resolve the Capability Property Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, propertyDefinitions, + propertyAssignments) } override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, - interfaceName: String, operationName: String): MutableMap { - log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " + - "operationName({})", nodeTemplateName, interfaceName, operationName) - - val propertyAssignmentValue: MutableMap = hashMapOf() + interfaceName: String, + operationName: String): MutableMap { + log.info("resolveNodeTemplateInterfaceOperationInputs for node template ($nodeTemplateName),interface name " + + "($interfaceName), operationName($operationName)") val propertyAssignments: MutableMap = bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) @@ -256,40 +274,22 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName) ?: hashMapOf() - log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments) + log.info("input definition for node template ($nodeTemplateName), values ($propertyAssignments)") - // Iterate Node Type Properties - nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty -> - // Get the Express or Value for the Node Template - val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] + /** + * Resolve the Property Input Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypeInterfaceOperationInputs, + propertyAssignments) - var resolvedValue: JsonNode = NullNode.getInstance() - if (propertyAssignment != null) { - // Resolve the Expressing - val propertyAssignmentExpression = PropertyAssignmentService(this) - resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) - } else { - // Assign default value to the Operation - nodeTypeProperty.defaultValue?.let { - resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) - } - } - // Set for Return of method - propertyAssignmentValue[nodeTypePropertyName] = resolvedValue - } - log.trace("resolved input assignments for node template ({}), values ({})", nodeTemplateName, - propertyAssignmentValue) - - return propertyAssignmentValue } override fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, - interfaceName: String, operationName: String): MutableMap { - log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ({}),interface name ({}), " + - "operationName({})", nodeTemplateName, interfaceName, operationName) - - val propertyAssignmentValue: MutableMap = hashMapOf() + interfaceName: String, + operationName: String): MutableMap { + log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ($nodeTemplateName),interface name " + + "($interfaceName), operationName($operationName)") val propertyAssignments: MutableMap = bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) @@ -300,30 +300,15 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val nodeTypeInterfaceOperationOutputs: MutableMap = bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName) ?: hashMapOf() - - // Iterate Node Type Properties - nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty -> - - // Get the Express or Value for the Node Template - val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] - - var resolvedValue: JsonNode = NullNode.getInstance() - if (propertyAssignment != null) { - // Resolve the Expressing - val propertyAssignmentExpression = PropertyAssignmentService(this) - resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, nodeTypePropertyName, propertyAssignment) - } else { - // Assign default value to the Operation - nodeTypeProperty.defaultValue?.let { - resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) - } - } - // Set for Return of method - propertyAssignmentValue[nodeTypePropertyName] = resolvedValue - - // Store operation output values into context - setNodeTemplateOperationOutputValue(nodeTemplateName, interfaceName, operationName, nodeTypePropertyName, resolvedValue) - log.trace("resolved output assignments for node template ({}), property name ({}), value ({})", nodeTemplateName, nodeTypePropertyName, resolvedValue) + /** + * Resolve the Property Output Assignment Values. + */ + val propertyAssignmentValue = resolveNodeTemplatePropertyAssignments(nodeTemplateName, + nodeTypeInterfaceOperationOutputs, propertyAssignments) + + // Store operation output values into context + propertyAssignmentValue.forEach { key, value -> + setNodeTemplateOperationOutputValue(nodeTemplateName, interfaceName, operationName, key, value) } return propertyAssignmentValue } @@ -338,12 +323,11 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) return nodeTemplate.artifacts?.get(artifactName) - ?: throw BluePrintProcessorException(String.format("failed to get artifat definition {} from the node template" - , artifactName)) + ?: throw BluePrintProcessorException("failed to get artifat definition($artifactName) from the node " + + "template") } - override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { val path = StringBuilder(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() @@ -351,8 +335,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl put(path, value) } - override fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS).append(BluePrintConstants.PATH_DIVIDER).append(workflowName) + override fun setWorkflowInputValue(workflowName: String, propertyName: String, + propertyDefinition: PropertyDefinition, value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS) + .append(BluePrintConstants.PATH_DIVIDER).append(workflowName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() @@ -361,7 +347,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() put(path, value) @@ -369,7 +356,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() put(path, value) @@ -377,31 +365,42 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() log.trace("setting operation property path ({}), values ({})", path, value) put(path, value) } - override fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + override fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() put(path, value) } - override fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + override fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() @@ -415,47 +414,36 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl return getJsonNode(path) } - override fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES).append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS).append(BluePrintConstants.PATH_DIVIDER).append(operationName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS).append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + override fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String): JsonNode { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return getJsonNode(path) } override fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() return getJsonNode(path) } override fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() return getJsonNode(path) } - override fun getNodeTemplateRequirementPropertyValue(nodeTemplateName: String, requirementName: String, propertyName: - String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_REQUIREMENTS).append(requirementName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return getJsonNode(path) - } - - override fun getNodeTemplateCapabilityPropertyValue(nodeTemplateName: String, capabilityName: String, propertyName: - String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_CAPABILITIES).append(capabilityName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return getJsonNode(path) - } - override fun assignInputs(jsonNode: JsonNode) { log.info("assignInputs from input JSON ({})", jsonNode.toString()) bluePrintContext.inputs?.forEach { propertyName, property -> @@ -493,7 +481,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl override fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode { val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode() - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES).append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) .append(BluePrintConstants.PATH_DIVIDER).toString() store.keys.filter { diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index c01b14b31..02148f08a 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -39,7 +39,7 @@ class BluePrintRuntimeServiceTest { private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) @Test - fun testResolveNodeTemplateProperties() { + fun `test Resolve NodeTemplate Properties`() { log.info("************************ testResolveNodeTemplateProperties **********************") val bluePrintRuntimeService = getBluePrintRuntimeService() @@ -49,25 +49,31 @@ class BluePrintRuntimeServiceTest { val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath) bluePrintRuntimeService.assignInputs(inputNode) - val propContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateProperties("activate-process") + val propContext: MutableMap = bluePrintRuntimeService + .resolveNodeTemplateProperties("activate-process") assertNotNull(propContext, "Failed to populate interface property values") } @Test - fun testResolveNodeTemplateCapabilityProperties() { + fun `test resolve NodeTemplate Capability Properties`() { log.info("************************ testResolveNodeTemplateRequirementProperties **********************") - //TODO - } + val bluePrintRuntimeService = getBluePrintRuntimeService() - @Test - fun testResolveNodeTemplateRequirementProperties() { - log.info("************************ testResolveNodeTemplateRequirementProperties **********************") - //TODO + val executionContext = bluePrintRuntimeService.getExecutionContext() + + BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), + "data/default-context.json", executionContext) + + val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", + "netconf") + assertNotNull(capProperties, "Failed to populate capability property values") + assertEquals(capProperties["target-ip-address"], JacksonUtils.jsonNodeFromObject("localhost"), "Failed to populate parameter target-ip-address") + assertEquals(capProperties["port-number"], JacksonUtils.jsonNodeFromObject(830), "Failed to populate parameter port-number") } @Test - fun testResolveNodeTemplateInterfaceOperationInputs() { + fun `test Resolve NodeTemplate Interface Operation Inputs`() { log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") val bluePrintRuntimeService = getBluePrintRuntimeService() @@ -77,16 +83,17 @@ class BluePrintRuntimeServiceTest { BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), "data/default-context.json", executionContext) - val inContext: MutableMap = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs("resource-assignment", - "ResourceAssignmentComponent", "process") + val inContext: MutableMap = bluePrintRuntimeService + .resolveNodeTemplateInterfaceOperationInputs("resource-assignment", + "ResourceAssignmentComponent", "process") assertNotNull(inContext, "Failed to populate interface input property values") assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - } + } @Test - fun testResolveNodeTemplateInterfaceOperationOutputs() { + fun `test Resolve NodeTemplate Interface Operation Outputs`() { log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************") val bluePrintRuntimeService = getBluePrintRuntimeService() @@ -107,7 +114,7 @@ class BluePrintRuntimeServiceTest { } @Test - fun testNodeTemplateContextProperty() { + fun `test NodeTemplate Context Property`() { log.info("************************ testNodeTemplateContextProperty **********************") val bluePrintRuntimeService = getBluePrintRuntimeService() -- cgit 1.2.3-korg From 67a076b19d69441ae8e695f1d0f67620dacf719d Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Wed, 16 Jan 2019 16:51:17 -0500 Subject: Resource Resolution Service Enhancement to the Resource Resolution Service to add ResourceResolutionRunTimeService Change-Id: Ia0799447e8a71e7455c5a18abc08dce503db6d35 Issue-ID: CCSDK-958 Signed-off-by: Singal, Kapil (ks220y) --- .../core/BluePrintConstants.kt | 343 +++++++++++---------- .../controllerblueprints/core/BluePrintTypes.kt | 2 + .../controllerblueprints/core/CustomFunctions.kt | 31 +- .../core/service/BluePrintValidatorService.kt | 2 +- .../core/utils/JacksonUtils.kt | 70 +++-- .../validation/BluePrintNodeTypeValidatorImpl.kt | 4 +- .../resource/dict/utils/ResourceAssignmentUtils.kt | 156 ---------- 7 files changed, 248 insertions(+), 360 deletions(-) delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 4c2d6e2fc..68037387f 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -1,172 +1,173 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -/** - * BluePrintConstants - * - * @author Brinda Santh - */ -object BluePrintConstants { - - const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" - const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" - const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" - const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" - - const val STATUS_SUCCESS: String = "success" - const val STATUS_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" - - const val DATA_TYPE_STRING: String = "string" - const val DATA_TYPE_INTEGER: String = "integer" - const val DATA_TYPE_FLOAT: String = "float" - const val DATA_TYPE_BOOLEAN: String = "boolean" - const val DATA_TYPE_TIMESTAMP: String = "timestamp" - const val DATA_TYPE_NULL: String = "null" - const val DATA_TYPE_LIST: String = "list" - const val DATA_TYPE_MAP: String = "map" - - const val USER_SYSTEM: String = "System" - - const val PATH_DIVIDER: String = "/" - const val PATH_SERVICE_TEMPLATE: String = "service_template" - const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" - const val PATH_METADATA: String = "metadata" - const val PATH_NODE_TYPES: String = "node_types" - const val PATH_POLICY_TYPES: String = "policy_types" - const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" - const val PATH_ARTIFACT_TYPES: String = "artifact_types" - const val PATH_DATA_TYPES: String = "data_types" - const val PATH_INPUTS: String = "inputs" - const val PATH_NODE_WORKFLOWS: String = "workflows" - const val PATH_NODE_TEMPLATES: String = "node_templates" - const val PATH_CAPABILITIES: String = "capabilities" - const val PATH_REQUIREMENTS: String = "requirements" - const val PATH_INTERFACES: String = "interfaces" - const val PATH_OPERATIONS: String = "operations" - const val PATH_OUTPUTS: String = "outputs" - const val PATH_PROPERTIES: String = "properties" - const val PATH_ATTRIBUTES: String = "attributes" - const val PATH_ARTIFACTS: String = "artifacts" - - const val MODEL_DIR_MODEL_TYPE: String = "definition-type" - - const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" - const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" - const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" - const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" - const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" - - const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" - const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" - const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" - const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" - const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" - const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" - const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" - - const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" - const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" - const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" - const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" - const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" - - const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" - const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" - const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" - @Deprecated("Artifacts will be attached to Node Template") - const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" - const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" - - const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" - const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" - const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" - const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" - const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" - const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" - - const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" - - const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" - - const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" - const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" - const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" - const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" - const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" - const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" - const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" - // Custom capabilities - const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" - const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" - const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" - const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" - const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" - - const val EXPRESSION_GET_INPUT: String = "get_input" - const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" - const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" - const val EXPRESSION_GET_PROPERTY: String = "get_property" - const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" - const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" - - const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" - const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" - const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" - const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" - const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" - const val PROPERTY_BLUEPRINT_NAME: String = "template_name" - const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" - - const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" - const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" - const val TOSCA_DEFINITIONS_DIR: String = "Definitions" - const val TOSCA_PLANS_DIR: String = "Plans" - const val TOSCA_SCRIPTS_DIR: String = "Scripts" - const val TOSCA_MAPPINGS_DIR: String = "Mappings" - const val TOSCA_TEMPLATES_DIR: String = "Templates" - - const val METADATA_USER_GROUPS = "user-groups" - const val METADATA_TEMPLATE_NAME = "template_name" - const val METADATA_TEMPLATE_VERSION = "template_version" - const val METADATA_TEMPLATE_AUTHOR = "template_author" - const val METADATA_TEMPLATE_TAGS = "template_tags" - const val METADATA_WORKFLOW_NAME = "workflow_name" - - const val PAYLOAD_DATA = "payload-data" - const val PROPERTY_CURRENT_STEP = "current-step" - const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" - const val PROPERTY_CURRENT_INTERFACE = "current-interface" - const val PROPERTY_CURRENT_OPERATION = "current-operation" - const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" - const val PROPERTY_EXECUTION_REQUEST = "execution-request" - - const val OPERATION_PROCESS = "process" - const val OPERATION_PREPARE = "prepare" - - const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" - const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" - const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" - +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core + +/** + * BluePrintConstants + * + * @author Brinda Santh + */ +object BluePrintConstants { + + const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" + const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" + const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + + const val STATUS_SUCCESS: String = "success" + const val STATUS_FAILURE: String = "failure" + + const val TYPE_DEFAULT: String = "default" + + const val DATA_TYPE_STRING: String = "string" + const val DATA_TYPE_INTEGER: String = "integer" + const val DATA_TYPE_FLOAT: String = "float" + const val DATA_TYPE_DOUBLE: String = "double" + const val DATA_TYPE_BOOLEAN: String = "boolean" + const val DATA_TYPE_TIMESTAMP: String = "timestamp" + const val DATA_TYPE_NULL: String = "null" + const val DATA_TYPE_LIST: String = "list" + const val DATA_TYPE_MAP: String = "map" + + const val USER_SYSTEM: String = "System" + + const val PATH_DIVIDER: String = "/" + const val PATH_SERVICE_TEMPLATE: String = "service_template" + const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" + const val PATH_METADATA: String = "metadata" + const val PATH_NODE_TYPES: String = "node_types" + const val PATH_POLICY_TYPES: String = "policy_types" + const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" + const val PATH_ARTIFACT_TYPES: String = "artifact_types" + const val PATH_DATA_TYPES: String = "data_types" + const val PATH_INPUTS: String = "inputs" + const val PATH_NODE_WORKFLOWS: String = "workflows" + const val PATH_NODE_TEMPLATES: String = "node_templates" + const val PATH_CAPABILITIES: String = "capabilities" + const val PATH_REQUIREMENTS: String = "requirements" + const val PATH_INTERFACES: String = "interfaces" + const val PATH_OPERATIONS: String = "operations" + const val PATH_OUTPUTS: String = "outputs" + const val PATH_PROPERTIES: String = "properties" + const val PATH_ATTRIBUTES: String = "attributes" + const val PATH_ARTIFACTS: String = "artifacts" + + const val MODEL_DIR_MODEL_TYPE: String = "definition-type" + + const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" + const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" + const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" + const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" + const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" + + const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" + const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" + const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" + const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" + const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" + const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" + const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" + + const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" + const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" + const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" + const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" + const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" + + const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" + const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" + const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" + @Deprecated("Artifacts will be attached to Node Template") + const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" + const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" + + const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" + const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" + const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" + const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" + const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" + const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" + + const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" + + const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" + + const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" + const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" + const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" + const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" + const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" + const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" + const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" + // Custom capabilities + const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" + const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" + const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" + const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" + const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" + + const val EXPRESSION_GET_INPUT: String = "get_input" + const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" + const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" + const val EXPRESSION_GET_PROPERTY: String = "get_property" + const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" + const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" + + const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" + const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" + const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" + const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" + const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" + const val PROPERTY_BLUEPRINT_NAME: String = "template_name" + const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" + + const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" + const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" + const val TOSCA_DEFINITIONS_DIR: String = "Definitions" + const val TOSCA_PLANS_DIR: String = "Plans" + const val TOSCA_SCRIPTS_DIR: String = "Scripts" + const val TOSCA_MAPPINGS_DIR: String = "Mappings" + const val TOSCA_TEMPLATES_DIR: String = "Templates" + + const val METADATA_USER_GROUPS = "user-groups" + const val METADATA_TEMPLATE_NAME = "template_name" + const val METADATA_TEMPLATE_VERSION = "template_version" + const val METADATA_TEMPLATE_AUTHOR = "template_author" + const val METADATA_TEMPLATE_TAGS = "template_tags" + const val METADATA_WORKFLOW_NAME = "workflow_name" + + const val PAYLOAD_DATA = "payload-data" + const val PROPERTY_CURRENT_STEP = "current-step" + const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" + const val PROPERTY_CURRENT_INTERFACE = "current-interface" + const val PROPERTY_CURRENT_OPERATION = "current-operation" + const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" + const val PROPERTY_EXECUTION_REQUEST = "execution-request" + + const val OPERATION_PROCESS = "process" + const val OPERATION_PREPARE = "prepare" + + const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" + const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" + const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" + } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index 64797ed40..4c35b53a2 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -103,6 +103,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_STRING) validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) validTypes.add(BluePrintConstants.DATA_TYPE_NULL) @@ -117,6 +118,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_STRING) validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) validTypes.add(BluePrintConstants.DATA_TYPE_NULL) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt index 4d1d9b653..11f709c9a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -112,25 +112,40 @@ fun MutableMap.getAsDouble(key: String): Double { // Checks fun checkNotEmpty(value: String?): Boolean { - return value != null && value.isNotEmpty() + return value != null && value.isNotBlank() } -fun checkNotEmptyNThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean { - val notEmpty = value != null && value.isNotEmpty() +fun checkNotEmptyOrThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean { + val notEmpty = checkNotEmpty(value) if (!notEmpty) { throw BluePrintException(message!!) } return notEmpty } +fun checkEqualsOrThrow(value1: String?, value2: String?, lazyMessage: () -> Any): Boolean { + if (value1.equals(value2, ignoreCase = true)) { + return true + } else { + throw BluePrintException(lazyMessage().toString()) + } +} + +fun nullToEmpty(value: String?): String { + return if (checkNotEmpty(value)) value!! else "" +} + +fun returnNotEmptyOrThrow(value: String?, lazyMessage: () -> Any): String { + if (checkNotEmpty(value)) { + return value!! + } else { + throw IllegalStateException(lazyMessage().toString()) + } +} + fun InputStream.toFile(path: String): File { val file = File(path) file.outputStream().use { this.copyTo(it) } return file } - - - - - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 178373704..b33cc3f0c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -523,7 +523,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class) open fun validateImplementation(implementation: Implementation) { - checkNotEmptyNThrow(implementation.primary) + checkNotEmptyOrThrow(implementation.primary) } @Throws(BluePrintException::class) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 6321a8385..2e5a040c5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -33,9 +33,11 @@ import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes import java.io.File import java.nio.charset.Charset +import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType /** * @@ -174,8 +176,13 @@ class JacksonUtils { return getMapFromJson(content, valueType) } + fun getInstanceFromMap(properties: MutableMap, classType: Class): T { + return readValue(getJson(properties), classType) + ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)") + } + fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { - if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { return checkJsonNodeValueOfPrimitiveType(type, jsonNode) } else if (BluePrintTypes.validCollectionTypes().contains(type)) { return checkJsonNodeValueOfCollectionType(type, jsonNode) @@ -183,59 +190,76 @@ class JacksonUtils { return false } + fun checkIfPrimitiveType(primitiveType: String): Boolean { + return when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_STRING -> true + BluePrintConstants.DATA_TYPE_BOOLEAN -> true + BluePrintConstants.DATA_TYPE_INTEGER -> true + BluePrintConstants.DATA_TYPE_FLOAT -> true + BluePrintConstants.DATA_TYPE_DOUBLE -> true + BluePrintConstants.DATA_TYPE_TIMESTAMP -> true + else -> false + } + } + fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { - when (primitiveType) { - BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual - BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean - BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt - BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble - BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual - else -> return false + return when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual + else -> false } } fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { - when (type) { - BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray - BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode - else -> return false + return when (type.toLowerCase()) { + BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray + BluePrintConstants.DATA_TYPE_MAP -> jsonNode.isContainerNode + else -> false } } fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) { - when (primitiveType) { + when (primitiveType.toLowerCase()) { BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean) BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int) BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float) + BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, value as Double) BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String) else -> objectNode.put(key, value as String) } } fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) { - when (primitiveType) { + when (primitiveType.toLowerCase()) { BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean) BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int) BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float) + BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(value as Double) BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String) else -> arrayNode.add(value as String) } } fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { - when (primitiveType) { + when (primitiveType.toLowerCase()) { BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false) BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0) BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0) + BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, 0.0) else -> objectNode.put(key, "") } } fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { - when (primitiveType) { + when (primitiveType.toLowerCase()) { BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false) BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0) BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0) + BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(0.0) else -> arrayNode.add("") } } @@ -250,13 +274,15 @@ class JacksonUtils { } } - fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? { - when (type) { - BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean) - BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int) - BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float) - else -> return JacksonUtils.getJsonNode(value) + fun convertPrimitiveResourceValue(type: String, value: String): JsonNode { + return when (type.toLowerCase()) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(java.lang.Boolean.valueOf(value)) + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(Integer.valueOf(value)) + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(java.lang.Float.valueOf(value)) + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(java.lang.Double.valueOf(value)) + else -> getJsonNode(value) } } + } } \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt index 2e4a733a8..1077f347e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -20,7 +20,7 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -149,7 +149,7 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ } open fun validateImplementation(implementation: Implementation) { - checkNotEmptyNThrow(implementation.primary) + checkNotEmptyOrThrow(implementation.primary) } } \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt deleted file mode 100644 index a234a89ee..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils - -import java.util.Date -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.NullNode -import com.fasterxml.jackson.databind.node.ObjectNode -import org.onap.ccsdk.apps.controllerblueprints.core.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment - -class ResourceAssignmentUtils { - companion object { - - private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString()) - - @Synchronized - @Throws(BluePrintProcessorException::class) - fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) { - - val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" } - checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment") - - if (checkNotEmpty(resourceAssignment.dictionaryName)) { - resourceAssignment.dictionaryName = resourceAssignment.name - logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})") - } - - try { - if (checkNotEmpty(resourceProp.type)) { - val convertedValue = convertResourceValue(resourceProp.type, value) - logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})") - resourceProp.value = convertedValue - resourceAssignment.updatedDate = Date() - resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM - resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS - } - } catch (e: Exception) { - throw BluePrintProcessorException("Failed in setting value for template key (%s) and " + - "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e) - } - } - - private fun convertResourceValue(type: String, value: Any?): JsonNode? { - var convertedValue: JsonNode? - - if (value == null || value is NullNode) { - logger.info("Returning {} value from convertResourceValue", value) - return null - } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) { - convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value) - } else { - // Case where Resource is non-primitive type - if (value is String) { - convertedValue = JacksonUtils.jsonNode(value) - } else { - convertedValue = JacksonUtils.getJsonNode(value) - } - } - return convertedValue - } - - @Synchronized - fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) { - if (checkNotEmpty(resourceAssignment.name)) { - resourceAssignment.updatedDate = Date() - resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM - resourceAssignment.status = BluePrintConstants.STATUS_FAILURE - resourceAssignment.message = message - } - } - - @Synchronized - @Throws(BluePrintProcessorException::class) - fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) { - val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" } - if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) { - logger.error("failed to populate mandatory resource mapping ($resourceAssignment)") - throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)") - } - } - - @Synchronized - @Throws(BluePrintProcessorException::class) - fun generateResourceDataForAssignments(assignments: List): String { - var result = "{}" - try { - val mapper = ObjectMapper() - val root = mapper.readTree(result) - - assignments.forEach { - if (checkNotEmpty(it.name) && it.property != null) { - - val type = it.property?.type - val value = it.property?.value - logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type, - value) - if (value == null) { - (root as ObjectNode).set(it.name, null) - } else if (value is JsonNode) { - (root as ObjectNode).put(it.name, value as JsonNode) - } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as String) - } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as Boolean) - } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as Int) - } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as Float) - } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as String) - } else { - val jsonNode = JacksonUtils.getJsonNode(value) - if (jsonNode != null) { - (root as ObjectNode).put(it.name, jsonNode) - } else { - (root as ObjectNode).set(it.name, null) - } - } - } - } - result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root) - logger.info("Generated Resource Param Data ({})", result) - } catch (e: Exception) { - throw BluePrintProcessorException("kapil is failing with $e.message", e) - } - - return result - } - - fun transformResourceSource(properties: MutableMap, classType: Class): T { - val content = JacksonUtils.getJson(properties) - return JacksonUtils.readValue(content, classType) - ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)") - } - - } -} \ No newline at end of file -- cgit 1.2.3-korg From 63b46822006012aab9be495d2626a062f4c79949 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 17 Jan 2019 04:49:30 -0500 Subject: Resource Resolution Service: Primary DB Adding Primary-DB Resource Resolution Processor Service to resolve Resources of source primary-db Change-Id: I156f7958b681e51b7c3bfdee92b6fbd196591e73 Issue-ID: CCSDK-942 Signed-off-by: Singal, Kapil (ks220y) --- .../resource/dict/ResourceDictionaryConstants.kt | 4 +++- .../resource/dict/utils/ResourceDictionaryUtilsTest.java | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index e4219c139..0004b02f5 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -15,6 +15,7 @@ */ package org.onap.ccsdk.apps.controllerblueprints.resource.dict + /** * ResourceDictionaryConstants * @@ -23,7 +24,8 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict object ResourceDictionaryConstants { const val SOURCE_INPUT = "input" const val SOURCE_DEFAULT = "default" - const val SOURCE_DB = "primary-db" + const val SOURCE_MDSAL = "mdsal" + const val SOURCE_PRIMARY_DB = "primary-db" const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java index fa2413805..92bfa7301 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -59,9 +59,9 @@ public class ResourceDictionaryUtilsTest { Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); // To Check Assigned Source - resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_DB); + resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PRIMARY_DB); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_DB, resourceAssignment.getDictionarySource()); + Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.getDictionarySource()); } @@ -78,7 +78,7 @@ public class ResourceDictionaryUtilsTest { Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); // TO check the multiple Source - sources.put(ResourceDictionaryConstants.SOURCE_DB, new NodeTemplate()); + sources.put(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, new NodeTemplate()); String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); -- cgit 1.2.3-korg From 1e6299583fea73e98f3ad017da81c1addf8beba5 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 17 Jan 2019 16:47:46 -0500 Subject: Fix classpath issue w/ guava MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kotlin compiler embeded guava dependency, hence it's ending w/ a classpath issue. kotlin-compiler-embaddeable fixes this issue, and is getting pulled already. So we exclude koltin-compiler to avoid issue. Change-Id: Ib703e4b4ac7a478f1918282b35bcd646f5c83038 Issue-ID: CCSDK-961 Signed-off-by: Alexis de Talhouët --- components/parent/pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 8ecb2c1a2..365515aa1 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -302,9 +302,21 @@ com.fasterxml.jackson.module jackson-module-kotlin
+ + org.jetbrains.kotlin + kotlin-compiler-embeddable + org.jetbrains.kotlin kotlin-scripting-jvm-host + + + + + org.jetbrains.kotlin + kotlin-compiler + + -- cgit 1.2.3-korg From 3c1cc5d3c33e0667b3d917cff1d1f0952b255461 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sat, 12 Jan 2019 15:48:20 -0500 Subject: Implement BluePrintCatalogService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifcb0d730daec4da747d704c270b72b991e01f474 Issue-ID: CCSDK-908 Signed-off-by: Alexis de Talhouët --- .../core/interfaces/BluePrintCatalogService.kt | 41 ++++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt index 9186635ee..c99cdf749 100755 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt @@ -16,25 +16,44 @@ package org.onap.ccsdk.apps.controllerblueprints.core.interfaces -interface BluePrintCatalogService { +import org.jetbrains.annotations.NotNull +import org.jetbrains.annotations.Nullable +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import java.io.File +import java.nio.file.Path - /** - * Upload the CBA Zip fle to data base and return the Database identifier - */ - fun uploadToDataBase(file: String, validate : Boolean): String +interface BluePrintCatalogService { /** - * Download the CBA zip file from the data base and place it in a path and return the CBA zip absolute path + * Save the CBA to database. + * @param blueprintFile Either a directory, or an archive + * @param validate whether to validate blueprint content. Default true. + * @return The unique blueprint identifier + * @throws BluePrintException if process failed */ - fun downloadFromDataBase(name: String, version: String, path: String): String + @NotNull + @Throws(BluePrintException::class) + fun saveToDatabase(@NotNull blueprintFile: File, @Nullable validate: Boolean = true): String /** - * Get the Blueprint from Data Base and Download it under working directory and return the path path + * Retrieve the CBA from database either archived or extracted. + * @param name Name of the blueprint + * @param version Version of the blueprint + * @param extract true to extract the content, false for archived content. Default to true + * @return Path where CBA is located + * @throws BluePrintException if process failed */ - fun prepareBluePrint(name: String, version: String): String + @NotNull + @Throws(BluePrintException::class) + fun getFromDatabase(@NotNull name: String, @NotNull version: String, @Nullable extract: Boolean = true): Path /** - * Get blueprint archive with zip file from Data Base + * Delete the CBA from database. + * @param name Name of the blueprint + * @param version Version of the blueprint + * @throws BluePrintException if process failed */ - fun downloadFromDataBase(uuid: String, path: String): String + @NotNull + @Throws(BluePrintException::class) + fun deleteFromDatabase(@NotNull name: String, @NotNull version: String) } \ No newline at end of file -- cgit 1.2.3-korg From afa5c2df6c53dfce43c72c05457ec5a108ae0ed7 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sun, 13 Jan 2019 16:49:32 -0500 Subject: Implement BluePrintManagementServiceGrpc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I66a6a3c23b5a3c24ce8d61178f00f053cb8bbbdc Issue-ID: CCSDK-909 Signed-off-by: Alexis de Talhouët --- .../api-definition/proto/BluePrintManagement.proto | 58 ++++++++-------------- 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/components/model-catalog/api-definition/proto/BluePrintManagement.proto b/components/model-catalog/api-definition/proto/BluePrintManagement.proto index 55f9466e4..dc0680d57 100644 --- a/components/model-catalog/api-definition/proto/BluePrintManagement.proto +++ b/components/model-catalog/api-definition/proto/BluePrintManagement.proto @@ -2,55 +2,37 @@ syntax = "proto3"; option java_multiple_files = true; package org.onap.ccsdk.apps.controllerblueprints.management.api; -message BluePrintUploadInput { - CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; - FileChunk fileChunk = 4; +message BluePrintManagementInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; + FileChunk fileChunk = 4; } -message FileChunk { - bytes chunk = 1; -} - -message BluePrintUploadOutput { - CommonHeader commonHeader = 1; - Status status = 3; -} - -message BluePrintRemoveInput { - CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; +message BluePrintManagementOutput { + CommonHeader commonHeader = 1; + Status status = 3; } -message BluePrintRemoveOutput { - CommonHeader commonHeader = 1; - Status status = 3; +message FileChunk { + bytes chunk = 1; } message CommonHeader { - string timestamp = 1; - string originatorId = 23; - string requestId = 3; - string subRequestId = 4; -} - -message ActionIdentifiers { - string blueprintName = 1; - string blueprintVersion = 2; - string actionName = 3; - string mode = 4; + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; } message Status { - string timestamp = 1; - int32 code = 2; - string message = 3; - string errorMessage = 4; + string timestamp = 1; + int32 code = 2; + string message = 3; + string errorMessage = 4; } service BluePrintManagementService { - rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintUploadOutput); - rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintRemoveOutput); + rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); + rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); } -- cgit 1.2.3-korg From bece50a90f6510f0ec3d109ff4dc4a9257881ac1 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 15 Jan 2019 14:44:58 -0500 Subject: Implement CBA upload through REST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I417254c5107f8b0031932e6a7cf0599561ee9a3c Issue-ID: CCSDK-910 Signed-off-by: Alexis de Talhouët --- .../core/utils/BluePrintArchiveUtils.kt | 65 +++++++--------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt index ab5175dea..fe7929e85 100755 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -24,13 +24,18 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream import org.apache.commons.io.IOUtils import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import java.io.* +import org.slf4j.LoggerFactory +import java.io.BufferedInputStream +import java.io.File +import java.io.FileInputStream +import java.io.IOException import java.nio.charset.Charset import java.util.zip.ZipFile class BluePrintArchiveUtils { companion object { + private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) fun getFileContent(fileName: String): String = runBlocking { async { @@ -51,50 +56,20 @@ class BluePrintArchiveUtils { /** * Create a new Zip from a root directory * - * @param directory the base directory - * @param filename the output filename + * @param source the base directory + * @param destination the output filename * @param absolute store absolute filepath (from directory) or only filename * @return True if OK */ fun compress(source: File, destination: File, absolute: Boolean): Boolean { - // recursive call - val zaos: ZipArchiveOutputStream try { - zaos = ZipArchiveOutputStream(FileOutputStream(destination)) - } catch (e: FileNotFoundException) { - return false - } - - try { - recurseFiles(source, source, zaos, absolute) - } catch (e2: IOException) { - try { - zaos.close() - } catch (e: IOException) { - // ignore + ZipArchiveOutputStream(destination).use { + recurseFiles(source, source, it, absolute) } - + } catch (e: Exception) { + log.error("Fail to compress folder(:$source) to path(${destination.path}", e) return false } - - try { - zaos.finish() - } catch (e1: IOException) { - // ignore - } - - try { - zaos.flush() - } catch (e: IOException) { - // ignore - } - - try { - zaos.close() - } catch (e: IOException) { - // ignore - } - return true } @@ -113,21 +88,19 @@ class BluePrintArchiveUtils { if (file.isDirectory) { // recursive call val files = file.listFiles() - for (file2 in files!!) { - recurseFiles(root, file2, zaos, absolute) + for (fileChild in files!!) { + recurseFiles(root, fileChild, zaos, absolute) } } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) { - var filename: String? = null - if (absolute) { - filename = file.absolutePath.substring(root.absolutePath.length) + val filename = if (absolute) { + file.absolutePath.substring(root.absolutePath.length) } else { - filename = file.name + file.name } val zae = ZipArchiveEntry(filename) - zae.setSize(file.length()) + zae.size = file.length() zaos.putArchiveEntry(zae) - val fis = FileInputStream(file) - IOUtils.copy(fis, zaos) + FileInputStream(file).use { IOUtils.copy(it, zaos) } zaos.closeArchiveEntry() } } -- cgit 1.2.3-korg From e6a3021f85854eb5be61f128606a30db1a7bdf09 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 15 Jan 2019 16:17:17 -0500 Subject: Add support for async REST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ieb53cbd75c2e21355b153611f6490c1b2af6053b Issue-ID: CCSDK-662 Signed-off-by: Alexis de Talhouët --- .../apps/controllerblueprints/core/BluePrintConstants.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 68037387f..4ef0e82b2 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -27,12 +27,13 @@ object BluePrintConstants { const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" - const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" - - const val STATUS_SUCCESS: String = "success" - const val STATUS_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + + const val STATUS_SUCCESS: String = "success" + const val STATUS_PROCESSING: String = "processing" + const val STATUS_FAILURE: String = "failure" + + const val TYPE_DEFAULT: String = "default" const val DATA_TYPE_STRING: String = "string" const val DATA_TYPE_INTEGER: String = "integer" -- cgit 1.2.3-korg From 95553263e5ea110912e83c93e2b22b4796fe57c6 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Fri, 18 Jan 2019 14:29:38 -0500 Subject: Create module for .proto definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That way 3rd party system can depend on it to create a client Change-Id: I96e8588251eb0911a7dd7bee270954e966d9fc40 Issue-ID: CCSDK-947 Signed-off-by: Alexis de Talhouët --- .../api-definition/proto/BluePrintManagement.proto | 38 ---------- .../api-definition/proto/BluePrintProcessing.proto | 49 ------------- components/model-catalog/proto-definition/pom.xml | 81 ++++++++++++++++++++++ .../proto/BluePrintManagement.proto | 38 ++++++++++ .../proto/BluePrintProcessing.proto | 49 +++++++++++++ components/pom.xml | 4 +- 6 files changed, 171 insertions(+), 88 deletions(-) delete mode 100644 components/model-catalog/api-definition/proto/BluePrintManagement.proto delete mode 100644 components/model-catalog/api-definition/proto/BluePrintProcessing.proto create mode 100644 components/model-catalog/proto-definition/pom.xml create mode 100644 components/model-catalog/proto-definition/proto/BluePrintManagement.proto create mode 100644 components/model-catalog/proto-definition/proto/BluePrintProcessing.proto diff --git a/components/model-catalog/api-definition/proto/BluePrintManagement.proto b/components/model-catalog/api-definition/proto/BluePrintManagement.proto deleted file mode 100644 index dc0680d57..000000000 --- a/components/model-catalog/api-definition/proto/BluePrintManagement.proto +++ /dev/null @@ -1,38 +0,0 @@ -syntax = "proto3"; -option java_multiple_files = true; -package org.onap.ccsdk.apps.controllerblueprints.management.api; - -message BluePrintManagementInput { - CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; - FileChunk fileChunk = 4; -} - -message BluePrintManagementOutput { - CommonHeader commonHeader = 1; - Status status = 3; -} - -message FileChunk { - bytes chunk = 1; -} - -message CommonHeader { - string timestamp = 1; - string originatorId = 23; - string requestId = 3; - string subRequestId = 4; -} - -message Status { - string timestamp = 1; - int32 code = 2; - string message = 3; - string errorMessage = 4; -} - -service BluePrintManagementService { - rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); - rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); -} diff --git a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto b/components/model-catalog/api-definition/proto/BluePrintProcessing.proto deleted file mode 100644 index 8fa4a13fa..000000000 --- a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto +++ /dev/null @@ -1,49 +0,0 @@ -syntax = "proto3"; -import "google/protobuf/struct.proto"; -option java_multiple_files = true; -package org.onap.ccsdk.apps.controllerblueprints.processing.api; - -message ExecutionServiceInput { - CommonHeader commonHeader = 1; - ActionIdentifiers actionIdentifiers = 2; - google.protobuf.Struct payload = 3; -} - -message ExecutionServiceOutput { - CommonHeader commonHeader = 1; - ActionIdentifiers actionIdentifiers = 2; - Status status = 3; - google.protobuf.Struct payload = 4; -} - -message CommonHeader { - string timestamp = 1; - string originatorId = 23; - string requestId = 3; - string subRequestId = 4; - Flag flag = 5; -} - -message Flag { - bool isForce = 1; - int32 ttl = 2; -} - -message ActionIdentifiers { - string blueprintName = 1; - string blueprintVersion = 2; - string actionName = 3; - string mode = 4; -} - -message Status { - int32 code = 1; - string errorMessage = 2; - string message = 3; - string eventType = 4; - string timestamp = 5; -} - -service BluePrintProcessingService { - rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput); -} diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml new file mode 100644 index 000000000..c1f77922c --- /dev/null +++ b/components/model-catalog/proto-definition/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + modules + 0.4.1-SNAPSHOT + + + proto-definition + jar + + Controller Blueprints Proto Definition + Controller Blueprints Proto Definition + + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-stub + + + com.google.protobuf + protobuf-java-util + + + + + + + kr.motd.maven + os-maven-plugin + 1.6.1 + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + + com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier} + + grpc-java + + io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier} + + proto + + + + + compile + compile-custom + + + + + + + \ No newline at end of file diff --git a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto new file mode 100644 index 000000000..dc0680d57 --- /dev/null +++ b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.management.api; + +message BluePrintManagementInput { + CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; + FileChunk fileChunk = 4; +} + +message BluePrintManagementOutput { + CommonHeader commonHeader = 1; + Status status = 3; +} + +message FileChunk { + bytes chunk = 1; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; +} + +message Status { + string timestamp = 1; + int32 code = 2; + string message = 3; + string errorMessage = 4; +} + +service BluePrintManagementService { + rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); + rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); +} diff --git a/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto new file mode 100644 index 000000000..8fa4a13fa --- /dev/null +++ b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; +import "google/protobuf/struct.proto"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.processing.api; + +message ExecutionServiceInput { + CommonHeader commonHeader = 1; + ActionIdentifiers actionIdentifiers = 2; + google.protobuf.Struct payload = 3; +} + +message ExecutionServiceOutput { + CommonHeader commonHeader = 1; + ActionIdentifiers actionIdentifiers = 2; + Status status = 3; + google.protobuf.Struct payload = 4; +} + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; + Flag flag = 5; +} + +message Flag { + bool isForce = 1; + int32 ttl = 2; +} + +message ActionIdentifiers { + string blueprintName = 1; + string blueprintVersion = 2; + string actionName = 3; + string mode = 4; +} + +message Status { + int32 code = 1; + string errorMessage = 2; + string message = 3; + string eventType = 4; + string timestamp = 5; +} + +service BluePrintProcessingService { + rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput); +} diff --git a/components/pom.xml b/components/pom.xml index 5b8768cea..95ffd5c02 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + org.onap.ccsdk.apps ccsdk-apps @@ -37,5 +38,6 @@ parent core resource-dict + model-catalog/proto-definition -- cgit 1.2.3-korg From 148f823ff5a500aad6cc1456f0f70b1000ca6d57 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Fri, 18 Jan 2019 14:59:10 -0500 Subject: Make BluePrintProcessingService#process stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4aed859365a9c7251d8b29c0c68726d53b0f9d0f Issue-ID: CCSDK-662 Signed-off-by: Alexis de Talhouët --- .../model-catalog/proto-definition/proto/BluePrintProcessing.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto index 8fa4a13fa..d8ad571b6 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto @@ -45,5 +45,5 @@ message Status { } service BluePrintProcessingService { - rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput); + rpc process (stream ExecutionServiceInput) returns (stream ExecutionServiceOutput); } -- cgit 1.2.3-korg From 83b8b91a3648b585d3fd451f99aab90db5fe5fc9 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Sun, 20 Jan 2019 17:49:52 -0500 Subject: Resource Resolution Service: Source Rest Complex Data Processing for Primary-Config-Data DataSource Resource Resolution Service Change-Id: I62492b5c4e3c0b831f9027df5d42c6b80186debc Issue-ID: CCSDK-674 Signed-off-by: Singal, Kapil (ks220y) --- .../resources/dictionary/dictionary_schema.json | 4 +- .../vFW/Definitions/vFW_spinup.json | 46 +++++++++++----------- .../Definitions/baseconfig-mapping.json | 2 +- .../Definitions/resources_definition_types.json | 2 +- .../starter-dictionary/image_name.json | 2 +- .../starter-dictionary/key_name.json | 2 +- .../starter-dictionary/mdsal-source.json | 2 +- .../starter-dictionary/onap_private_net_id.json | 2 +- .../starter-dictionary/onap_private_subnet_id.json | 2 +- .../starter-dictionary/pub_key.json | 2 +- .../starter-dictionary/sample-licenses.json | 2 +- .../starter-dictionary/sample-mdsal-source.json | 2 +- .../starter-dictionary/vfw_private_ip_0.json | 2 +- .../starter-dictionary/vfw_private_ip_1.json | 2 +- .../starter-dictionary/vnf-name.json | 2 +- .../starter-dictionary/vnf_name.json | 2 +- .../starter-dictionary/vpg_private_ip_0.json | 2 +- .../starter-dictionary/vsn_private_ip_0.json | 2 +- .../load/resource_dictionary/mdsal-source.json | 2 +- .../load/resource_dictionary/vfw_private_ip_0.json | 2 +- .../load/resource_dictionary/vfw_private_ip_1.json | 2 +- .../load/resource_dictionary/vnf-name.json | 2 +- .../load/resource_dictionary/vnf_name.json | 2 +- .../load/resource_dictionary/vpg_private_ip_0.json | 2 +- .../load/resource_dictionary/vsn_private_ip_0.json | 2 +- .../resource/dict/ResourceDictionaryConstants.kt | 2 +- .../factory/ResourceSourceMappingFactoryTest.java | 2 +- .../dict/utils/ResourceDictionaryTestUtils.kt | 2 +- .../src/test/resources/validation/cyclic.json | 10 ++--- .../src/test/resources/validation/duplicate.json | 10 ++--- .../src/test/resources/validation/success.json | 10 ++--- 31 files changed, 66 insertions(+), 66 deletions(-) diff --git a/components/core/src/test/resources/dictionary/dictionary_schema.json b/components/core/src/test/resources/dictionary/dictionary_schema.json index f9ef9eeed..51db5f51a 100644 --- a/components/core/src/test/resources/dictionary/dictionary_schema.json +++ b/components/core/src/test/resources/dictionary/dictionary_schema.json @@ -54,7 +54,7 @@ "aai": { "type": "any" }, - "mdsal": { + "primary-config-data": { "type": "object", "properties": { "path": { @@ -188,7 +188,7 @@ } } }, - "mdsal": { + "primary-config-data": { "type": "object", "properties": { "names": { diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json index 13847bbb4..4484d550e 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json @@ -667,7 +667,7 @@ }, "input-param": false, "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -982,7 +982,7 @@ }, "input-param": false, "dictionary-name": "image_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1007,7 +1007,7 @@ }, "input-param": false, "dictionary-name": "key_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1032,7 +1032,7 @@ }, "input-param": false, "dictionary-name": "pub_key", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1057,7 +1057,7 @@ }, "input-param": false, "dictionary-name": "onap_private_net_id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1082,7 +1082,7 @@ }, "input-param": false, "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1462,7 +1462,7 @@ }, "input-param": false, "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1777,7 +1777,7 @@ }, "input-param": false, "dictionary-name": "image_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1802,7 +1802,7 @@ }, "input-param": false, "dictionary-name": "key_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1827,7 +1827,7 @@ }, "input-param": false, "dictionary-name": "pub_key", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1852,7 +1852,7 @@ }, "input-param": false, "dictionary-name": "onap_private_net_id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1877,7 +1877,7 @@ }, "input-param": false, "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1950,7 +1950,7 @@ }, "input-param": false, "dictionary-name": "vfw_private_ip_0", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -1975,7 +1975,7 @@ }, "input-param": false, "dictionary-name": "vsn_private_ip_0", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2050,7 +2050,7 @@ }, "input-param": false, "dictionary-name": "vpg_private_ip_0", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2284,7 +2284,7 @@ }, "input-param": false, "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2574,7 +2574,7 @@ }, "input-param": false, "dictionary-name": "image_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2625,7 +2625,7 @@ }, "input-param": false, "dictionary-name": "key_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2650,7 +2650,7 @@ }, "input-param": false, "dictionary-name": "pub_key", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2675,7 +2675,7 @@ }, "input-param": false, "dictionary-name": "onap_private_net_id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2700,7 +2700,7 @@ }, "input-param": false, "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -2848,7 +2848,7 @@ }, "input-param": false, "dictionary-name": "vfw_private_ip_1", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" @@ -3250,7 +3250,7 @@ }, "input-param": false, "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json index c457086cf..67d2a914e 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json @@ -27,7 +27,7 @@ "type": "string" }, "dictionary-name": "vnf_name", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "service-instance-id", "vnf-id" diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json index 557f6efce..c88712146 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json @@ -38,7 +38,7 @@ "type": "string" }, "sources": { - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json index 37ef5ae19..57a0ef391 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/image_name.json @@ -10,7 +10,7 @@ "input": { "type": "source-input" }, - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json index 1f1b3e65c..6eb8d929b 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/key_name.json @@ -10,7 +10,7 @@ "input": { "type": "source-input" }, - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json index 300a71f1f..67661ecd0 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json @@ -7,7 +7,7 @@ }, "updated-by": "brindasanth@onap.com", "sources": { - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json index bb70fe3c4..3dd74f7d4 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_net_id.json @@ -10,7 +10,7 @@ "input": { "type": "source-input" }, - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json index d38ceb49c..6cb22c3d6 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/onap_private_subnet_id.json @@ -10,7 +10,7 @@ "input": { "type": "source-input" }, - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json b/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json index ce6c2f2a3..fe172cafd 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/pub_key.json @@ -10,7 +10,7 @@ "input": { "type": "source-input" }, - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json index 5834dd49b..c0f78ac55 100644 --- a/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-licenses.json @@ -11,7 +11,7 @@ }, "updated-by": "brindasanth@onap.com", "sources": { - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json index 25464d3fe..75d7ca050 100644 --- a/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/sample-mdsal-source.json @@ -7,7 +7,7 @@ }, "updated-by": "brindasanth@onap.com", "sources": { - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json index 71a4df2c4..4c227f91f 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_0.json @@ -12,7 +12,7 @@ "properties" : { } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json index 481edae8c..0df08c000 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vfw_private_ip_1.json @@ -12,7 +12,7 @@ "properties" : { } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json index 89b3dc1c0..4c0320aca 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnf-name.json @@ -7,7 +7,7 @@ "type" : "string" }, "sources" : { - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json b/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json index c55f1c18a..e9d8a3b48 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vnf_name.json @@ -7,7 +7,7 @@ "type" : "string" }, "sources" : { - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json index 13d89993b..586aa0c9c 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vpg_private_ip_0.json @@ -12,7 +12,7 @@ "properties" : { } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json index fcd6d8d55..1fe479717 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/vsn_private_ip_0.json @@ -12,7 +12,7 @@ "properties" : { } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/load/resource_dictionary/mdsal-source.json b/components/resource-dict/load/resource_dictionary/mdsal-source.json index b38986a4b..fa72e5dc2 100644 --- a/components/resource-dict/load/resource_dictionary/mdsal-source.json +++ b/components/resource-dict/load/resource_dictionary/mdsal-source.json @@ -7,7 +7,7 @@ }, "updated-by": "brindasanth@onap.com", "sources": { - "mdsal": { + "primary-config-data": { "type": "source-rest", "properties": { "type": "JSON", diff --git a/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json b/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json index 7c8d4f4e8..59f51516d 100644 --- a/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json +++ b/components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json @@ -13,7 +13,7 @@ "key" : "vfw_private_ip_0" } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json b/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json index 0553b8c37..6dda72f7c 100644 --- a/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json +++ b/components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json @@ -13,7 +13,7 @@ "key" : "vfw_private_ip_1" } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/load/resource_dictionary/vnf-name.json b/components/resource-dict/load/resource_dictionary/vnf-name.json index 47371d184..708030ee1 100644 --- a/components/resource-dict/load/resource_dictionary/vnf-name.json +++ b/components/resource-dict/load/resource_dictionary/vnf-name.json @@ -7,7 +7,7 @@ "type" : "string" }, "sources" : { - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/load/resource_dictionary/vnf_name.json b/components/resource-dict/load/resource_dictionary/vnf_name.json index 4617a264e..3164367c6 100644 --- a/components/resource-dict/load/resource_dictionary/vnf_name.json +++ b/components/resource-dict/load/resource_dictionary/vnf_name.json @@ -7,7 +7,7 @@ "type" : "string" }, "sources" : { - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json b/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json index 912cfb9ad..9bef3c791 100644 --- a/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json +++ b/components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json @@ -13,7 +13,7 @@ "key" : "vpg_private_ip_0" } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json b/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json index bf987382c..52a4542c5 100644 --- a/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json +++ b/components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json @@ -13,7 +13,7 @@ "key" : "vsn_private_ip_0" } }, - "mdsal" : { + "primary-config-data" : { "type" : "source-rest", "properties" : { "type" : "JSON", diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt index 0004b02f5..aa06c9da0 100644 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -24,7 +24,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict object ResourceDictionaryConstants { const val SOURCE_INPUT = "input" const val SOURCE_DEFAULT = "default" - const val SOURCE_MDSAL = "mdsal" + const val SOURCE_PRIMARY_CONFIG_DATA = "primary-config-data" const val SOURCE_PRIMARY_DB = "primary-db" const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java index 3f5aef43d..f11638e35 100644 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java +++ b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java @@ -28,7 +28,7 @@ public class ResourceSourceMappingFactoryTest { ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db"); ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-config-data", "source-rest"); String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db"); Assert.notNull(nodeTypeName, "Failed to get primary-db mapping"); diff --git a/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt index 50e5c3290..74ef6d6de 100644 --- a/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt +++ b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt @@ -25,6 +25,6 @@ object ResourceDictionaryTestUtils { ResourceSourceMappingFactory.registerSourceMapping("primary-db", "source-primary-db") ResourceSourceMappingFactory.registerSourceMapping("input", "source-input") ResourceSourceMappingFactory.registerSourceMapping("default", "source-default") - ResourceSourceMappingFactory.registerSourceMapping("mdsal", "source-rest") + ResourceSourceMappingFactory.registerSourceMapping("primary-config-data", "source-rest") } } \ No newline at end of file diff --git a/components/resource-dict/src/test/resources/validation/cyclic.json b/components/resource-dict/src/test/resources/validation/cyclic.json index 7e6472f5a..98cd14446 100644 --- a/components/resource-dict/src/test/resources/validation/cyclic.json +++ b/components/resource-dict/src/test/resources/validation/cyclic.json @@ -29,7 +29,7 @@ "required": true }, "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id" ] @@ -42,7 +42,7 @@ "required": true }, "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id" ] @@ -54,7 +54,7 @@ "type": "string" }, "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id", "bundle-id" @@ -67,7 +67,7 @@ "type": "string" }, "dictionary-name": "managed-ip", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "loopback-ip" ] @@ -90,7 +90,7 @@ "type": "string" }, "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "loopback-ip" ] diff --git a/components/resource-dict/src/test/resources/validation/duplicate.json b/components/resource-dict/src/test/resources/validation/duplicate.json index 28ab71fca..7581ff64d 100644 --- a/components/resource-dict/src/test/resources/validation/duplicate.json +++ b/components/resource-dict/src/test/resources/validation/duplicate.json @@ -29,7 +29,7 @@ "required": true }, "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id" ] @@ -42,7 +42,7 @@ "required": true }, "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id" ] @@ -54,7 +54,7 @@ "type": "string" }, "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id", "bundle-id" @@ -67,7 +67,7 @@ "type": "string" }, "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "loopback-ip" ] @@ -90,7 +90,7 @@ "type": "string" }, "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "loopback-ip" ] diff --git a/components/resource-dict/src/test/resources/validation/success.json b/components/resource-dict/src/test/resources/validation/success.json index 5d0e89805..486251d60 100644 --- a/components/resource-dict/src/test/resources/validation/success.json +++ b/components/resource-dict/src/test/resources/validation/success.json @@ -29,7 +29,7 @@ "required": true }, "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id" ] @@ -42,7 +42,7 @@ "required": true }, "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id" ] @@ -54,7 +54,7 @@ "type": "string" }, "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "vnf-id", "bundle-id" @@ -67,7 +67,7 @@ "type": "string" }, "dictionary-name": "managed-ip", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "loopback-ip" ] @@ -90,7 +90,7 @@ "type": "string" }, "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", + "dictionary-source": "primary-config-data", "dependencies": [ "loopback-ip" ] -- cgit 1.2.3-korg From 2bb2e0fa50480e833de6eeeb6244217cb23a8f5f Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 21 Jan 2019 08:35:36 -0500 Subject: Map proto to pojo. implement blueprint processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I16b06b4700a42d4a7066eb8c0779677fa28cd94b Issue-ID: CCSDK-951 Signed-off-by: Alexis de Talhouët --- .../proto-definition/proto/BluePrintCommon.proto | 31 +++++++++++++++ .../proto/BluePrintManagement.proto | 21 ++-------- .../proto/BluePrintProcessing.proto | 45 +++++----------------- 3 files changed, 45 insertions(+), 52 deletions(-) create mode 100644 components/model-catalog/proto-definition/proto/BluePrintCommon.proto diff --git a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto new file mode 100644 index 000000000..0f17783aa --- /dev/null +++ b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +option java_multiple_files = true; +package org.onap.ccsdk.apps.controllerblueprints.common.api; + +message CommonHeader { + string timestamp = 1; + string originatorId = 23; + string requestId = 3; + string subRequestId = 4; + Flag flag = 5; +} + +message Flag { + bool isForce = 1; + int32 ttl = 2; +} + +message ActionIdentifiers { + string blueprintName = 1; + string blueprintVersion = 2; + string actionName = 3; + string mode = 4; +} + +message Status { + int32 code = 1; + string errorMessage = 2; + string message = 3; + string eventType = 4; + string timestamp = 5; +} \ No newline at end of file diff --git a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto index dc0680d57..658cbbbdc 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto @@ -1,37 +1,24 @@ syntax = "proto3"; +import "BluePrintCommon.proto"; option java_multiple_files = true; package org.onap.ccsdk.apps.controllerblueprints.management.api; message BluePrintManagementInput { - CommonHeader commonHeader = 1; + org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader commonHeader = 1; string blueprintName = 2; string blueprintVersion = 3; FileChunk fileChunk = 4; } message BluePrintManagementOutput { - CommonHeader commonHeader = 1; - Status status = 3; + org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader commonHeader = 1; + org.onap.ccsdk.apps.controllerblueprints.common.api.Status status = 3; } message FileChunk { bytes chunk = 1; } -message CommonHeader { - string timestamp = 1; - string originatorId = 23; - string requestId = 3; - string subRequestId = 4; -} - -message Status { - string timestamp = 1; - int32 code = 2; - string message = 3; - string errorMessage = 4; -} - service BluePrintManagementService { rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput); diff --git a/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto index d8ad571b6..5b91f46b7 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintProcessing.proto @@ -1,49 +1,24 @@ syntax = "proto3"; import "google/protobuf/struct.proto"; +import "BluePrintCommon.proto"; option java_multiple_files = true; package org.onap.ccsdk.apps.controllerblueprints.processing.api; + message ExecutionServiceInput { - CommonHeader commonHeader = 1; - ActionIdentifiers actionIdentifiers = 2; - google.protobuf.Struct payload = 3; + org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader commonHeader = 1; + org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers actionIdentifiers = 2; + google.protobuf.Struct payload = 3; } message ExecutionServiceOutput { - CommonHeader commonHeader = 1; - ActionIdentifiers actionIdentifiers = 2; - Status status = 3; - google.protobuf.Struct payload = 4; -} - -message CommonHeader { - string timestamp = 1; - string originatorId = 23; - string requestId = 3; - string subRequestId = 4; - Flag flag = 5; -} - -message Flag { - bool isForce = 1; - int32 ttl = 2; -} - -message ActionIdentifiers { - string blueprintName = 1; - string blueprintVersion = 2; - string actionName = 3; - string mode = 4; + org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader commonHeader = 1; + org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers actionIdentifiers = 2; + org.onap.ccsdk.apps.controllerblueprints.common.api.Status status = 3; + google.protobuf.Struct payload = 4; } -message Status { - int32 code = 1; - string errorMessage = 2; - string message = 3; - string eventType = 4; - string timestamp = 5; -} service BluePrintProcessingService { - rpc process (stream ExecutionServiceInput) returns (stream ExecutionServiceOutput); + rpc process (stream ExecutionServiceInput) returns (stream ExecutionServiceOutput); } -- cgit 1.2.3-korg From c5da036e9c92280f0f3c722f98e7cc17c857284c Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 23 Jan 2019 11:42:13 -0500 Subject: GRPC 1.18.0 Upgrade. Change-Id: I1f7f75e14d284641d86c5ef91723b00aaab9bed7 Issue-ID: CCSDK-998 Signed-off-by: Muthuramalingam, Brinda Santh --- .../apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt | 4 ++-- components/model-catalog/proto-definition/pom.xml | 7 ++++--- components/parent/pom.xml | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt index 143c4a848..59a037199 100644 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt +++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt @@ -27,7 +27,7 @@ class BluePrintFileUtilsTest { @Test fun testNewBlueprint() = runBlocking { - val targetPath: String = Paths.get("target").toUri().toURL().path.plus("bp-new-test") + val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-new-test") BluePrintFileUtils.createEmptyBluePrint(targetPath) } @@ -36,7 +36,7 @@ class BluePrintFileUtilsTest { fun testBlueprintCopy() = runBlocking { val sourcePath: String = "./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration" - val targetPath: String = Paths.get("target").toUri().toURL().path.plus("bp-copy-test") + val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-copy-test") val targetDir = File(targetPath) targetDir.deleteOnExit() diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml index c1f77922c..f76dd5f1a 100644 --- a/components/model-catalog/proto-definition/pom.xml +++ b/components/model-catalog/proto-definition/pom.xml @@ -1,7 +1,8 @@ - - - - org.jetbrains.kotlin - kotlin-compiler - - - io.grpc -- cgit 1.2.3-korg From 1fe99c6fa24ef00a9652a4e6798a93fd5950273e Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 29 Jan 2019 16:53:17 -0500 Subject: Update parent for proto-definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid pulling transitive dependencies. Change-Id: I91530307817231c3b15459539e433cf97f3e4dce Issue-ID: CCSDK-947 Signed-off-by: Alexis de Talhouët --- components/model-catalog/proto-definition/pom.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml index c92893929..4680f6291 100644 --- a/components/model-catalog/proto-definition/pom.xml +++ b/components/model-catalog/proto-definition/pom.xml @@ -19,12 +19,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.onap.ccsdk.apps.components - parent + org.onap.ccsdk.apps + ccsdk-apps 0.4.1-SNAPSHOT - ../../parent + ../../../ + org.onap.ccsdk.apps.components proto-definition jar @@ -35,14 +36,17 @@ io.grpc grpc-protobuf + 1.17.1 io.grpc grpc-stub + 1.17.1 com.google.protobuf protobuf-java-util + 3.6.1 -- cgit 1.2.3-korg From d72aeb02425dc63ee86dbec816aba162cb28b315 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 30 Jan 2019 15:52:30 -0500 Subject: blueprint scripting services Change-Id: I834b83e0c2716eceadeec8a5f17a7604e938166a Issue-ID: CCSDK-941 Signed-off-by: Muthuramalingam, Brinda Santh --- .../core/BluePrintConstants.kt | 16 ++++---- .../core/interfaces/BluePrintScriptsService.kt | 25 ++++++++++++ .../core/service/BluePrintContext.kt | 13 +++++- .../kotlin/ResourceAssignmentProcessor.cba.kts | 44 +++++++++++++++++++++ .../Scripts/kotlin/ScriptComponent.cba.kts | 46 ++++++++++++++++++++++ .../starter-type/node_type/source-capability.json | 10 ++++- 6 files changed, 145 insertions(+), 9 deletions(-) create mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 4ef0e82b2..b1a7daad2 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -27,13 +27,13 @@ object BluePrintConstants { const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" - const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" - - const val STATUS_SUCCESS: String = "success" - const val STATUS_PROCESSING: String = "processing" - const val STATUS_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + + const val STATUS_SUCCESS: String = "success" + const val STATUS_PROCESSING: String = "processing" + const val STATUS_FAILURE: String = "failure" + + const val TYPE_DEFAULT: String = "default" const val DATA_TYPE_STRING: String = "string" const val DATA_TYPE_INTEGER: String = "integer" @@ -102,6 +102,7 @@ object BluePrintConstants { const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" + const val MODEL_TYPE_NODES_COMPONENT_KOTLIN: String = "tosca.nodes.component.Kotlin" const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" @@ -148,6 +149,7 @@ object BluePrintConstants { const val TOSCA_SCRIPTS_DIR: String = "Scripts" const val TOSCA_MAPPINGS_DIR: String = "Mappings" const val TOSCA_TEMPLATES_DIR: String = "Templates" + const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin" const val METADATA_USER_GROUPS = "user-groups" const val METADATA_TEMPLATE_NAME = "template_name" diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt new file mode 100644 index 000000000..124c167a8 --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt @@ -0,0 +1,25 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +interface BluePrintScriptsService{ + + fun scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String, + reCompile: Boolean): T +} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 1a6d096d8..793604514 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:Suppress("unused") package org.onap.ccsdk.apps.controllerblueprints.core.service import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils @@ -55,6 +57,15 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { return JacksonUtils.getJson(serviceTemplate, pretty) } + fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME) + ?: throw BluePrintException("could't get template name from meta data") + + fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION) + ?: throw BluePrintException("could't get template version from meta data") + + fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR) + ?: throw BluePrintException("could't get template author from meta data") + // Workflow val workflows: MutableMap? = serviceTemplate.topologyTemplate?.workflows @@ -148,7 +159,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { val nodeTemplates: MutableMap? = serviceTemplate.topologyTemplate?.nodeTemplates fun nodeTemplateByName(name: String): NodeTemplate = - nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") + nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") fun nodeTemplateForNodeType(name: String): MutableMap? { return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts new file mode 100644 index 000000000..f1da61407 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive + +open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() { + + lateinit var resourceAssignment: ResourceAssignment + + override fun getName(): String { + return "resource-assignment-processor-custom-capability" + } + + override fun process(resourceAssignment: ResourceAssignment) { + this.resourceAssignment = resourceAssignment + } + + override fun prepareResponse(): ResourceAssignment { + return resourceAssignment + } + + override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + TODO("To Implement") + } + +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts new file mode 100644 index 000000000..184c49335 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts @@ -0,0 +1,46 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode + +open class SampleKotlinComponent : BlueprintFunctionNode { + + override fun getName(): String { + return "my Name" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "Successfully Executed Scripts" + } +} diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json index e4eb90e7b..2bdd7d574 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json +++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json @@ -17,10 +17,18 @@ ] }, "instance-name": { - "description": "Capability component instance reference name.", + "description": "Capability component instance reference name for JAVA-COMPONENT, Script Class name for KOTLIN-COMPONENT.", "required": true, "type": "string" }, + "instance-dependencies": { + "required": false, + "description": "Instance dependency Names to Inject to Kotlin / Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } + }, "input-key-mapping": { "description": "Context name to input parameters name mapping.", "required": false, -- cgit 1.2.3-korg From 8df5693cba361b130d9feff10e2477cfec1230d7 Mon Sep 17 00:00:00 2001 From: "Cherukuri, Venkatanaresh (vn166g)" Date: Tue, 5 Feb 2019 09:47:55 -0500 Subject: Blueprint Processor Python Script Components Adding Python scripts for Netconf Executor components Change-Id: I6d84dea2e47860063a1140146aebe94d61f8d9c1 Issue-ID: CCSDK-997 Signed-off-by: Cherukuri, Venkatanaresh (vn166g) --- .../Definitions/activation-blueprint.json | 6 +-- .../Scripts/SamplePythonComponentNode.py | 12 ----- .../baseconfiguration/Scripts/__init__.py | 0 .../Scripts/python/DefaultGetNetConfig.py | 50 +++++++++++++++++++ .../Scripts/python/SamplePythonComponentNode.py | 12 +++++ .../baseconfiguration/Scripts/python/__init__.py | 0 .../scripts/python/ccsdk_netconf/__init__.py | 0 components/scripts/python/ccsdk_netconf/common.py | 2 + .../scripts/python/ccsdk_netconf/constant.py | 15 ++++++ .../python/ccsdk_netconf/netconf_constant.py | 15 ++++++ .../scripts/python/ccsdk_netconf/netconfclient.py | 56 ++++++++++++++++++++++ 11 files changed, 153 insertions(+), 15 deletions(-) delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/__init__.py create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/__init__.py create mode 100644 components/scripts/python/ccsdk_netconf/__init__.py create mode 100644 components/scripts/python/ccsdk_netconf/common.py create mode 100644 components/scripts/python/ccsdk_netconf/constant.py create mode 100644 components/scripts/python/ccsdk_netconf/netconf_constant.py create mode 100644 components/scripts/python/ccsdk_netconf/netconfclient.py diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json index a3bf546d6..822cc68b7 100644 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -175,7 +175,7 @@ "artifacts": { "component-script": { "type": "artifact-script-jython", - "file": "Scripts/SamplePythonComponentNode.py" + "file": "Scripts/python/SamplePythonComponentNode.py" } } }, @@ -205,7 +205,7 @@ "artifacts": { "component-script": { "type": "artifact-script-jython", - "file": "Scripts/SamplePythonComponentNode.py" + "file": "Scripts/python/SamplePythonComponentNode.py" } } }, @@ -242,7 +242,7 @@ "artifacts": { "component-script": { "type": "artifact-script-jython", - "file": "Scripts/SamplePythonComponentNode.py" + "file": "Scripts/python/DefaultGetNetConfig.py" } } }, diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py deleted file mode 100644 index 0a583dc57..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SamplePythonComponentNode.py +++ /dev/null @@ -1,12 +0,0 @@ -from abstract_blueprint_function import AbstractPythonComponentFunction -from blueprint_constants import * - -class SamplePythonComponentNode(AbstractPythonComponentFunction): - - def process(self, execution_request): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None - - def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/__init__.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py new file mode 100644 index 000000000..4db7c731b --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py @@ -0,0 +1,50 @@ +import netconf_constant +from netconfclient import NetconfClient +from java.lang import Exception +from abstract_blueprint_function import AbstractPythonComponentFunction +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService +from org.onap.ccsdk.apps.controllerblueprints.core.utils import JacksonUtils +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces import DeviceInfo +from org.onap.ccsdk.apps.controllerblueprints.core.service import BluePrintRuntimeService + + +class DefaultGetNetConfig(AbstractPythonComponentFunction): + def process(self, execution_request): + try: + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) + #requestId = globals()[netconf_constant.PARAM_REQUEST_ID] + requestId = '1234' + + bluePrintRuntimeService = globals()['bluePrintRuntimeService'] + + capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf") + + log.info("capabilityProperty {}",capabilityProperty) + netconfService = NetconfRpcService() + nc = NetconfClient(log, netconfService) + + nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty)) + runningConfigTemplate = "runningconfig-template" + + runningConfigMessageId = "get-config-" + requestId + + deviceResponse = nc.getConfig(messageId=runningConfigMessageId, + filter=runningConfigTemplate) + + log.info("Get Running Config Response {} ", deviceResponse.responseMessage) + if(deviceResponse !='null') : + status = deviceResponse.status + responseData = "{}" + if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'): + errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage + + except Exception, err: + log.info("Exception in the script {}",err.getMessage()) + status = netconf_constant.STATUS_FAILURE + errorMessage = "Get Running Config Failure ::"+err.getMessage() + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py new file mode 100644 index 000000000..0a583dc57 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py @@ -0,0 +1,12 @@ +from abstract_blueprint_function import AbstractPythonComponentFunction +from blueprint_constants import * + +class SamplePythonComponentNode(AbstractPythonComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/__init__.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/scripts/python/ccsdk_netconf/__init__.py b/components/scripts/python/ccsdk_netconf/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/scripts/python/ccsdk_netconf/common.py b/components/scripts/python/ccsdk_netconf/common.py new file mode 100644 index 000000000..139597f9c --- /dev/null +++ b/components/scripts/python/ccsdk_netconf/common.py @@ -0,0 +1,2 @@ + + diff --git a/components/scripts/python/ccsdk_netconf/constant.py b/components/scripts/python/ccsdk_netconf/constant.py new file mode 100644 index 000000000..534ca9e13 --- /dev/null +++ b/components/scripts/python/ccsdk_netconf/constant.py @@ -0,0 +1,15 @@ +SERVICE_LOG = "log" +SERVICE_NETCONF = "netconfService" +SERVICE_MESSAGE = "messageService" + +PARAM_REQUEST_ID = "requestId" +PARAM_ACTION = "action" + +STATUS_SUCCESS = "success" +STATUS_FAILURE = "failure" + +CONFIG_TARGET_RUNNING = "running" +CONFIG_TARGET_CANDIDATE = "candidate" +CONFIG_DEFAULT_OPERATION_MERGE = "merge" +CONFIG_DEFAULT_OPERATION_REPLACE = "replace" +CONFIG_DEFAULT_OPERATION_NONE = "none" diff --git a/components/scripts/python/ccsdk_netconf/netconf_constant.py b/components/scripts/python/ccsdk_netconf/netconf_constant.py new file mode 100644 index 000000000..534ca9e13 --- /dev/null +++ b/components/scripts/python/ccsdk_netconf/netconf_constant.py @@ -0,0 +1,15 @@ +SERVICE_LOG = "log" +SERVICE_NETCONF = "netconfService" +SERVICE_MESSAGE = "messageService" + +PARAM_REQUEST_ID = "requestId" +PARAM_ACTION = "action" + +STATUS_SUCCESS = "success" +STATUS_FAILURE = "failure" + +CONFIG_TARGET_RUNNING = "running" +CONFIG_TARGET_CANDIDATE = "candidate" +CONFIG_DEFAULT_OPERATION_MERGE = "merge" +CONFIG_DEFAULT_OPERATION_REPLACE = "replace" +CONFIG_DEFAULT_OPERATION_NONE = "none" diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py new file mode 100644 index 000000000..448e03dc1 --- /dev/null +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -0,0 +1,56 @@ +from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_DEFAULT_OPERATION_REPLACE + + + +class NetconfClient: + + def __init__(self, log, nc): + self.log = log + self.nc = nc + + def disconnect(self): + self.nc.disconnect() + return + + def connect(self,deviceInfo): + self.nc.connect(deviceInfo) + return + + def lock(self, messageId, configTarget, messageTimeout=30): + deviceResponse = self.nc.lock(messageId, configTarget, messageTimeout) + return deviceResponse + + def getConfig(self, messageId, filter, configTarget=CONFIG_TARGET_RUNNING, messageTimeout=30): + self.log.info("in the ncclient getConfig {}",messageId) + self.log.info("in the ncclient getConfig {}",filter) + deviceResponse = self.nc.getConfig(messageId, filter, configTarget, messageTimeout) + return deviceResponse + + def editConfig(self, messageId, messageContent, reConnect=False, wait=0, lock=False, + configTarget=CONFIG_TARGET_RUNNING, editDefaultOperation=CONFIG_DEFAULT_OPERATION_REPLACE, + deleteConfig= False, validate= False, commit=False, discardChanges =True, unlock=False, + preRestartWait=0, postRestartWait=0, messageTimeout=30): + deviceResponse = self.nc.editConfig(messageId, messageContent, reConnect, wait, lock, configTarget, + editDefaultOperation, deleteConfig, validate, commit, discardChanges, unlock, + preRestartWait, postRestartWait, messageTimeout) + return deviceResponse + + def commit(self, messageId, message, discardChanges =True, messageTimeout=30): + deviceResponse = self.nc.commit(messageId, message, discardChanges, messageTimeout) + return deviceResponse + + def unLock(self, messageId, configTarget, messageTimeout=30): + deviceResponse = self.nc.unLock(messageId, configTarget, messageTimeout) + return deviceResponse + + def discardChanges(self, messageId, messageTimeout=30): + deviceResponse = self.nc.discardChanges(messageId, messageTimeout) + return deviceResponse + + def close(self, messageId, force=False, messageTimeout=30): + deviceResponse = self.nc.close(messageId, force, messageTimeout) + return deviceResponse + + def rpc(self, request, messageId, messageTimeout=30): + deviceResponse = self.nc.rpc(request, messageId, messageTimeout) + return deviceResponse -- cgit 1.2.3-korg From c8ec87c77de53f5933a6519e55c1c6d4c6be6530 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Thu, 7 Feb 2019 14:51:50 -0500 Subject: Refactor components core and resource dict modules Change-Id: I04e9e723d68a38ecefe48206e67fddbe43c55854 Issue-ID: CCSDK-1047 Signed-off-by: Muthuramalingam, Brinda Santh --- .../artifact_type/artifact-bpmn-camunda.json | 8 - .../artifact_type/artifact-directed-graph.json | 9 - .../artifact_type/artifact-mapping-resource.json | 8 - .../artifact_type/artifact-script-python.json | 8 - .../artifact_type/artifact-template-velocity.json | 8 - .../tosca.artifacts.Implementation.json | 5 - .../model_type/data_type/datatype-property.json | 27 - .../data_type/datatype-resource-assignment.json | 46 -- .../load/model_type/data_type/dt-license-key.json | 11 - .../load/model_type/data_type/dt-v4-aggregate.json | 15 - .../data_type/tosca.datatypes.Credential.json | 31 - .../node_type/artifact-config-template.json | 37 -- .../node_type/component-config-generator.json | 72 --- .../node_type/component-netconf-executor.json | 79 --- .../node_type/component-resource-assignment.json | 68 --- .../model_type/node_type/dg-activate-netconf.json | 52 -- .../model_type/node_type/dg-config-generator.json | 51 -- .../node_type/dg-resource-assign-activate.json | 56 -- .../node_type/dg-resource-assignment.json | 51 -- .../model_type/node_type/tosca.nodes.Artifact.json | 5 - .../node_type/tosca.nodes.Component.json | 5 - .../load/model_type/node_type/tosca.nodes.DG.json | 5 - .../load/model_type/node_type/tosca.nodes.Vnf.json | 5 - .../node_type/tosca.nodes.component.Python.json | 5 - .../model_type/node_type/vnf-netconf-device.json | 42 -- components/core/pom.xml | 78 --- .../core/BluePrintConstants.kt | 176 ------ .../controllerblueprints/core/BluePrintError.kt | 29 - .../core/BluePrintException.kt | 49 -- .../core/BluePrintProcessorException.kt | 50 -- .../controllerblueprints/core/BluePrintTypes.kt | 164 ------ .../core/ConfigModelConstant.kt | 30 - .../controllerblueprints/core/CustomFunctions.kt | 151 ----- .../core/common/ApplicationConstants.kt | 23 - .../core/config/BluePrintLoadConfiguration.kt | 34 -- .../core/data/BluePrintExpressionData.kt | 70 --- .../core/data/BluePrintModel.kt | 622 --------------------- .../core/data/BlueprintErrorCode.kt | 97 ---- .../core/factory/BluePrintValidatorFactory.kt | 45 -- .../core/interfaces/BluePrintCatalogService.kt | 59 -- .../core/interfaces/BluePrintEnhancer.kt | 141 ----- .../core/interfaces/BluePrintRepoService.kt | 47 -- .../core/interfaces/BluePrintScriptsService.kt | 25 - .../core/interfaces/BlueprintFunctionNode.kt | 39 -- .../core/interfaces/BlueprintValidator.kt | 132 ----- .../core/service/BluePrintChainedService.kt | 117 ---- .../core/service/BluePrintContext.kt | 254 --------- .../core/service/BluePrintExpressionService.kt | 173 ------ .../core/service/BluePrintImportService.kt | 96 ---- .../core/service/BluePrintParserService.kt | 62 -- .../core/service/BluePrintRepoFileService.kt | 71 --- .../core/service/BluePrintRuntimeService.kt | 501 ----------------- .../core/service/BluePrintTemplateService.kt | 94 ---- .../core/service/BluePrintValidatorService.kt | 607 -------------------- .../core/service/PropertyAssignmentService.kt | 210 ------- .../core/utils/BluePrintArchiveUtils.kt | 147 ----- .../core/utils/BluePrintFileUtils.kt | 253 --------- .../core/utils/BluePrintMetadataUtils.kt | 144 ----- .../core/utils/BluePrintRuntimeUtils.kt | 61 -- .../core/utils/JacksonReactorUtils.kt | 109 ---- .../core/utils/JacksonUtils.kt | 288 ---------- .../core/utils/ResourceResolverUtils.kt | 62 -- .../core/utils/ServiceTemplateUtils.kt | 110 ---- .../core/utils/TopologicalSortingUtils.kt | 131 ----- .../BluePrintArtifactTypeValidatorImpl.kt | 33 -- .../BluePrintAttributeDefinitionValidatorImpl.kt | 29 - .../validation/BluePrintDataTypeValidatorImpl.kt | 37 -- .../BluePrintNodeTemplateValidatorImpl.kt | 298 ---------- .../validation/BluePrintNodeTypeValidatorImpl.kt | 155 ----- .../BluePrintPropertyDefinitionValidatorImpl.kt | 83 --- .../BluePrintServiceTemplateValidatorImpl.kt | 107 ---- .../BluePrintTopologyTemplateValidatorImpl.kt | 72 --- .../validation/BluePrintValidatorServiceImpl.kt | 48 -- .../validation/BluePrintWorkflowValidatorImpl.kt | 79 --- .../services/javax.script.ScriptEngineFactory | 17 - .../core/CustomFunctionsTest.kt | 35 -- .../core/mock/MockBluePrintTypeValidatorService.kt | 59 -- .../core/service/BluePrintContextTest.kt | 53 -- .../core/service/BluePrintExpressionServiceTest.kt | 117 ---- .../core/service/BluePrintRepoFileServiceTest.kt | 57 -- .../core/service/BluePrintRuntimeServiceTest.kt | 144 ----- .../core/service/BluePrintTemplateServiceTest.kt | 35 -- .../BluePrintValidatorDefaultServiceTest.kt | 49 -- .../core/utils/BluePrintFileUtilsTest.kt | 59 -- .../core/utils/BluePrintMetadataUtilsTest.kt | 40 -- .../core/utils/JacksonUtilsTest.kt | 78 --- .../core/utils/TopologicalSortingUtilsTest.kt | 36 -- .../BluePrintValidatorServiceImplTest.kt | 101 ---- .../src/test/resources/componentnode/default.json | 100 ---- .../core/src/test/resources/data/alltype-data.json | 10 - .../src/test/resources/data/default-context.json | 7 - .../resources/dictionary/dictionary_schema.json | 261 --------- .../src/test/resources/properties/convert.json | 36 -- .../src/test/resources/properties/default.json | 16 - .../scripts/SampleBlueprintFunctionNode.kts | 44 -- .../test/resources/templates/base-config-data.json | 36 -- .../resources/templates/base-config-template.vtl | 61 -- components/parent/pom.xml | 12 - components/pom.xml | 3 +- .../node_type/source-component-java.json | 31 - .../load/model_type/node_type/source-default.json | 18 - .../load/model_type/node_type/source-input.json | 18 - .../model_type/node_type/source-primary-db.json | 44 -- .../load/model_type/node_type/source-rest.json | 61 -- .../node_type/tosca.nodes.ResourceSource.json | 5 - .../load/resource_dictionary/address.json | 17 - .../load/resource_dictionary/aic-cloud-region.json | 17 - .../load/resource_dictionary/aic_clli.json | 17 - .../resource_dictionary/availability_zone_0.json | 17 - .../load/resource_dictionary/default-source.json | 16 - .../load/resource_dictionary/input-source.json | 17 - .../load/resource_dictionary/mdsal-source.json | 34 -- .../load/resource_dictionary/name_0.json | 17 - .../load/resource_dictionary/nf-role.json | 25 - .../load/resource_dictionary/nfc-naming-code.json | 25 - .../resource_dictionary/onap_private_net_cidr.json | 21 - .../resource_dictionary/onap_private_net_id.json | 17 - .../resource_dictionary/primary-db-source.json | 24 - .../resource_dictionary/private-prefix-id.json | 21 - .../resource_dictionary/protected-prefix-id.json | 21 - .../protected_private_net_cidr.json | 21 - .../load/resource_dictionary/public_net_id.json | 17 - .../resource_dictionary/service-instance-id.json | 17 - .../resource_dictionary/unprotected-prefix-id.json | 21 - .../unprotected_private_net_cidr.json | 21 - .../load/resource_dictionary/vf-module-id.json | 17 - .../load/resource_dictionary/vf-module-label.json | 25 - .../vf-module-model-customization-uuid.json | 17 - .../load/resource_dictionary/vf-module-type.json | 25 - .../load/resource_dictionary/vf-naming-policy.json | 25 - .../load/resource_dictionary/vf-nf-code.json | 25 - .../load/resource_dictionary/vf_module_name.json | 17 - .../resource_dictionary/vfccustomizationuuid.json | 25 - .../load/resource_dictionary/vfw_private_ip_0.json | 35 -- .../load/resource_dictionary/vfw_private_ip_1.json | 35 -- .../load/resource_dictionary/vfw_private_ip_2.json | 17 - .../load/resource_dictionary/vm-type.json | 25 - .../load/resource_dictionary/vnf-id.json | 17 - .../vnf-model-customization-uuid.json | 17 - .../load/resource_dictionary/vnf-name.json | 28 - .../load/resource_dictionary/vnf_name.json | 28 - .../vnfc-model-invariant-uuid.json | 25 - .../resource_dictionary/vnfc-model-version.json | 25 - .../load/resource_dictionary/vpg_private_ip_0.json | 35 -- .../load/resource_dictionary/vpg_private_ip_1.json | 17 - .../load/resource_dictionary/vsn_private_ip_0.json | 35 -- .../load/resource_dictionary/vsn_private_ip_1.json | 17 - components/resource-dict/pom.xml | 44 -- .../resource/dict/ResourceDefinition.kt | 100 ---- .../resource/dict/ResourceDictionaryConstants.kt | 38 -- .../dict/factory/ResourceSourceMappingFactory.kt | 47 -- .../service/ResourceAssignmentValidationService.kt | 163 ------ .../service/ResourceDefinitionValidationService.kt | 113 ---- .../dict/utils/BulkResourceSequencingUtils.kt | 109 ---- .../resource/dict/utils/ResourceDictionaryUtils.kt | 94 ---- .../resource/dict/ResourceDefinitionTest.java | 60 -- .../factory/ResourceSourceMappingFactoryTest.java | 42 -- .../ResourceAssignmentValidationServiceTest.kt | 66 --- .../ResourceDefinitionValidationServiceTest.java | 56 -- .../utils/BulkResourceSequencingUtilsTest.java | 37 -- .../dict/utils/ResourceDictionaryUtilsTest.java | 99 ---- .../dict/utils/ResourceDictionaryTestUtils.kt | 30 - .../resources/data/resource-assignment-input.json | 10 - .../src/test/resources/validation/cyclic.json | 111 ---- .../src/test/resources/validation/duplicate.json | 110 ---- .../src/test/resources/validation/success.json | 110 ---- 166 files changed, 1 insertion(+), 11217 deletions(-) delete mode 100644 components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json delete mode 100644 components/core/load/model_type/artifact_type/artifact-directed-graph.json delete mode 100644 components/core/load/model_type/artifact_type/artifact-mapping-resource.json delete mode 100644 components/core/load/model_type/artifact_type/artifact-script-python.json delete mode 100644 components/core/load/model_type/artifact_type/artifact-template-velocity.json delete mode 100644 components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json delete mode 100644 components/core/load/model_type/data_type/datatype-property.json delete mode 100644 components/core/load/model_type/data_type/datatype-resource-assignment.json delete mode 100644 components/core/load/model_type/data_type/dt-license-key.json delete mode 100644 components/core/load/model_type/data_type/dt-v4-aggregate.json delete mode 100644 components/core/load/model_type/data_type/tosca.datatypes.Credential.json delete mode 100644 components/core/load/model_type/node_type/artifact-config-template.json delete mode 100644 components/core/load/model_type/node_type/component-config-generator.json delete mode 100644 components/core/load/model_type/node_type/component-netconf-executor.json delete mode 100644 components/core/load/model_type/node_type/component-resource-assignment.json delete mode 100644 components/core/load/model_type/node_type/dg-activate-netconf.json delete mode 100644 components/core/load/model_type/node_type/dg-config-generator.json delete mode 100644 components/core/load/model_type/node_type/dg-resource-assign-activate.json delete mode 100644 components/core/load/model_type/node_type/dg-resource-assignment.json delete mode 100644 components/core/load/model_type/node_type/tosca.nodes.Artifact.json delete mode 100644 components/core/load/model_type/node_type/tosca.nodes.Component.json delete mode 100644 components/core/load/model_type/node_type/tosca.nodes.DG.json delete mode 100644 components/core/load/model_type/node_type/tosca.nodes.Vnf.json delete mode 100644 components/core/load/model_type/node_type/tosca.nodes.component.Python.json delete mode 100644 components/core/load/model_type/node_type/vnf-netconf-device.json delete mode 100644 components/core/pom.xml delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt delete mode 100755 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt delete mode 100755 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt delete mode 100755 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt delete mode 100644 components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt delete mode 100644 components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt delete mode 100644 components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt delete mode 100644 components/core/src/test/resources/componentnode/default.json delete mode 100644 components/core/src/test/resources/data/alltype-data.json delete mode 100644 components/core/src/test/resources/data/default-context.json delete mode 100644 components/core/src/test/resources/dictionary/dictionary_schema.json delete mode 100644 components/core/src/test/resources/properties/convert.json delete mode 100644 components/core/src/test/resources/properties/default.json delete mode 100644 components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts delete mode 100755 components/core/src/test/resources/templates/base-config-data.json delete mode 100755 components/core/src/test/resources/templates/base-config-template.vtl delete mode 100644 components/resource-dict/load/model_type/node_type/source-component-java.json delete mode 100644 components/resource-dict/load/model_type/node_type/source-default.json delete mode 100644 components/resource-dict/load/model_type/node_type/source-input.json delete mode 100644 components/resource-dict/load/model_type/node_type/source-primary-db.json delete mode 100644 components/resource-dict/load/model_type/node_type/source-rest.json delete mode 100644 components/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json delete mode 100644 components/resource-dict/load/resource_dictionary/address.json delete mode 100644 components/resource-dict/load/resource_dictionary/aic-cloud-region.json delete mode 100644 components/resource-dict/load/resource_dictionary/aic_clli.json delete mode 100644 components/resource-dict/load/resource_dictionary/availability_zone_0.json delete mode 100644 components/resource-dict/load/resource_dictionary/default-source.json delete mode 100644 components/resource-dict/load/resource_dictionary/input-source.json delete mode 100644 components/resource-dict/load/resource_dictionary/mdsal-source.json delete mode 100644 components/resource-dict/load/resource_dictionary/name_0.json delete mode 100644 components/resource-dict/load/resource_dictionary/nf-role.json delete mode 100644 components/resource-dict/load/resource_dictionary/nfc-naming-code.json delete mode 100644 components/resource-dict/load/resource_dictionary/onap_private_net_cidr.json delete mode 100644 components/resource-dict/load/resource_dictionary/onap_private_net_id.json delete mode 100644 components/resource-dict/load/resource_dictionary/primary-db-source.json delete mode 100644 components/resource-dict/load/resource_dictionary/private-prefix-id.json delete mode 100644 components/resource-dict/load/resource_dictionary/protected-prefix-id.json delete mode 100644 components/resource-dict/load/resource_dictionary/protected_private_net_cidr.json delete mode 100644 components/resource-dict/load/resource_dictionary/public_net_id.json delete mode 100644 components/resource-dict/load/resource_dictionary/service-instance-id.json delete mode 100644 components/resource-dict/load/resource_dictionary/unprotected-prefix-id.json delete mode 100644 components/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf-module-id.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf-module-label.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf-module-type.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf-naming-policy.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf-nf-code.json delete mode 100644 components/resource-dict/load/resource_dictionary/vf_module_name.json delete mode 100644 components/resource-dict/load/resource_dictionary/vfccustomizationuuid.json delete mode 100644 components/resource-dict/load/resource_dictionary/vfw_private_ip_0.json delete mode 100644 components/resource-dict/load/resource_dictionary/vfw_private_ip_1.json delete mode 100644 components/resource-dict/load/resource_dictionary/vfw_private_ip_2.json delete mode 100644 components/resource-dict/load/resource_dictionary/vm-type.json delete mode 100644 components/resource-dict/load/resource_dictionary/vnf-id.json delete mode 100644 components/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json delete mode 100644 components/resource-dict/load/resource_dictionary/vnf-name.json delete mode 100644 components/resource-dict/load/resource_dictionary/vnf_name.json delete mode 100644 components/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json delete mode 100644 components/resource-dict/load/resource_dictionary/vnfc-model-version.json delete mode 100644 components/resource-dict/load/resource_dictionary/vpg_private_ip_0.json delete mode 100644 components/resource-dict/load/resource_dictionary/vpg_private_ip_1.json delete mode 100644 components/resource-dict/load/resource_dictionary/vsn_private_ip_0.json delete mode 100644 components/resource-dict/load/resource_dictionary/vsn_private_ip_1.json delete mode 100644 components/resource-dict/pom.xml delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt delete mode 100644 components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java delete mode 100644 components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java delete mode 100644 components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt delete mode 100644 components/resource-dict/src/test/resources/data/resource-assignment-input.json delete mode 100644 components/resource-dict/src/test/resources/validation/cyclic.json delete mode 100644 components/resource-dict/src/test/resources/validation/duplicate.json delete mode 100644 components/resource-dict/src/test/resources/validation/success.json diff --git a/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json deleted file mode 100644 index ac76b4f4f..000000000 --- a/components/core/load/model_type/artifact_type/artifact-bpmn-camunda.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Camunda BPM File", - "version": "1.0.0", - "file_ext": [ - "bpmn" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-directed-graph.json b/components/core/load/model_type/artifact_type/artifact-directed-graph.json deleted file mode 100644 index 7ab3a5434..000000000 --- a/components/core/load/model_type/artifact_type/artifact-directed-graph.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "description": "Directed Graph File", - "version": "1.0.0", - "file_ext": [ - "json", - "xml" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-mapping-resource.json b/components/core/load/model_type/artifact_type/artifact-mapping-resource.json deleted file mode 100644 index 0a3261b09..000000000 --- a/components/core/load/model_type/artifact_type/artifact-mapping-resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-script-python.json b/components/core/load/model_type/artifact_type/artifact-script-python.json deleted file mode 100644 index b48d2b628..000000000 --- a/components/core/load/model_type/artifact_type/artifact-script-python.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/artifact-template-velocity.json b/components/core/load/model_type/artifact_type/artifact-template-velocity.json deleted file mode 100644 index 9395d3970..000000000 --- a/components/core/load/model_type/artifact_type/artifact-template-velocity.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json b/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json deleted file mode 100644 index 5a7c95684..000000000 --- a/components/core/load/model_type/artifact_type/tosca.artifacts.Implementation.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "TOSCA base type for implementation artifacts", - "version": "1.0.0", - "derived_from": "tosca.artifacts.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/datatype-property.json b/components/core/load/model_type/data_type/datatype-property.json deleted file mode 100644 index 5584b10ea..000000000 --- a/components/core/load/model_type/data_type/datatype-property.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/datatype-resource-assignment.json b/components/core/load/model_type/data_type/datatype-resource-assignment.json deleted file mode 100644 index cc9816ebb..000000000 --- a/components/core/load/model_type/data_type/datatype-resource-assignment.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "status": { - "required": false, - "type": "string" - }, - "message": { - "required": false, - "type": "string" - }, - "updated-date": { - "required": false, - "type": "string" - }, - "updated-by": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/dt-license-key.json b/components/core/load/model_type/data_type/dt-license-key.json deleted file mode 100644 index e9c312b79..000000000 --- a/components/core/load/model_type/data_type/dt-license-key.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-plicense-key Data Type", - "properties": { - "license-key": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/dt-v4-aggregate.json b/components/core/load/model_type/data_type/dt-v4-aggregate.json deleted file mode 100644 index 842a7f805..000000000 --- a/components/core/load/model_type/data_type/dt-v4-aggregate.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-v4-aggregate Data Type", - "properties": { - "ipv4-address": { - "required": true, - "type": "string" - }, - "ipv4-plen": { - "required": false, - "type": "integer" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/data_type/tosca.datatypes.Credential.json b/components/core/load/model_type/data_type/tosca.datatypes.Credential.json deleted file mode 100644 index 820a55168..000000000 --- a/components/core/load/model_type/data_type/tosca.datatypes.Credential.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "1.0.0", - "description": "Credential", - "properties": { - "protocol": { - "required": false, - "type": "string" - }, - "token_type": { - "required": true, - "type": "string", - "default" : "password" - }, - "token": { - "required": false, - "type": "string" - }, - "keys": { - "required": false, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "user": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/artifact-config-template.json b/components/core/load/model_type/node_type/artifact-config-template.json deleted file mode 100644 index af99d75b8..000000000 --- a/components/core/load/model_type/node_type/artifact-config-template.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/component-config-generator.json b/components/core/load/model_type/node_type/component-config-generator.json deleted file mode 100644 index 9e86b8aed..000000000 --- a/components/core/load/model_type/node_type/component-config-generator.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "description": "This is Generate Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": { - "operations": { - "process": { - "inputs": { - "template-data": { - "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "template-content": { - "description": "Conditional : Dynamic Template used to generate Configuration.", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "action-name": { - "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "template-name": { - "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - } - }, - "outputs": { - "generated-config": { - "description": "Generated Configuration for the Template adn Resource Data", - "required": true, - "type": "string" - }, - "mask-info": { - "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.apps.controllerblueprints.core.data.custom.MaskInfo ", - "required": false, - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/component-netconf-executor.json b/components/core/load/model_type/node_type/component-netconf-executor.json deleted file mode 100644 index 7dcff5839..000000000 --- a/components/core/load/model_type/node_type/component-netconf-executor.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "description": "This is Netconf Transaction Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vnf-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "org-onap-ccsdk-netconf-adaptor-service-NetconfExecutorNode": { - "operations": { - "process": { - "inputs": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "service-template-name": { - "description": "Service Template Name", - "required": true, - "type": "string" - }, - "service-template-version": { - "description": "Service Template Version", - "required": true, - "type": "string" - }, - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-id": { - "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "reservation-id": { - "description": "Reservation Id used to send to NPM", - "required": false, - "type": "string" - }, - "execution-script": { - "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.", - "required": true, - "type": "string" - } - }, - "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" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/component-resource-assignment.json b/components/core/load/model_type/node_type/component-resource-assignment.json deleted file mode 100644 index 2a9035619..000000000 --- a/components/core/load/model_type/node_type/component-resource-assignment.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "service-template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "service-template-version": { - "description": "Service Template Version.", - "required": true, - "type": "string" - }, - "resource-type": { - "description": "Request type.", - "required": true, - "type": "string" - }, - "template-names": { - "description": "Name of the artifact Node Templates, to get the template Content.", - "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": true, - "type": "string" - }, - "action-name": { - "description": "Action Name of the process", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-activate-netconf.json b/components/core/load/model_type/node_type/dg-activate-netconf.json deleted file mode 100644 index 57667de98..000000000 --- a/components/core/load/model_type/node_type/dg-activate-netconf.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "description": "This is Download Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ActivateNetconf": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-config-generator.json b/components/core/load/model_type/node_type/dg-config-generator.json deleted file mode 100644 index e59c34b6e..000000000 --- a/components/core/load/model_type/node_type/dg-config-generator.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "This is Activate DG for Config Generator Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-config-generator", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "GenerateConfiguration": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-resource-assign-activate.json b/components/core/load/model_type/node_type/dg-resource-assign-activate.json deleted file mode 100644 index ca703a793..000000000 --- a/components/core/load/model_type/node_type/dg-resource-assign-activate.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "description": "This is Resource Assign and Activate Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "ra-component": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - }, - "netconf-component": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignAndActivate": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/dg-resource-assignment.json b/components/core/load/model_type/node_type/dg-resource-assignment.json deleted file mode 100644 index 9cce82a9e..000000000 --- a/components/core/load/model_type/node_type/dg-resource-assignment.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.Artifact.json b/components/core/load/model_type/node_type/tosca.nodes.Artifact.json deleted file mode 100644 index 814105277..000000000 --- a/components/core/load/model_type/node_type/tosca.nodes.Artifact.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Deprecated Artifact Node Type.", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.Component.json b/components/core/load/model_type/node_type/tosca.nodes.Component.json deleted file mode 100644 index bc4827b8b..000000000 --- a/components/core/load/model_type/node_type/tosca.nodes.Component.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is default Component Node", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.DG.json b/components/core/load/model_type/node_type/tosca.nodes.DG.json deleted file mode 100644 index 86728cf2f..000000000 --- a/components/core/load/model_type/node_type/tosca.nodes.DG.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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/core/load/model_type/node_type/tosca.nodes.Vnf.json b/components/core/load/model_type/node_type/tosca.nodes.Vnf.json deleted file mode 100644 index acb1f2f31..000000000 --- a/components/core/load/model_type/node_type/tosca.nodes.Vnf.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is VNF Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/tosca.nodes.component.Python.json b/components/core/load/model_type/node_type/tosca.nodes.component.Python.json deleted file mode 100644 index 7b67c8cb2..000000000 --- a/components/core/load/model_type/node_type/tosca.nodes.component.Python.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Python Component", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/components/core/load/model_type/node_type/vnf-netconf-device.json b/components/core/load/model_type/node_type/vnf-netconf-device.json deleted file mode 100644 index 54573bade..000000000 --- a/components/core/load/model_type/node_type/vnf-netconf-device.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "description": "This is VNF Device with Netconf Capability", - "version": "1.0.0", - "capabilities": { - "netconf": { - "type": "tosca.capability.Netconf", - "properties": { - "login-key": { - "required": true, - "type": "string", - "default": "sdnc" - }, - "login-account": { - "required": true, - "type": "string", - "default": "sdnc-tacacs" - }, - "source": { - "required": true, - "type": "string", - "default": "npm" - }, - "target-ip-address": { - "required": true, - "type": "string" - }, - "port-number": { - "required": true, - "type": "integer", - "default": 830 - }, - "connection-time-out": { - "required": false, - "type": "integer", - "default": 30 - } - } - } - }, - "derived_from": "tosca.nodes.Vnf" - -} diff --git a/components/core/pom.xml b/components/core/pom.xml deleted file mode 100644 index 03d46f493..000000000 --- a/components/core/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - 4.0.0 - - org.onap.ccsdk.apps.components - parent - 0.4.1-SNAPSHOT - ../parent - - org.onap.ccsdk.apps.controllerblueprints - core - Controller Blueprints Core - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - - - io.projectreactor - reactor-core - - - org.yaml - snakeyaml - - - org.apache.velocity - velocity - - - - org.jetbrains.kotlin - kotlin-test-junit - test - - - io.mockk - mockk - test - - - org.jetbrains.kotlinx - kotlinx-coroutines-test - test - - - - - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt deleted file mode 100644 index b1a7daad2..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -/** - * BluePrintConstants - * - * @author Brinda Santh - */ -object BluePrintConstants { - - const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" - const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" - const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" - const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" - - const val STATUS_SUCCESS: String = "success" - const val STATUS_PROCESSING: String = "processing" - const val STATUS_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" - - const val DATA_TYPE_STRING: String = "string" - const val DATA_TYPE_INTEGER: String = "integer" - const val DATA_TYPE_FLOAT: String = "float" - const val DATA_TYPE_DOUBLE: String = "double" - const val DATA_TYPE_BOOLEAN: String = "boolean" - const val DATA_TYPE_TIMESTAMP: String = "timestamp" - const val DATA_TYPE_NULL: String = "null" - const val DATA_TYPE_LIST: String = "list" - const val DATA_TYPE_MAP: String = "map" - - const val USER_SYSTEM: String = "System" - - const val PATH_DIVIDER: String = "/" - const val PATH_SERVICE_TEMPLATE: String = "service_template" - const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" - const val PATH_METADATA: String = "metadata" - const val PATH_NODE_TYPES: String = "node_types" - const val PATH_POLICY_TYPES: String = "policy_types" - const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" - const val PATH_ARTIFACT_TYPES: String = "artifact_types" - const val PATH_DATA_TYPES: String = "data_types" - const val PATH_INPUTS: String = "inputs" - const val PATH_NODE_WORKFLOWS: String = "workflows" - const val PATH_NODE_TEMPLATES: String = "node_templates" - const val PATH_CAPABILITIES: String = "capabilities" - const val PATH_REQUIREMENTS: String = "requirements" - const val PATH_INTERFACES: String = "interfaces" - const val PATH_OPERATIONS: String = "operations" - const val PATH_OUTPUTS: String = "outputs" - const val PATH_PROPERTIES: String = "properties" - const val PATH_ATTRIBUTES: String = "attributes" - const val PATH_ARTIFACTS: String = "artifacts" - - const val MODEL_DIR_MODEL_TYPE: String = "definition-type" - - const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" - const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" - const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" - const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" - const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" - - const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" - const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" - const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" - const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" - const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" - const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" - const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" - - const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" - const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" - const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" - const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" - const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" - - const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" - const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" - const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" - @Deprecated("Artifacts will be attached to Node Template") - const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" - const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" - - const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" - const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" - const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" - const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" - const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" - const val MODEL_TYPE_NODES_COMPONENT_KOTLIN: String = "tosca.nodes.component.Kotlin" - const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" - - const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" - - const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" - - const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" - const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" - const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" - const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" - const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" - const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" - const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" - // Custom capabilities - const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" - const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" - const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" - const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" - const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" - - const val EXPRESSION_GET_INPUT: String = "get_input" - const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" - const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" - const val EXPRESSION_GET_PROPERTY: String = "get_property" - const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" - const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" - - const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" - const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" - const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" - const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" - const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" - const val PROPERTY_BLUEPRINT_NAME: String = "template_name" - const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" - - const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" - const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" - const val TOSCA_DEFINITIONS_DIR: String = "Definitions" - const val TOSCA_PLANS_DIR: String = "Plans" - const val TOSCA_SCRIPTS_DIR: String = "Scripts" - const val TOSCA_MAPPINGS_DIR: String = "Mappings" - const val TOSCA_TEMPLATES_DIR: String = "Templates" - const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin" - - const val METADATA_USER_GROUPS = "user-groups" - const val METADATA_TEMPLATE_NAME = "template_name" - const val METADATA_TEMPLATE_VERSION = "template_version" - const val METADATA_TEMPLATE_AUTHOR = "template_author" - const val METADATA_TEMPLATE_TAGS = "template_tags" - const val METADATA_WORKFLOW_NAME = "workflow_name" - - const val PAYLOAD_DATA = "payload-data" - const val PROPERTY_CURRENT_STEP = "current-step" - const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" - const val PROPERTY_CURRENT_INTERFACE = "current-interface" - const val PROPERTY_CURRENT_OPERATION = "current-operation" - const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" - const val PROPERTY_EXECUTION_REQUEST = "execution-request" - - const val OPERATION_PROCESS = "process" - const val OPERATION_PREPARE = "prepare" - - const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" - const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" - const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt deleted file mode 100644 index ea5bda42e..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -class BluePrintError { - var errors: MutableList = arrayListOf() - - fun addError(type: String, name: String, error: String) { - this.errors.add("$type : $name : $error") - } - - fun addError(error: String) { - this.errors.add(error) - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt deleted file mode 100644 index 5c386c214..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core -/** - * - * - * @author Brinda Santh - */ -class BluePrintException : Exception { - - var code: Int = 100 - - constructor(cause: Throwable) : super(cause) - constructor(message: String) : super(message) - constructor(message: String, cause: Throwable) : super(message, cause) - constructor(cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause) - - constructor(code: Int, cause: Throwable) : super(cause) { - this.code = code - } - - constructor(code: Int, message: String) : super(message) { - this.code = code - } - - constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { - this.code = code - } - - constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) - : super(String.format(message, *args), cause) { - this.code = code - } -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt deleted file mode 100644 index 000062134..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -/** - * - * - * @author Brinda Santh - */ -class BluePrintProcessorException : RuntimeException { - var code: Int = 100 - - constructor(message: String, cause: Throwable) : super(message, cause) - constructor(message: String) : super(message) - constructor(cause: Throwable) : super(cause) - constructor(cause: Throwable, message: String, vararg args: Any?) : super(format(message, *args), cause) - - constructor(code: Int, cause: Throwable) : super(cause) { - this.code = code - } - - constructor(code: Int, message: String) : super(message) { - this.code = code - } - - constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { - this.code = code - } - - constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) - : super(String.format(message, *args), cause) { - this.code = code - } -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt deleted file mode 100644 index 4c35b53a2..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition - -/** - * - * - * @author Brinda Santh - */ -object BluePrintTypes { - - @JvmStatic - val validNodeTypeDerivedFroms: MutableList = arrayListOf( - BluePrintConstants.MODEL_TYPE_NODES_ROOT, - BluePrintConstants.MODEL_TYPE_NODE_DG, - BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, - BluePrintConstants.MODEL_TYPE_NODE_VNF, - BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT, - BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, - BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA, - BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE, - BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT, - BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON, - BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON, - BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT - ) - - @JvmStatic - val validArtifactTypeDerivedFroms: MutableList = arrayListOf( - BluePrintConstants.MODEL_TYPE_ARTIFACTS_ROOT, - BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION - ) - - @JvmStatic - val validDataTypeDerivedFroms: MutableList = arrayListOf( - BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, - BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC - ) - - @Deprecated("This has to move to Relationship Types Model Drive") - @JvmStatic - val validRelationShipDerivedFroms: MutableList = arrayListOf( - BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, - BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, - BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, - BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, - BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO, - BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO - ) - - @Deprecated("This has to move to Capability Types Model Drive") - @JvmStatic - val validCapabilityTypes: MutableList = arrayListOf( - BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH, - BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP - ) - - @JvmStatic - fun validModelTypes(): List { - val validTypes: MutableList = arrayListOf() - validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) - validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) - validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) - validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) - return validTypes - } - - @JvmStatic - fun validPropertyTypes(): List { - val validTypes: MutableList = arrayListOf() - validTypes.add(BluePrintConstants.DATA_TYPE_STRING) - validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) - validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) - validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) - validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) - validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) - validTypes.add(BluePrintConstants.DATA_TYPE_NULL) - validTypes.add(BluePrintConstants.DATA_TYPE_LIST) - validTypes.add(BluePrintConstants.DATA_TYPE_MAP) - return validTypes - } - - @JvmStatic - fun validPrimitiveTypes(): List { - val validTypes: MutableList = arrayListOf() - validTypes.add(BluePrintConstants.DATA_TYPE_STRING) - validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) - validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) - validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) - validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) - validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) - validTypes.add(BluePrintConstants.DATA_TYPE_NULL) - return validTypes - } - - @JvmStatic - fun validCollectionTypes(): List { - val validTypes: MutableList = arrayListOf() - validTypes.add(BluePrintConstants.DATA_TYPE_LIST) - validTypes.add(BluePrintConstants.DATA_TYPE_MAP) - return validTypes - } - - @JvmStatic - fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean { - val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL - return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type) - && BluePrintTypes.validPrimitiveTypes().contains(entrySchema) - } - - @JvmStatic - fun validCommands(): List { - return listOf(BluePrintConstants.EXPRESSION_GET_INPUT, - BluePrintConstants.EXPRESSION_GET_ATTRIBUTE, - BluePrintConstants.EXPRESSION_GET_PROPERTY, - BluePrintConstants.EXPRESSION_GET_ARTIFACT, - BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT, - BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE) - } - - @JvmStatic - fun rootNodeTypes(): List { - return listOf(BluePrintConstants.MODEL_TYPE_NODES_ROOT) - } - - @JvmStatic - fun rootDataTypes(): List { - return listOf(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT) - } - - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt deleted file mode 100644 index 5461798de..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -/** - * - * - * @author Brinda Santh - */ -object ConfigModelConstant { - - const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON" - const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE" - const val CAPABILITY_PROPERTY_MAPPING = "mapping" -} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt deleted file mode 100644 index 11f709c9a..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.BooleanNode -import com.fasterxml.jackson.databind.node.DoubleNode -import com.fasterxml.jackson.databind.node.IntNode -import com.fasterxml.jackson.databind.node.TextNode -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.slf4j.helpers.MessageFormatter -import java.io.File -import java.io.InputStream -import kotlin.reflect.KClass - -/** - * - * - * @author Brinda Santh - */ - -fun String.asJsonPrimitive(): TextNode { - return TextNode(this) -} - -fun Boolean.asJsonPrimitive(): BooleanNode { - return BooleanNode.valueOf(this) -} - -fun Int.asJsonPrimitive(): IntNode { - return IntNode.valueOf(this) -} - -fun Double.asJsonPrimitive(): DoubleNode { - return DoubleNode.valueOf(this) -} - -fun MutableMap.asJsonNode(): JsonNode { - return JacksonUtils.jsonNodeFromObject(this) -} - -fun format(message: String, vararg args: Any?): String { - if (args != null && args.isNotEmpty()) { - return MessageFormatter.arrayFormat(message, args).message - } - return message -} - -fun MutableMap.castOptionalValue(key: String, valueType: KClass): T? { - if (containsKey(key)) { - return get(key) as? T - } else { - return null - } -} - -fun MutableMap.castValue(key: String, valueType: KClass): T { - if (containsKey(key)) { - return get(key) as T - } else { - throw BluePrintException("couldn't find the key $key") - } -} - -fun MutableMap.putJsonElement(key: String, value: Any) { - when (value) { - is JsonNode -> - this[key] = value - is String -> - this[key] = TextNode(value) - is Boolean -> - this[key] = BooleanNode.valueOf(value) - is Int -> - this[key] = IntNode.valueOf(value.toInt()) - is Double -> - this[key] = DoubleNode.valueOf(value.toDouble()) - else -> - this[key] = JacksonUtils.jsonNodeFromObject(value) - } -} - -fun MutableMap.getAsString(key: String): String { - return this[key]?.asText() ?: throw BluePrintException("couldn't find value for key($key)") -} - -fun MutableMap.getAsBoolean(key: String): Boolean { - return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)") -} - -fun MutableMap.getAsInt(key: String): Int { - return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)") -} - -fun MutableMap.getAsDouble(key: String): Double { - return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)") -} - -// Checks - -fun checkNotEmpty(value: String?): Boolean { - return value != null && value.isNotBlank() -} - -fun checkNotEmptyOrThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean { - val notEmpty = checkNotEmpty(value) - if (!notEmpty) { - throw BluePrintException(message!!) - } - return notEmpty -} - -fun checkEqualsOrThrow(value1: String?, value2: String?, lazyMessage: () -> Any): Boolean { - if (value1.equals(value2, ignoreCase = true)) { - return true - } else { - throw BluePrintException(lazyMessage().toString()) - } -} - -fun nullToEmpty(value: String?): String { - return if (checkNotEmpty(value)) value!! else "" -} - -fun returnNotEmptyOrThrow(value: String?, lazyMessage: () -> Any): String { - if (checkNotEmpty(value)) { - return value!! - } else { - throw IllegalStateException(lazyMessage().toString()) - } -} - -fun InputStream.toFile(path: String): File { - val file = File(path) - file.outputStream().use { this.copyTo(it) } - return file -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt deleted file mode 100644 index 994ea5b7b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright © 2019 Bell Canada - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.common - -object ApplicationConstants { - const val ACTIVE_Y = "Y" - const val ACTIVE_N = "N" - const val ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL" -} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt deleted file mode 100644 index 235cfd56b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.config - -open class BluePrintLoadConfiguration { - - lateinit var blueprintDeployPath: String - lateinit var blueprintArchivePath: String - lateinit var blueprintEnrichmentPath: String - - var loadInitialData: Boolean = false - var loadBluePrint: Boolean = false - var loadBluePrintPaths: String? = null - - var loadModelType: Boolean = false - var loadModeTypePaths: String? = null - - var loadResourceDictionary: Boolean = false - var loadResourceDictionaryPaths: String? = null -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt deleted file mode 100644 index c0eb13f92..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.data - -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.ObjectNode -/** - * - * - * @author Brinda Santh - */ -data class ExpressionData( - var isExpression: Boolean = false, - var valueNode: JsonNode, - var expressionNode: ObjectNode? = null, - var inputExpression: InputExpression? = null, - var propertyExpression: PropertyExpression? = null, - var attributeExpression: AttributeExpression? = null, - var artifactExpression: ArtifactExpression? = null, - var operationOutputExpression: OperationOutputExpression? = null, - var command: String? = null -) - -data class InputExpression( - var propertyName: String -) - -data class PropertyExpression( - var modelableEntityName: String = "SELF", - var reqOrCapEntityName: String? = null, - var propertyName: String, - var subPropertyName: String? = null -) - -data class AttributeExpression( - var modelableEntityName: String = "SELF", - var reqOrCapEntityName: String? = null, - var attributeName: String, - var subAttributeName: String? = null -) - -data class ArtifactExpression( - val modelableEntityName: String = "SELF", - val artifactName: String, - val location: String? = "LOCAL_FILE", - val remove: Boolean? = false -) - -data class OperationOutputExpression( - val modelableEntityName: String = "SELF", - val interfaceName: String, - val operationName: String, - val propertyName: String -) - - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt deleted file mode 100644 index 663c1fe6c..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.data - -import com.fasterxml.jackson.annotation.JsonIgnore -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.annotation.JsonPropertyOrder -import com.fasterxml.jackson.databind.JsonNode -import io.swagger.annotations.ApiModelProperty - -/** - * - * - * @author Brinda Santh - */ -open class EntityType { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var version: String = "1.0.0" - var metadata: MutableMap? = null - @get:JsonProperty("derived_from") - lateinit var derivedFrom: String - var attributes: MutableMap? = null - var properties: MutableMap? = null -} - -/* - 5.3.2 tosca.datatypes.Credential - The Credential type is a complex TOSCA data Type used when describing - authorization credentials used to access network accessible resources. - */ -class Credential { - @get:JsonIgnore - var id: String? = null - var protocol: String? = null - @get:JsonProperty("token_type") - lateinit var tokenType: String - lateinit var token: String - var keys: MutableMap? = null - lateinit var user: String -} - -/* -3.5.2 Constraint clause -A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities. - */ -class ConstraintClause { - @get:JsonProperty("equal") - var equal: JsonNode? = null - @get:JsonProperty("greater_than") - var greaterThan: Any? = null - @get:JsonProperty("greater_or_equal") - var greaterOrEqual: Any? = null - @get:JsonProperty("less_than") - var lessThan: Any? = null - @get:JsonProperty("less_or_equal") - var lessOrEqual: Any? = null - @get:JsonProperty("in_range") - var inRange: Any? = null - @get:JsonProperty("valid_values") - var validValues: MutableList? = null - @get:JsonProperty("length") - var length: Any? = null - @get:JsonProperty("min_length") - var minLength: Any? = null - @get:JsonProperty("max_length") - var maxLength: Any? = null - var pattern: String? = null - var schema: String? = null -} - -/* -3.5.4 Node Filter definition -A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties. - */ - -class NodeFilterDefinition { - var properties: MutableMap? = null - var capabilities: MutableList? = null -} - -/* -3.5.5 Repository definition - A repository definition defines a named external repository which contains deployment - and implementation artifacts that are referenced within the TOSCA Service Template. -*/ -class RepositoryDefinition { - @get:JsonIgnore - var id: String? = null - var description: String? = null - lateinit var url: String - var credential: Credential? = null -} - - -/* -3.5.6 Artifact definition -An artifact definition defines a named, typed file that can be associated with Node Type -or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations. - */ -class ArtifactDefinition { - @get:JsonIgnore - var id: String? = null - var type: String? = null - var file: String? = null - var repository: String? = null - var description: String? = null - @get:JsonProperty("deploy_Path") - var deployPath: String? = null - var properties: MutableMap? = null - var content: String? = null - @Deprecated("Mapping content is define by the Type") - var mappingContent: String? = null -} - - -/* -3.5.7 Import definition -An import definition is used within a TOSCA Service Template to locate and uniquely name -another TOSCA Service Template file which has type and template definitions to be imported (included) -and referenced within another Service Template. - */ -class ImportDefinition { - @get:JsonIgnore - var id: String? = null - lateinit var file: String - var repository: String? = null - @get:JsonProperty("namespace_uri") - var namespaceUri: String? = null - @get:JsonProperty("namespace_prefix") - var namespacePrefix: String? = null -} - -/* -3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an -entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.). -Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are -instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates. - */ -class PropertyDefinition { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var required: Boolean? = null - lateinit var type: String - @get:JsonProperty("default") - var defaultValue: JsonNode? = null - var status: String? = null - var constraints: MutableList? = null - @get:JsonProperty("entry_schema") - var entrySchema: EntrySchema? = null - @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values") - var value: JsonNode? = null -} - - -/* -3.5.10 Attribute definition - -An attribute definition defines a named, typed value that can be associated with an entity defined in this -specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the -“actual state” of some property of a TOSCA entity after it has been deployed and instantiated -(as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function -from the instance model and used as values to other entities within TOSCA Service Templates. - */ - -class AttributeDefinition { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var required: Boolean? = null - lateinit var type: String - @JsonProperty("default") - var defaultValue: JsonNode? = null - var status: String? = null - var constraints: MutableList? = null - @JsonProperty("entry_schema") - var entrySchema: EntrySchema? = null -} - -/* -3.5.13 Operation definition -An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script). - */ -class OperationDefinition { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var implementation: Implementation? = null - var inputs: MutableMap? = null - var outputs: MutableMap? = null -} - -class Implementation { - lateinit var primary: String - var dependencies: MutableList? = null -} - -/* -3.5.14 Interface definition -An interface definition defines a named interface that can be associated with a Node or Relationship Type - */ -class InterfaceDefinition { - @get:JsonIgnore - var id: String? = null - var type: String? = null - var operations: MutableMap? = null - var inputs: MutableMap? = null -} - -/* -3.5.15 Event Filter definition -An event filter definition defines criteria for selection of an attribute, for the purpose of monitoring it, within a TOSCA entity, or one its capabilities. - */ -class EventFilterDefinition { - @get:JsonIgnore - var id: String? = null - lateinit var node: String - var requirement: String? = null - var capability: String? = null -} - -/* -3.5.16 Trigger definition TODO -A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with. - */ -class TriggerDefinition { - @get:JsonIgnore - var id: String? = null - var description: String? = null - @get:JsonProperty("event_type") - lateinit var eventType: String - @get:JsonProperty("target_filter") - var targetFilter: EventFilterDefinition? = null - var condition: ConditionClause? = null - var constraint: ConditionClause? = null - var method: String? = null - lateinit var action: String -} - -/* - 3.5.17 Workflow activity definition - A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to: - · Delegate the workflow for a node expected to be provided by the orchestrator - · Set the state of a node - · Call an operation defined on a TOSCA interface of a node, relationship or group - · Inline another workflow defined in the topology (to allow reusability) - */ -class Activity { - var delegate: String? = null - @get:JsonProperty("set_state") - var setState: String? = null - @get:JsonProperty("call_operation") - var callOperation: String? = null - var inlines: ArrayList? = null -} - -/* -3.5.20 Workflow precondition definition -A workflow condition can be used as a filter or precondition to check if a workflow can be processed or not based on the state of the instances of a TOSCA topology deployment. When not met, the workflow will not be triggered. - */ -class PreConditionDefinition { - @get:JsonIgnore - var id: String? = null - lateinit var target: String - @get:JsonProperty("target_relationship") - lateinit var targetRelationship: String - lateinit var condition: ArrayList -} - -/* -3.5.21 Workflow step definition -A workflow step allows to define one or multiple sequenced activities in a workflow and how they are connected to other steps in the workflow. They are the building blocks of a declarative workflow. - */ -class Step { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var target: String? = null - @JsonProperty("target_relationship") - var targetRelationship: String? = null - @JsonProperty("operation_host") - var operationHost: String? = null - var activities: ArrayList? = null - @get:JsonProperty("on_success") - var onSuccess: ArrayList? = null - @get:JsonProperty("on_failure") - var onFailure: ArrayList? = null -} - -/* -3.6.2 Capability definition -A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes. - */ - -class CapabilityDefinition { - @get:JsonIgnore - var id: String? = null - lateinit var type: String - var description: String? = null - var properties: MutableMap? = null - @get:JsonProperty("valid_source_types") - var validSourceTypes: MutableList? = null - var occurrences: MutableList? = null -} - -/* -3.6.3 Requirement definition -The Requirement definition describes a named requirement (dependencies) of a TOSCA Node Type or Node template which needs to be fulfilled by a matching Capability definition declared by another TOSCA modelable entity. The requirement definition may itself include the specific name of the fulfilling entity (explicitly) or provide an abstract type, along with additional filtering characteristics, that a TOSCA orchestrator can use to fulfill the capability at runtime (implicitly). - */ -class RequirementDefinition { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var capability: String? = null - var node: String? = null - var relationship: String? = null - var occurrences: MutableList? = null -} - -/* -3.6.4 Artifact Type -An Artifact Type is a reusable entity that defines the type of one or more files that are used to define implementation or deployment artifacts that are referenced by nodes or relationships on their operations. - */ -class ArtifactType : EntityType() { - @get:JsonProperty("mime_type") - var mimeType: String? = null - @get:JsonProperty("file_ext") - var fileExt: MutableList? = null - -} - -/* -3.6.6 Data Type -A Data Type definition defines the schema for new named datatypes in TOSCA. - */ - -class DataType : EntityType() { - var constraints: MutableList? = null -} - -/* -3.6.9 Node Type -A Node Type is a reusable entity that defines the type of one or more Node Templates. As such, a Node Type defines the structure of observable properties via a Properties Definition, the Requirements and Capabilities of the node as well as its supported interfaces. - - */ - -class NodeType : EntityType() { - var capabilities: MutableMap? = null - var requirements: MutableMap? = null - var interfaces: MutableMap? = null - var artifacts: MutableMap? = null -} - -/* -3.6.8 Requirement Type -A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose. The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types along with a named Feature notation. - */ - -class RequirementType : EntityType() { - var requirements: MutableMap? = null - var capabilities: MutableMap? = null - var interfaces: MutableMap? = null - var artifacts: MutableMap? = null -} - -/* -3.6.10 Relationship Type -A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates. -*/ - -class RelationshipType : EntityType() { - var interfaces: MutableMap? = null - @get:JsonProperty("valid_target_types") - var validTargetTypes: ArrayList? = null -} - -/* -3.6.11 Group Type -A Group Type defines logical grouping types for nodes, typically for different management purposes. -Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology - of an application, yet can have capabilities and the ability to attach policies and interfaces - that can be applied (depending on the group type) to its member nodes. - */ - -class GroupType : EntityType() { - var members: MutableList? = null - var requirements: ArrayList? = null - var capabilities: MutableMap? = null - var interfaces: MutableMap? = null - -} - -/* - 3.6.12 Policy Type - A Policy Type defines a type of requirement that affects or governs an application or service’s - topology at some stage of its lifecycle, but is not explicitly part of the topology itself - (i.e., it does not prevent the application or service from being deployed or run if it did not exist). - */ -class PolicyType : EntityType() { - lateinit var targets: MutableList -} - -/* -3.7.1 Capability assignment -A capability assignment allows node template authors to assign values to properties and attributes for a named capability definition that is part of a Node Template’s type definition. - */ -class CapabilityAssignment { - @get:JsonIgnore - var id: String? = null - var attributes: MutableMap? = null - var properties: MutableMap? = null -} - -/* -3.7.4 Relationship Template -A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations. - */ -class GroupDefinition { - @get:JsonIgnore - var id: String? = null - lateinit var type: String - var description: String? = null - var metadata: MutableMap? = null - var properties: MutableMap? = null - var members = ArrayList() - var interfaces: MutableMap? = null -} - -/* -3.7.6 Policy definition -A policy definition defines a policy that can be associated with a TOSCA topology or top-level entity definition (e.g., group definition, node template, etc.). - */ -class PolicyDefinition { - @get:JsonIgnore - var id: String? = null - lateinit var type: String - var description: String? = null - var metadata: MutableMap? = null - var properties: MutableMap? = null - var targets: MutableList? = null -} - - -/* -3.8 Topology Template definition -This section defines the topology template of a cloud application. The main ingredients of the topology template are node templates representing components of the application and relationship templates representing links between the components. These elements are defined in the nested node_templates section and the nested relationship_templates sections, respectively. Furthermore, a topology template allows for defining input parameters, output parameters as well as grouping of node templates. - */ -class TopologyTemplate { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var inputs: MutableMap? = null - @get:JsonProperty("node_templates") - var nodeTemplates: MutableMap? = null - @get:JsonProperty("relationship_templates") - var relationshipTemplates: MutableMap? = null - var policies: MutableMap? = null - var outputs: MutableMap? = null - @get:JsonProperty("substitution_mappings") - var substitutionMappings: Any? = null - var workflows: MutableMap? = null -} - -class SubstitutionMapping { - @get:JsonProperty("node_type") - lateinit var nodeType: String - lateinit var capabilities: ArrayList - lateinit var requirements: ArrayList -} - -class EntrySchema { - lateinit var type: String - var constraints: MutableList? = null -} - -class InterfaceAssignment { - @get:JsonIgnore - var id: String? = null - var operations: MutableMap? = null - var inputs: MutableMap? = null -} - -/* -3.7.3 Node Template -A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations. - */ - -open class NodeTemplate { - @get:JsonIgnore - var id: String? = null - var description: String? = null - lateinit var type: String - var metadata: MutableMap? = null - var directives: MutableList? = null - //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class) - var properties: MutableMap? = null - var attributes: MutableMap? = null - var capabilities: MutableMap? = null - var requirements: MutableMap? = null - var interfaces: MutableMap? = null - var artifacts: MutableMap? = null - @get:JsonProperty("node_filter") - var nodeFilter: NodeFilterDefinition? = null - var copy: String? = null -} - -class OperationAssignment { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var implementation: Implementation? = null - var inputs: MutableMap? = null - var outputs: MutableMap? = null -} - -/* -3.7.4 Relationship Template -A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations. - */ - -class RelationshipTemplate { - var type: String? = null - var description: String? = null - var metadata: MutableMap? = null - var properties: MutableMap? = null - var attributes: MutableMap? = null - var interfaces: MutableMap? = null - var copy: String? = null -} - -/* -3.7.2 Requirement assignment -A Requirement assignment allows template authors to provide either concrete names of TOSCA templates or provide abstract selection criteria for providers to use to find matching TOSCA templates that are used to fulfill a named requirement’s declared TOSCA Node Type. - */ - -class RequirementAssignment { - @get:JsonIgnore - var id: String? = null - var capability: String? = null - var node: String? = null - //Relationship Type or Relationship Template - var relationship: String? = null -} - - -class Workflow { - @get:JsonIgnore - var id: String? = null - var description: String? = null - var steps: MutableMap? = null - var preconditions: ArrayList? = null - var inputs: MutableMap? = null -} - - -class ConditionClause { - var and: ArrayList>? = null - var or: ArrayList>? = null - @get:JsonProperty("assert") - var assertConditions: ArrayList>? = null -} - -/* -3.9 Service Template definition -A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document. - */ - -@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"]) -class ServiceTemplate : Cloneable { - @get:JsonIgnore - var id: String? = null - @get:JsonProperty("tosca_definitions_version") - var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0" - var metadata: MutableMap? = null - var description: String? = null - @get:JsonProperty("dsl_definitions") - var dslDefinitions: MutableMap? = null - var repositories: MutableMap? = null - var imports: MutableList? = null - @get:JsonProperty("artifact_types") - var artifactTypes: MutableMap? = null - @get:JsonProperty("data_types") - var dataTypes: MutableMap? = null - @get:JsonProperty("relationship_types") - var relationshipTypes: MutableMap? = null - @get:JsonProperty("node_types") - var nodeTypes: MutableMap? = null - @get:JsonProperty("policy_types") - var policyTypes: MutableMap? = null - @get:JsonProperty("topology_template") - var topologyTemplate: TopologyTemplate? = null - - override public fun clone(): ServiceTemplate { - return super.clone() as ServiceTemplate - } -} - -class ToscaMetaData { - lateinit var toscaMetaFileVersion: String - lateinit var csarVersion: String - lateinit var createdBy: String - lateinit var entityDefinitions: String - var templateTags: String? = null -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt deleted file mode 100644 index bef174b9d..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright © 2018-2019 Bell Canada Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.ccsdk.apps.controllerblueprints.core.data - -import java.util.HashMap - -/** - * ErrorCode.java Purpose: Maintain a list of HTTP status codes - * - * @author Steve Siani - * @version 1.0 - */ -enum class ErrorCode (val value: Int, val httpCode: Int) { - - /// TODO: Add more attribute for each needed application protocol - // TODO: Example: INVALID_FILE_EXTENSION(2, 415, 25) - GENERIC_FAILURE(1, 500) { - override fun message(detailMsg: String): String { - return "Generic failure. Details : {$detailMsg}" - } - }, - INVALID_FILE_EXTENSION(2, 415) { - override fun message(detailMsg: String): String { - return "Unexpected file extension. Details : {$detailMsg}" - } - }, - BLUEPRINT_PATH_MISSING(3, 503) { - override fun message(detailMsg: String): String { - return "Blueprint path missing or wrong. Details : {$detailMsg}" - } - }, - BLUEPRINT_WRITING_FAIL(4, 503) { - override fun message(detailMsg: String): String { - return "Fail to write blueprint files. Details : {$detailMsg}" - } - }, - IO_FILE_INTERRUPT(5, 503) { - override fun message(detailMsg: String): String { - return "IO file system interruption. Details : {$detailMsg}" - } - }, - INVALID_REQUEST_FORMAT(6, 400) { - override fun message(detailMsg: String): String { - return "Bad request. Details : {$detailMsg}" - } - }, - UNAUTHORIZED_REQUEST(7, 401) { - override fun message(detailMsg: String): String { - return "The request requires user authentication. Details : {$detailMsg}" - } - }, - REQUEST_NOT_FOUND(8, 404) { - override fun message(detailMsg: String): String { - return "Request mapping doesn't exist. Details : {$detailMsg}" - } - }, - RESOURCE_NOT_FOUND(9, 404) { - override fun message(detailMsg: String): String { - return "No response was found for this request in the server. Details : {$detailMsg}" - } - }, - CONFLICT_ADDING_RESOURCE(10, 409) { - override fun message(detailMsg: String): String { - return "Duplicated entry while saving Blueprint. Details : {$detailMsg}" - } - }; - - abstract fun message(detailMsg: String): String - - companion object { - - private val map = HashMap() - - init { - for (errorCode in ErrorCode.values()) { - map[errorCode.value] = errorCode - } - } - - fun valueOf(value: Int): ErrorCode? { - return if (map.containsKey(value)) map[value] else map[1] - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt deleted file mode 100644 index 63f788a2f..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.factory - - -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorService - -/** - * - * - * @author Brinda Santh - */ - -object BluePrintValidatorFactory { - - var bluePrintValidatorServices: MutableMap = HashMap() - - init { - bluePrintValidatorServices[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT] = BluePrintValidatorDefaultService() - } - - fun register(key:String, bluePrintValidatorService: BluePrintValidatorService){ - bluePrintValidatorServices[key] = bluePrintValidatorService - } - - fun instance(key : String) : BluePrintValidatorService?{ - return bluePrintValidatorServices[key] - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt deleted file mode 100755 index c99cdf749..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.interfaces - -import org.jetbrains.annotations.NotNull -import org.jetbrains.annotations.Nullable -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import java.io.File -import java.nio.file.Path - -interface BluePrintCatalogService { - - /** - * Save the CBA to database. - * @param blueprintFile Either a directory, or an archive - * @param validate whether to validate blueprint content. Default true. - * @return The unique blueprint identifier - * @throws BluePrintException if process failed - */ - @NotNull - @Throws(BluePrintException::class) - fun saveToDatabase(@NotNull blueprintFile: File, @Nullable validate: Boolean = true): String - - /** - * Retrieve the CBA from database either archived or extracted. - * @param name Name of the blueprint - * @param version Version of the blueprint - * @param extract true to extract the content, false for archived content. Default to true - * @return Path where CBA is located - * @throws BluePrintException if process failed - */ - @NotNull - @Throws(BluePrintException::class) - fun getFromDatabase(@NotNull name: String, @NotNull version: String, @Nullable extract: Boolean = true): Path - - /** - * Delete the CBA from database. - * @param name Name of the blueprint - * @param version Version of the blueprint - * @throws BluePrintException if process failed - */ - @NotNull - @Throws(BluePrintException::class) - fun deleteFromDatabase(@NotNull name: String, @NotNull version: String) -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt deleted file mode 100644 index f01f12620..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.interfaces - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -interface BluePrintEnhancer { - fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) -} - -interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer - -interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer - -interface BluePrintWorkflowEnhancer : BluePrintEnhancer - -interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer - -interface BluePrintNodeTypeEnhancer : BluePrintEnhancer - -interface BluePrintArtifactDefinitionEnhancer : BluePrintEnhancer - -interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer - -interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer - -interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer - - -interface BluePrintEnhancerService { - - @Throws(BluePrintException::class) - fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext - - @Throws(BluePrintException::class) - fun enhance(basePath: String): BluePrintContext -} - -interface BluePrintTypeEnhancerService { - - fun getServiceTemplateEnhancers(): List - - fun getTopologyTemplateEnhancers(): List - - fun getWorkflowEnhancers(): List - - fun getNodeTemplateEnhancers(): List - - fun getNodeTypeEnhancers(): List - - fun getArtifactDefinitionEnhancers(): List - - fun getPolicyTypeEnhancers(): List - - fun getPropertyDefinitionEnhancers(): List - - fun getAttributeDefinitionEnhancers(): List - - fun enhanceServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { - val enhancers = getServiceTemplateEnhancers() - doEnhancement(bluePrintRuntimeService, name, serviceTemplate, enhancers) - } - - fun enhanceTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { - val enhancers = getTopologyTemplateEnhancers() - doEnhancement(bluePrintRuntimeService, name, topologyTemplate, enhancers) - } - - fun enhanceWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { - val enhancers = getWorkflowEnhancers() - doEnhancement(bluePrintRuntimeService, name, workflow, enhancers) - } - - fun enhanceNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { - val enhancers = getNodeTemplateEnhancers() - doEnhancement(bluePrintRuntimeService, name, nodeTemplate, enhancers) - } - - fun enhanceNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { - val enhancers = getNodeTypeEnhancers() - doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers) - } - - fun enhanceArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) { - val enhancers = getArtifactDefinitionEnhancers() - doEnhancement(bluePrintRuntimeService, name, artifactDefinition, enhancers) - } - - fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) { - val enhancers = getPolicyTypeEnhancers() - doEnhancement(bluePrintRuntimeService, name, policyType, enhancers) - } - - fun enhancePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap) { - properties.forEach { propertyName, propertyDefinition -> - enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) - } - } - - fun enhancePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { - val enhancers = getPropertyDefinitionEnhancers() - doEnhancement(bluePrintRuntimeService, name, propertyDefinition, enhancers) - } - - fun enhanceAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap) { - attributes.forEach { attributeName, attributeDefinition -> - enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) - } - } - - fun enhanceAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { - val enhancers = getAttributeDefinitionEnhancers() - doEnhancement(bluePrintRuntimeService, name, attributeDefinition, enhancers) - } - - @Suppress("UNCHECKED_CAST") - private fun doEnhancement(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, enhancers: List>) { - if (enhancers.isNotEmpty()) { - enhancers.forEach { - it.enhance(bluePrintRuntimeService, name, definition as T) - } - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt deleted file mode 100644 index efcb0c38b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.interfaces - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import java.io.Serializable - -/** - * BluePrintRepoFileService - * @author Brinda Santh - * - */ - -interface BluePrintRepoService : Serializable { - - @Throws(BluePrintException::class) - fun getNodeType(nodeTypeName: String): NodeType - - @Throws(BluePrintException::class) - fun getDataType(dataTypeName: String): DataType - - @Throws(BluePrintException::class) - fun getArtifactType(artifactTypeName: String): ArtifactType - - @Throws(BluePrintException::class) - fun getRelationshipType(relationshipTypeName: String): RelationshipType - - @Throws(BluePrintException::class) - fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt deleted file mode 100644 index 124c167a8..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.interfaces - -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext - -interface BluePrintScriptsService{ - - fun scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String, - reCompile: Boolean): T -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt deleted file mode 100644 index 0b9f1f182..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.interfaces - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import java.util.function.Function - - -interface BlueprintFunctionNode : Function { - - fun getName(): String - - @Throws(BluePrintProcessorException::class) - fun prepareRequest(executionRequest: T): T - - @Throws(BluePrintProcessorException::class) - fun process(executionRequest: T) - - @Throws(BluePrintProcessorException::class) - fun recover(runtimeException: RuntimeException, executionRequest: T) - - @Throws(BluePrintProcessorException::class) - fun prepareResponse(): R - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt deleted file mode 100644 index bea790fd3..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt +++ /dev/null @@ -1,132 +0,0 @@ -package org.onap.ccsdk.apps.controllerblueprints.core.interfaces - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - - -interface BluePrintValidator { - - fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) - -} - - -interface BluePrintServiceTemplateValidator : BluePrintValidator - -interface BluePrintTopologyTemplateValidator : BluePrintValidator - -interface BluePrintArtifactTypeValidator : BluePrintValidator - -interface BluePrintDataTypeValidator : BluePrintValidator - -interface BluePrintNodeTypeValidator : BluePrintValidator - -interface BluePrintNodeTemplateValidator : BluePrintValidator - -interface BluePrintWorkflowValidator : BluePrintValidator - -interface BluePrintPropertyDefinitionValidator : BluePrintValidator - -interface BluePrintAttributeDefinitionValidator : BluePrintValidator - -/** - * Blueprint Validation Interface. - */ -interface BluePrintValidatorService { - - @Throws(BluePrintException::class) - fun validateBluePrints(basePath: String): Boolean - - @Throws(BluePrintException::class) - fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean -} - - -interface BluePrintTypeValidatorService { - - fun getServiceTemplateValidators(): List - - fun getDataTypeValidators(): List - - fun getArtifactTypeValidators(): List - - fun getNodeTypeValidators(): List - - fun getTopologyTemplateValidators(): List - - fun getNodeTemplateValidators(): List - - fun getWorkflowValidators(): List - - fun getPropertyDefinitionValidators(): List - - fun getAttributeDefinitionValidators(): List - - fun validateServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { - val validators = getServiceTemplateValidators() - doValidation(bluePrintRuntimeService, name, serviceTemplate, validators) - } - - fun validateArtifactType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { - val validators = getArtifactTypeValidators() - doValidation(bluePrintRuntimeService, name, artifactType, validators) - } - - fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { - val validators = getDataTypeValidators() - doValidation(bluePrintRuntimeService, name, dataType, validators) - } - - fun validateNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { - val validators = getNodeTypeValidators() - doValidation(bluePrintRuntimeService, name, nodeType, validators) - } - - fun validateTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { - val validators = getTopologyTemplateValidators() - doValidation(bluePrintRuntimeService, name, topologyTemplate, validators) - } - - fun validateNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { - val validators = getNodeTemplateValidators() - doValidation(bluePrintRuntimeService, name, nodeTemplate, validators) - } - - fun validateWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { - val validators = getWorkflowValidators() - doValidation(bluePrintRuntimeService, name, workflow, validators) - } - - fun validatePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap) { - properties.forEach { propertyName, propertyDefinition -> - validatePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) - } - } - - fun validatePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { - val validators = getPropertyDefinitionValidators() - doValidation(bluePrintRuntimeService, name, propertyDefinition, validators) - } - - fun validateAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap) { - attributes.forEach { attributeName, attributeDefinition -> - validateAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) - } - } - - fun validateAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { - val validators = getAttributeDefinitionValidators() - doValidation(bluePrintRuntimeService, name, attributeDefinition, validators) - } - - @Suppress("UNCHECKED_CAST") - private fun doValidation(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, validators: List>) { - validators.forEach { - it.validate(bluePrintRuntimeService, name, definition as T) - } - } -} - - - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt deleted file mode 100644 index 065176342..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -/** - * - * - * @author Brinda Santh - */ -class BluePrintChainedService { - var bpc : BluePrintContext - - constructor(bpc : BluePrintContext){ - this.bpc = bpc - } - - fun nodeTypeChained(nodeTypeName: String): NodeType { - - val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) - val attributes = hashMapOf() - val properties = hashMapOf() - val requirements = hashMapOf() - val capabilities = hashMapOf() - val interfaces = hashMapOf() - val artifacts = hashMapOf() - - recNodeTypesChained(nodeTypeName).forEach { nodeType -> - - val subAttributes = bpc.nodeTypeByName(nodeType.id!!).attributes - if (subAttributes != null) { - attributes.putAll(subAttributes) - } - - val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties - if (subProperties != null) { - properties.putAll(subProperties) - } - - val subRequirements = bpc.nodeTypeByName(nodeType.id!!).requirements - if (subRequirements != null) { - requirements.putAll(subRequirements) - } - val subCapabilities = bpc.nodeTypeByName(nodeType.id!!).capabilities - if (subCapabilities != null) { - capabilities.putAll(subCapabilities) - } - val subInterfaces = bpc.nodeTypeByName(nodeType.id!!).interfaces - if (subInterfaces != null) { - interfaces.putAll(subInterfaces) - } - - val subArtifacts = bpc.nodeTypeByName(nodeType.id!!).artifacts - if (subArtifacts != null) { - artifacts.putAll(subArtifacts) - } - } - nodeType.attributes = attributes - nodeType.properties = properties - nodeType.requirements = requirements - nodeType.capabilities = capabilities - nodeType.interfaces = interfaces - nodeType.artifacts = artifacts - return nodeType - } - - fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap? { - val nodeType = bpc.nodeTypeByName(nodeTypeName) - val properties = hashMapOf() - - recNodeTypesChained(nodeTypeName).forEach { nodeType -> - val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties - if (subProperties != null) { - properties.putAll(subProperties) - } - } - return properties - } - - private fun recNodeTypesChained(nodeTypeName: String, nodeTypes: MutableList? = arrayListOf()): MutableList { - val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) - nodeType.id = nodeTypeName - val derivedFrom: String = nodeType.derivedFrom - if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { - recNodeTypesChained(derivedFrom, nodeTypes) - } - nodeTypes!!.add(nodeType) - return nodeTypes - } - - private fun recDataTypesChained(dataTypeName: String, dataTypes: MutableList? = arrayListOf()): MutableList { - val dataType: DataType = bpc.dataTypeByName(dataTypeName)!! - dataType.id = dataTypeName - val derivedFrom: String = dataType.derivedFrom - if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) { - recDataTypesChained(derivedFrom, dataTypes) - } - dataTypes!!.add(dataType) - return dataTypes - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt deleted file mode 100644 index 793604514..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@file:Suppress("unused") - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils - -/** - * - * - * @author Brinda Santh - */ -class BluePrintContext(val serviceTemplate: ServiceTemplate) { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - /** - * Blueprint CBA extracted file location - */ - var rootPath = "." - /** - * Root Definition file path - */ - var entryDefinition = "" - - val imports: List? = serviceTemplate.imports - - val metadata: MutableMap? = serviceTemplate.metadata - - val dataTypes: MutableMap? = serviceTemplate.dataTypes - - val inputs: MutableMap? = serviceTemplate.topologyTemplate?.inputs - - fun blueprintJson(pretty: Boolean = false): String = print("json", pretty) - - private fun print(type: String? = "json", pretty: Boolean = false): String { - return JacksonUtils.getJson(serviceTemplate, pretty) - } - - fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME) - ?: throw BluePrintException("could't get template name from meta data") - - fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION) - ?: throw BluePrintException("could't get template version from meta data") - - fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR) - ?: throw BluePrintException("could't get template author from meta data") - - // Workflow - val workflows: MutableMap? = serviceTemplate.topologyTemplate?.workflows - - fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName) - ?: throw BluePrintException("could't get workflow($workFlowName)") - - fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs - - fun workflowStepByName(workFlowName: String, stepName: String): Step { - return workflowByName(workFlowName).steps?.get(stepName) - ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)") - } - - fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String { - return workflowStepByName(workFlowName, stepName).target - ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)") - } - - fun workflowFirstStepNodeTemplate(workFlowName: String): String { - val firstStepName = workflowByName(workFlowName).steps?.keys?.first() - ?: throw BluePrintException("could't get first step for workflow($workFlowName)") - return workflowStepNodeTemplate(workFlowName, firstStepName) - } - - fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String { - return workflowStepByName(workFlowName, stepName).activities?.filter { it.callOperation != null }?.single()?.callOperation - ?: throw BluePrintException("could't get first callOperation for WorkFlow($workFlowName) ") - } - - // Data Type - fun dataTypeByName(name: String): DataType? = dataTypes?.get(name) - - // Artifact Type - val artifactTypes: MutableMap? = serviceTemplate.artifactTypes - - // Policy Types - val policyTypes: MutableMap? = serviceTemplate.policyTypes - - fun policyTypeByName(policyName: String) = policyTypes?.get(policyName) - ?: throw BluePrintException("could't get policy type for the name($policyName)") - - fun policyTypesDerivedFrom(name: String): MutableMap? { - return policyTypes?.filterValues { policyType -> policyType.derivedFrom == name }?.toMutableMap() - } - - fun policyTypesTarget(target: String): MutableMap? { - return policyTypes?.filterValues { it.targets.contains(target) }?.toMutableMap() - } - - fun policyTypesTargetNDerivedFrom(target: String, derivedFrom: String): MutableMap? { - return policyTypesDerivedFrom(derivedFrom)?.filterValues { - it.targets.contains(target) - }?.toMutableMap() - } - - // Node Type Methods - val nodeTypes: MutableMap? = serviceTemplate.nodeTypes - - fun nodeTypeByName(name: String): NodeType = - nodeTypes?.get(name) - ?: throw BluePrintException("could't get node type for the name($name)") - - fun nodeTypeDerivedFrom(name: String): MutableMap? { - return nodeTypes?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap() - } - - fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition { - return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName) - ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)") - } - - fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition { - return nodeTypeInterface(nodeTypeName, interfaceName).operations?.get(operationName) - ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)") - } - - fun interfaceNameForNodeType(nodeTypeName: String): String { - return nodeTypeByName(nodeTypeName).interfaces?.keys?.first() - ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name") - } - - fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).inputs - } - - fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).outputs - } - - // Node Template Methods - val nodeTemplates: MutableMap? = serviceTemplate.topologyTemplate?.nodeTemplates - - fun nodeTemplateByName(name: String): NodeTemplate = - nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") - - fun nodeTemplateForNodeType(name: String): MutableMap? { - return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() - } - - fun nodeTemplateNodeType(nodeTemplateName: String): NodeType { - val nodeTemplateType: String = nodeTemplateByName(nodeTemplateName).type - return nodeTypeByName(nodeTemplateType) - } - - fun nodeTemplateProperty(nodeTemplateName: String, propertyName: String): Any? { - return nodeTemplateByName(nodeTemplateName).properties?.get(propertyName) - } - - fun nodeTemplateArtifacts(nodeTemplateName: String): MutableMap? { - return nodeTemplateByName(nodeTemplateName).artifacts - } - - fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition { - return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName) - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)") - } - - fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition { - return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0) - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)") - } - - fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment { - return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first() - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment") - } - - fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String { - return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first() - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name") - } - - fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String { - return nodeTemplateFirstInterface(nodeTemplateName).operations?.keys?.first() - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name") - } - - fun nodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).inputs - } - - fun nodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { - return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).outputs - } - - fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment { - return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName) - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)") - } - - fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment { - return nodeTemplateInterface(nodeTemplateName, interfaceName).operations?.get(operationName) - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)") - } - - fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment { - return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName) - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)") - } - - fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment { - return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName) - ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)") - } - - fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate { - val filteredNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node - ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ") - return nodeTemplateByName(filteredNodeTemplateName) - } - - fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? { - return nodeTemplateCapability(nodeTemplateName, capabilityName).properties?.get(propertyName) - } - - // Chained Functions - - fun nodeTypeChained(nodeTypeName: String): NodeType { - return BluePrintChainedService(this).nodeTypeChained(nodeTypeName) - } - - fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap? { - return BluePrintChainedService(this).nodeTypeChainedProperties(nodeTypeName) - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt deleted file mode 100644 index 8caec75fd..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.ArrayNode -import com.fasterxml.jackson.databind.node.ObjectNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.data.* - -/** - * - * - * @author Brinda Santh - */ -object BluePrintExpressionService { - val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @JvmStatic - fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData { - log.trace("Assignment Data/Expression : {}", propertyAssignmentNode) - val expressionData = ExpressionData(valueNode = propertyAssignmentNode) - if (propertyAssignmentNode is ObjectNode) { - - val commands: Set = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands()) - if (commands.isNotEmpty()) { - expressionData.isExpression = true - expressionData.command = commands.first() - expressionData.expressionNode = propertyAssignmentNode - - when (expressionData.command) { - BluePrintConstants.EXPRESSION_GET_INPUT -> { - expressionData.inputExpression = populateInputExpression(propertyAssignmentNode) - } - BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { - expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode) - } - BluePrintConstants.EXPRESSION_GET_PROPERTY -> { - expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode) - } - BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { - expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode) - } - BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { - expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode) - } - } - } - } - return expressionData - } - - @JvmStatic - fun populateInputExpression(jsonNode: JsonNode): InputExpression { - return InputExpression(propertyName = jsonNode.first().textValue()) - } - - @JvmStatic - fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression { - val arrayNode: ArrayNode = jsonNode.first() as ArrayNode - check(arrayNode.size() >= 2) { - throw BluePrintException(String.format("missing property expression, " + - "it should be [ , , , " + - ", ..., ] , but present {}", jsonNode)) - } - var reqOrCapEntityName: String? = null - var propertyName = "" - var subProperty: String? = null - when { - arrayNode.size() == 2 -> propertyName = arrayNode[1].textValue() - arrayNode.size() == 3 -> { - reqOrCapEntityName = arrayNode[1].textValue() - propertyName = arrayNode[2].textValue() - } - arrayNode.size() > 3 -> { - reqOrCapEntityName = arrayNode[1].textValue() - propertyName = arrayNode[2].textValue() - val propertyPaths: List = arrayNode.filterIndexed { index, _ -> - index >= 3 - }.map { it.textValue() } - subProperty = propertyPaths.joinToString("/") - } - } - - return PropertyExpression(modelableEntityName = arrayNode[0].asText(), - reqOrCapEntityName = reqOrCapEntityName, - propertyName = propertyName, - subPropertyName = subProperty - ) - } - - @JvmStatic - fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression { - val arrayNode: ArrayNode = jsonNode.first() as ArrayNode - check(arrayNode.size() >= 2) { - throw BluePrintException(String.format("missing attribute expression, " + - "it should be [ , , ," + - " , ..., ] , but present {}", jsonNode)) - } - - var reqOrCapEntityName: String? = null - var attributeName = "" - var subAttributeName: String? = null - when { - arrayNode.size() == 2 -> attributeName = arrayNode[1].textValue() - arrayNode.size() == 3 -> { - reqOrCapEntityName = arrayNode[1].textValue() - attributeName = arrayNode[2].textValue() - } - arrayNode.size() > 3 -> { - reqOrCapEntityName = arrayNode[1].textValue() - attributeName = arrayNode[2].textValue() - val propertyPaths: List = arrayNode.filterIndexed { index, _ -> - index >= 3 - }.map { it.textValue() } - subAttributeName = propertyPaths.joinToString("/") - } - } - return AttributeExpression(modelableEntityName = arrayNode[0].asText(), - reqOrCapEntityName = reqOrCapEntityName, - attributeName = attributeName, - subAttributeName = subAttributeName - ) - } - - @JvmStatic - fun populateOperationOutputExpression(jsonNode: JsonNode): OperationOutputExpression { - val arrayNode: ArrayNode = jsonNode.first() as ArrayNode - - check(arrayNode.size() >= 4) { - throw BluePrintException(String.format("missing operation output expression, " + - "it should be (, , , ) , but present {}", jsonNode)) - } - return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(), - interfaceName = arrayNode[1].asText(), - operationName = arrayNode[2].asText(), - propertyName = arrayNode[3].asText() - ) - } - - @JvmStatic - fun populateArtifactExpression(jsonNode: JsonNode): ArtifactExpression { - val arrayNode: ArrayNode = jsonNode.first() as ArrayNode - - check(arrayNode.size() >= 2) { - throw BluePrintException(String.format("missing artifact expression, " + - "it should be [ , , , ] , but present {}", jsonNode)) - } - return ArtifactExpression(modelableEntityName = arrayNode[0].asText(), - artifactName = arrayNode[1].asText(), - location = arrayNode[2]?.asText() ?: "LOCAL_FILE", - remove = arrayNode[3]?.asBoolean() ?: false - ) - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt deleted file mode 100644 index 26eb19de1..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import java.io.File -import java.net.URL -import java.net.URLDecoder -import java.nio.charset.Charset - -class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { - companion object { - private const val PARENT_SERVICE_TEMPLATE: String = "parent" - } - - private val log: Logger = LoggerFactory.getLogger(this::class.toString()) - - private var importServiceTemplateMap: MutableMap = hashMapOf() - - - fun getImportResolvedServiceTemplate(): ServiceTemplate { - // Populate Imported Service Templates - traverseSchema(PARENT_SERVICE_TEMPLATE, parentServiceTemplate) - - importServiceTemplateMap.forEach { key, serviceTemplate -> - ServiceTemplateUtils.merge(parentServiceTemplate, serviceTemplate) - log.debug("merged service template $key") - } - return parentServiceTemplate - } - - private fun traverseSchema(key: String, serviceTemplate: ServiceTemplate) { - if (key != PARENT_SERVICE_TEMPLATE) { - importServiceTemplateMap[key] = serviceTemplate - } - val imports: List? = serviceTemplate.imports - - imports?.let { - serviceTemplate.imports?.forEach { importDefinition -> - val childServiceTemplate = resolveImportDefinition(importDefinition) - val keyName: String = importDefinition.file - traverseSchema(keyName, childServiceTemplate) - } - } - } - - private fun resolveImportDefinition(importDefinition: ImportDefinition): ServiceTemplate { - var serviceTemplate: ServiceTemplate? = null - val file: String = importDefinition.file - val decodedSystemId: String = URLDecoder.decode(file, Charset.defaultCharset().toString()) - log.trace("file ({}), decodedSystemId ({}) ", file, decodedSystemId) - try { - if (decodedSystemId.startsWith("http", true) - || decodedSystemId.startsWith("https", true)) { - val givenUrl: String = URL(decodedSystemId).toString() - val systemUrl: String = File(".").toURI().toURL().toString() - log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl) - if (givenUrl.startsWith(systemUrl)) { - - } - } else { - if (!decodedSystemId.startsWith("/")) { - importDefinition.file = StringBuilder().append(blueprintBasePath).append(File.separator).append(file).toString() - } - serviceTemplate = ServiceTemplateUtils.getServiceTemplate(importDefinition.file) - } - } catch (e: Exception) { - throw BluePrintException("failed to populate service template for ${importDefinition.file}", e) - } - if (serviceTemplate == null) { - throw BluePrintException("failed to populate service template for : ${importDefinition.file}") - } - return serviceTemplate - } - - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt deleted file mode 100644 index 43267ff1b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import java.io.File -import java.io.Serializable - -/** - * - * - * @author Brinda Santh - */ -interface BluePrintParserService : Serializable { - fun readBlueprint(content: String) : BluePrintContext - fun readBlueprintFile(fileName: String) : BluePrintContext - /** - * Read Blueprint from CSAR structure Directory - */ - fun readBlueprintFile(fileName: String, basePath : String) : BluePrintContext -} - -class BluePrintParserDefaultService : BluePrintParserService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - var basePath : String = javaClass.classLoader.getResource(".").path - - override fun readBlueprint(content: String): BluePrintContext { - return BluePrintContext(ServiceTemplateUtils.getServiceTemplateFromContent(content)) - } - - override fun readBlueprintFile(fileName: String): BluePrintContext { - return readBlueprintFile(fileName, basePath ) - } - - override fun readBlueprintFile(fileName: String, basePath : String): BluePrintContext { - val rootFilePath: String = StringBuilder().append(basePath).append(File.separator).append(fileName).toString() - val rootServiceTemplate : ServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) - // TODO("Nested Lookup Implementation based on Import files") - return BluePrintContext(rootServiceTemplate) - } - - -} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt deleted file mode 100644 index de338664c..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils - -open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) - - private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) - private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) - private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) - private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) - private val extension = ".json" - - override fun getDataType(dataTypeName: String): DataType { - val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(dataTypeName).plus(extension) - return getModelType(fileName, DataType::class.java) - } - - override fun getNodeType(nodeTypeName: String): NodeType { - val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) - return getModelType(fileName, NodeType::class.java) - } - - override fun getArtifactType(artifactTypeName: String): ArtifactType { - val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(artifactTypeName).plus(extension) - return getModelType(fileName, ArtifactType::class.java) - } - - override fun getRelationshipType(relationshipTypeName: String): RelationshipType { - val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(relationshipTypeName).plus(extension) - return getModelType(fileName, RelationshipType::class.java) - } - - override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { - val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(capabilityDefinitionName).plus(extension) - return getModelType(fileName, CapabilityDefinition::class.java) - } - - private fun getModelType(fileName: String, valueType: Class): T { - return JacksonUtils.readValueFromFile(fileName, valueType) - ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt deleted file mode 100644 index 60318659b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.NullNode -import com.fasterxml.jackson.databind.node.ObjectNode -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils - -interface BluePrintRuntimeService { - - fun id(): String - - fun bluePrintContext(): BluePrintContext - - fun getExecutionContext(): T - - fun setExecutionContext(executionContext: T) - - fun put(key: String, value: JsonNode) - - fun get(key: String): JsonNode? - - fun check(key: String): Boolean - - fun cleanRuntime() - - fun getAsString(key: String): String? - - fun getAsBoolean(key: String): Boolean? - - fun getAsInt(key: String): Int? - - fun getAsDouble(key: String): Double? - - fun getBluePrintError(): BluePrintError - - fun setBluePrintError(bluePrintError: BluePrintError) - - fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, - propertyDefinitions: MutableMap, - propertyAssignments: MutableMap): MutableMap - - fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap - - fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): MutableMap - - fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, - operationName: String): MutableMap - - fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, - operationName: String): MutableMap - - fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String - - fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition - - fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) - - fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) - - fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) - - fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) - - fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String, value: JsonNode) - - fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String, value: JsonNode) - - fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String, value: JsonNode) - - fun getInputValue(propertyName: String): JsonNode - - fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String): JsonNode - - fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? - - fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? - - fun assignInputs(jsonNode: JsonNode) - - fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) - - fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode -} - -/** - * - * - * @author Brinda Santh - */ -open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) - : BluePrintRuntimeService> { - - @Transient - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString()) - - private var store: MutableMap = hashMapOf() - - private var bluePrintError = BluePrintError() - - override fun id(): String { - return id - } - - override fun bluePrintContext(): BluePrintContext { - return bluePrintContext - } - - override fun getExecutionContext(): MutableMap { - return store - } - - @Suppress("UNCHECKED_CAST") - override fun setExecutionContext(executionContext: MutableMap) { - this.store = executionContext - } - - override fun put(key: String, value: JsonNode) { - store[key] = value - } - - override fun get(key: String): JsonNode { - return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)") - } - - override fun check(key: String): Boolean { - return store.containsKey(key) - } - - override fun cleanRuntime() { - store.clear() - } - - private fun getJsonNode(key: String): JsonNode { - return get(key) - } - - override fun getAsString(key: String): String? { - return get(key).asText() - } - - override fun getAsBoolean(key: String): Boolean? { - return get(key).asBoolean() - } - - override fun getAsInt(key: String): Int? { - return get(key).asInt() - } - - override fun getAsDouble(key: String): Double? { - return get(key).asDouble() - } - - override fun getBluePrintError(): BluePrintError { - return this.bluePrintError - } - - override fun setBluePrintError(bluePrintError: BluePrintError) { - this.bluePrintError = bluePrintError - } - - /** - * Resolve any property assignments for the node - */ - override fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, - propertyDefinitions: MutableMap, - propertyAssignments: MutableMap) - : MutableMap { - - val propertyAssignmentValue: MutableMap = hashMapOf() - - propertyDefinitions.forEach { nodeTypePropertyName, nodeTypeProperty -> - // Get the Express or Value for the Node Template - val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] - - var resolvedValue: JsonNode = NullNode.getInstance() - if (propertyAssignment != null) { - // Resolve the Expressing - val propertyAssignmentExpression = PropertyAssignmentService(this) - resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, - nodeTypePropertyName, propertyAssignment) - } else { - // Assign default value to the Operation - nodeTypeProperty.defaultValue?.let { - resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) - } - } - // Set for Return of method - propertyAssignmentValue[nodeTypePropertyName] = resolvedValue - } - return propertyAssignmentValue - } - - override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { - log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) - - val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - - val propertyAssignments: MutableMap = nodeTemplate.properties!! - - // Get the Node Type Definitions - val nodeTypePropertieDefinitions: MutableMap = bluePrintContext - .nodeTypeChainedProperties(nodeTemplate.type)!! - - /** - * Resolve the NodeTemplate Property Assignment Values. - */ - return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypePropertieDefinitions, - propertyAssignments) - } - - override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): - MutableMap { - log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " + - "($capabilityName)") - val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - - val propertyAssignments = nodeTemplate.capabilities?.get(capabilityName)?.properties ?: hashMapOf() - - val propertyDefinitions = bluePrintContext.nodeTemplateNodeType(nodeTemplateName) - .capabilities?.get(capabilityName)?.properties ?: hashMapOf() - - /** - * Resolve the Capability Property Assignment Values. - */ - return resolveNodeTemplatePropertyAssignments(nodeTemplateName, propertyDefinitions, - propertyAssignments) - } - - override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, - interfaceName: String, - operationName: String): MutableMap { - log.info("resolveNodeTemplateInterfaceOperationInputs for node template ($nodeTemplateName),interface name " + - "($interfaceName), operationName($operationName)") - - val propertyAssignments: MutableMap = - bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) - ?: hashMapOf() - - val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type - - val nodeTypeInterfaceOperationInputs: MutableMap = - bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName) - ?: hashMapOf() - - log.info("input definition for node template ($nodeTemplateName), values ($propertyAssignments)") - - /** - * Resolve the Property Input Assignment Values. - */ - return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypeInterfaceOperationInputs, - propertyAssignments) - - } - - - override fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, - interfaceName: String, - operationName: String): MutableMap { - log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ($nodeTemplateName),interface name " + - "($interfaceName), operationName($operationName)") - - val propertyAssignments: MutableMap = - bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) - ?: hashMapOf() - - val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type - - val nodeTypeInterfaceOperationOutputs: MutableMap = - bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName) - ?: hashMapOf() - /** - * Resolve the Property Output Assignment Values. - */ - val propertyAssignmentValue = resolveNodeTemplatePropertyAssignments(nodeTemplateName, - nodeTypeInterfaceOperationOutputs, propertyAssignments) - - // Store operation output values into context - propertyAssignmentValue.forEach { key, value -> - setNodeTemplateOperationOutputValue(nodeTemplateName, interfaceName, operationName, key, value) - } - return propertyAssignmentValue - } - - override fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String { - val artifactDefinition: ArtifactDefinition = resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName) - val propertyAssignmentExpression = PropertyAssignmentService(this) - return propertyAssignmentExpression.artifactContent(artifactDefinition) - } - - override fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition { - val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) - - return nodeTemplate.artifacts?.get(artifactName) - ?: throw BluePrintProcessorException("failed to get artifat definition($artifactName) from the node " + - "template") - - } - - override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { - val path = StringBuilder(BluePrintConstants.PATH_INPUTS) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - log.trace("setting input path ({}), values ({})", path, value) - put(path, value) - } - - override fun setWorkflowInputValue(workflowName: String, propertyName: String, - propertyDefinition: PropertyDefinition, value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS) - .append(BluePrintConstants.PATH_DIVIDER).append(workflowName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - put(path, value) - } - - override fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { - - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - put(path, value) - } - - override fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { - - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) - .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() - put(path, value) - } - - override fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, - value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) - .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) - .append(BluePrintConstants.PATH_DIVIDER).append(operationName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - log.trace("setting operation property path ({}), values ({})", path, value) - put(path, value) - } - - override fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String, - value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) - .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) - .append(BluePrintConstants.PATH_DIVIDER).append(operationName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - put(path, value) - } - - override fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String, - value: JsonNode) { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) - .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) - .append(BluePrintConstants.PATH_DIVIDER).append(operationName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - put(path, value) - } - - - override fun getInputValue(propertyName: String): JsonNode { - val path = StringBuilder(BluePrintConstants.PATH_INPUTS) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return getJsonNode(path) - } - - override fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, - operationName: String, propertyName: String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) - .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) - .append(BluePrintConstants.PATH_DIVIDER).append(operationName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return getJsonNode(path) - } - - override fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) - .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() - return getJsonNode(path) - } - - override fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode { - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) - .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() - return getJsonNode(path) - } - - override fun assignInputs(jsonNode: JsonNode) { - log.info("assignInputs from input JSON ({})", jsonNode.toString()) - bluePrintContext.inputs?.forEach { propertyName, property -> - val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) - ?: NullNode.getInstance() - setInputValue(propertyName, property, valueNode) - } - } - - override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { - log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString()) - - val dynamicInputPropertiesName = "$workflowName-properties" - - bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property -> - if (propertyName != dynamicInputPropertiesName) { - val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) - ?: NullNode.getInstance() - setInputValue(propertyName, property, valueNode) - } - } - // Load Dynamic data Types - val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName) - - workflowDynamicInputs?.let { - bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.forEach { propertyName, property -> - val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName) - ?: NullNode.getInstance() - setInputValue(propertyName, property, valueNode) - - } - } - } - - override fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode { - - val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode() - val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) - .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) - .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) - .append(BluePrintConstants.PATH_DIVIDER).toString() - store.keys.filter { - it.startsWith(path) - }.map { - val key = it.replace(path, "") - if (keys.contains(key)) { - val value = store[it] as JsonNode - jsonNode.set(key, value) - } - } - return jsonNode - } - - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt deleted file mode 100644 index d175fddea..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.fasterxml.jackson.core.io.CharTypes -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.JsonNodeFactory -import com.fasterxml.jackson.databind.node.TextNode -import org.apache.commons.lang3.BooleanUtils -import org.apache.commons.lang3.StringUtils -import org.apache.velocity.VelocityContext -import org.apache.velocity.app.Velocity -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import java.io.StringWriter - -open class BluePrintTemplateService { - - companion object { - - /** - * Generate Content from Velocity Template and JSON Content. - */ - fun generateContent(template: String, json: String, - ignoreJsonNull: Boolean = false, - additionalContext: MutableMap = hashMapOf()): String { - Velocity.init() - val mapper = ObjectMapper() - val nodeFactory = BluePrintJsonNodeFactory() - mapper.setNodeFactory(nodeFactory) - - val jsonNode = mapper.readValue(json, JsonNode::class.java) - ?: throw BluePrintProcessorException("couldn't get json node from json") - - if (ignoreJsonNull) - JacksonUtils.removeJsonNullNode(jsonNode) - - val velocityContext = VelocityContext() - velocityContext.put("StringUtils", StringUtils::class.java) - velocityContext.put("BooleanUtils", BooleanUtils::class.java) - /** - * Add the Custom Velocity Context API - */ - additionalContext.forEach { name, value -> velocityContext.put(name, value) } - /** - * Add the JSON Data to the context - */ - jsonNode.fields().forEach { entry -> - velocityContext.put(entry.key, entry.value) - } - - val stringWriter = StringWriter() - Velocity.evaluate(velocityContext, stringWriter, "TemplateData", template) - stringWriter.flush() - return stringWriter.toString() - } - } -} - -/** - * Customise JsonNodeFactory adn TextNode, Since it introduces quotes for string data. - */ -open class BluePrintJsonNodeFactory : JsonNodeFactory() { - override fun textNode(text: String): TextNode { - return BluePrintTextNode(text) - } -} - -open class BluePrintTextNode(v: String) : TextNode(v) { - override fun toString(): String { - var len = this._value.length - len = len + 2 + (len shr 4) - val sb = StringBuilder(len) - CharTypes.appendQuoted(sb, this._value) - return sb.toString() - } - -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt deleted file mode 100644 index b33cc3f0c..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ /dev/null @@ -1,607 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.google.common.base.Preconditions -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.apps.controllerblueprints.core.* -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import java.io.Serializable - -/** - * - * - * @author Brinda Santh - */ -interface BluePrintValidatorService : Serializable { - - @Throws(BluePrintException::class) - fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) - - @Throws(BluePrintException::class) - fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap) -} - -open class BluePrintValidatorDefaultService : BluePrintValidatorService { - - val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString()) - - lateinit var bluePrintContext: BluePrintContext - lateinit var serviceTemplate: ServiceTemplate - lateinit var properties: MutableMap - var message: StringBuilder = StringBuilder() - private val separator: String = BluePrintConstants.PATH_DIVIDER - var paths: MutableList = arrayListOf() - - @Throws(BluePrintException::class) - override fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) { - validateBlueprint(bluePrintContext.serviceTemplate, properties) - } - - @Throws(BluePrintException::class) - override fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap) { - this.bluePrintContext = BluePrintContext(serviceTemplate) - this.serviceTemplate = serviceTemplate - this.properties = properties - try { - message.appendln("-> Config Blueprint") - serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } - serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) } - serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } - serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } - serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } - } catch (e: Exception) { - log.error("validation failed in the path : {}", paths.joinToString(separator), e) - log.error("validation trace message :{} ", message) - throw BluePrintException(e, - format("failed to validate blueprint on path ({}) with message {}" - , paths.joinToString(separator), e.message)) - } - } - - @Throws(BluePrintException::class) - open fun validateMetadata(metaDataMap: MutableMap) { - paths.add("metadata") - - val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] - val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] - val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] - val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] - - Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") - Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") - Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") - Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateArtifactTypes(artifactTypes: MutableMap) { - paths.add("artifact_types") - artifactTypes.forEach { artifactName, artifactType -> - paths.add(artifactName) - message.appendln("--> Artifact Type :" + paths.joinToString(separator)) - artifactType.properties?.let { validatePropertyDefinitions(artifactType.properties!!) } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateDataTypes(dataTypes: MutableMap) { - paths.add("dataTypes") - dataTypes.forEach { dataTypeName, dataType -> - paths.add(dataTypeName) - message.appendln("--> DataType :" + paths.joinToString(separator)) - dataType.properties?.let { validatePropertyDefinitions(dataType.properties!!) } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateNodeTypes(nodeTypes: MutableMap) { - paths.add("nodeTypes") - nodeTypes.forEach { nodeTypeName, nodeType -> - // Validate Single Node Type - validateNodeType(nodeTypeName, nodeType) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateNodeType(nodeTypeName: String, nodeType: NodeType) { - paths.add(nodeTypeName) - message.appendln("--> Node Type :" + paths.joinToString(separator)) - val derivedFrom: String = nodeType.derivedFrom - //Check Derived From - checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) - - if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { - serviceTemplate.nodeTypes?.get(derivedFrom) - ?: throw BluePrintException(format("Failed to get derivedFrom NodeType({})'s for NodeType({}) ", - derivedFrom, nodeTypeName)) - } - - nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) } - nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } - nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } - nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get node type ({})'s derivedFrom({}) definition ", nodeTypeName, derivedFrom)) - } - } - - @Throws(BluePrintException::class) - open fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { - paths.add("topology") - message.appendln("--> Topology Template") - topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } - topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) } - topologyTemplate.workflows?.let { validateWorkFlows(topologyTemplate.workflows!!) } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateInputs(inputs: MutableMap) { - paths.add("inputs") - message.appendln("---> Input :" + paths.joinToString(separator)) - validatePropertyDefinitions(inputs) - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateNodeTemplates(nodeTemplates: MutableMap) { - paths.add("nodeTemplates") - nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> - validateNodeTemplate(nodeTemplateName, nodeTemplate) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { - paths.add(nodeTemplateName) - message.appendln("---> NodeTemplate :" + paths.joinToString(separator)) - val type: String = nodeTemplate.type - - val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type) - ?: throw BluePrintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName)) - - nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } - nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } - nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateArtifactDefinitions(artifacts: MutableMap) { - paths.add("artifacts") - artifacts.forEach { artifactDefinitionName, artifactDefinition -> - paths.add(artifactDefinitionName) - message.appendln("Validating artifact " + paths.joinToString(separator)) - val type: String = artifactDefinition.type - ?: throw BluePrintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName)) - // Check Artifact Type - checkValidArtifactType(artifactDefinitionName, type) - - val file: String = artifactDefinition.file - ?: throw BluePrintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName)) - - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateWorkFlows(workflows: MutableMap) { - paths.add("workflows") - workflows.forEach { workflowName, workflow -> - - // Validate Single workflow - validateWorkFlow(workflowName, workflow) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateWorkFlow(workflowName: String, workflow: Workflow) { - paths.add(workflowName) - message.appendln("---> Workflow :" + paths.joinToString(separator)) - // Step Validation Start - paths.add("steps") - workflow.steps?.forEach { stepName, _ -> - paths.add(stepName) - message.appendln("----> Steps :" + paths.joinToString(separator)) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - // Step Validation Ends - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validatePropertyDefinitions(properties: MutableMap) { - paths.add("properties") - properties.forEach { propertyName, propertyDefinition -> - paths.add(propertyName) - val dataType: String = propertyDefinition.type - when { - BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { - // Do Nothing - } - BluePrintTypes.validCollectionTypes().contains(dataType) -> { - val entrySchemaType: String = propertyDefinition.entrySchema?.type - ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName)) - checkPrimitiveOrComplex(entrySchemaType, propertyName) - } - else -> checkPropertyDataType(dataType, propertyName) - } - message.appendln("property " + paths.joinToString(separator) + " of type " + dataType) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, - properties: MutableMap) { - properties.forEach { propertyName, propertyAssignment -> - val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] - ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) - - validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) - - } - } - - @Throws(BluePrintException::class) - open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition, - propertyAssignment: JsonNode) { - // Check and Validate if Expression Node - val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) - if (!expressionData.isExpression) { - checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) - } - } - - @Throws(BluePrintException::class) - open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - val capabilities = nodeTemplate.capabilities - paths.add("capabilities") - capabilities?.forEach { capabilityName, capabilityAssignment -> - paths.add(capabilityName) - - val capabilityDefinition = nodeType.capabilities?.get(capabilityName) - ?: throw BluePrintException(format("Failed to get NodeTemplate({}) capability definition ({}) " + - "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type)) - - validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) - - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String, - capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) { - - capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } - - } - - @Throws(BluePrintException::class) - open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - val requirements = nodeTemplate.requirements - paths.add("requirements") - requirements?.forEach { requirementName, requirementAssignment -> - paths.add(requirementName) - val requirementDefinition = nodeType.requirements?.get(requirementName) - ?: throw BluePrintException(format("Failed to get NodeTemplate({}) requirement definition ({}) from" + - " NodeType({}) ", nodeTemplateName, requirementName, nodeTemplate.type)) - // Validate Requirement Assignment - validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - - } - - @Throws(BluePrintException::class) - open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, - requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { - log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) - val requirementNodeTemplateName = requirementAssignment.node!! - val capabilityName = requirementAssignment.capability - val relationship = requirementAssignment.relationship!! - - check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { - throw BluePrintException(format("Failed to get relationship type ({}) for NodeTemplate({})'s requirement({}) ", - relationship, nodeTemplateName, requirementAssignmentName)) - } - - val relationShipNodeTemplate = serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) - ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s for NodeTemplate({}) requirement({}) ", - requirementNodeTemplateName, nodeTemplateName, requirementAssignmentName)) - - relationShipNodeTemplate.capabilities?.get(capabilityName) - ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s capability({}) for NodeTemplate ({})'s requirement({}) ", - requirementNodeTemplateName, capabilityName, nodeTemplateName, requirementAssignmentName)) - - - } - - @Throws(BluePrintException::class) - open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - - val interfaces = nodeTemplate.interfaces - paths.add("interfaces") - interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> - paths.add(interfaceAssignmentName) - val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) - ?: throw BluePrintException(format("Failed to get NodeTemplate({}) interface definition ({}) from" + - " NodeType({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type)) - - validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, - interfaceAssignment) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - - - } - - @Throws(BluePrintException::class) - open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String, - interfaceDefinition: InterfaceDefinition, - interfaceAssignment: InterfaceAssignment) { - - val operations = interfaceAssignment.operations - operations?.let { - validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, - interfaceAssignment) - } - - } - - @Throws(BluePrintException::class) - open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String, - interfaceDefinition: InterfaceDefinition, - interfaceAssignment: InterfaceAssignment) { - - val operations = interfaceAssignment.operations - operations?.let { - it.forEach { operationAssignmentName, operationAssignments -> - - val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) - ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) ", - nodeTemplateName, operationAssignmentName)) - - log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName, - interfaceAssignmentName, operationAssignmentName) - - val inputs = operationAssignments.inputs - val outputs = operationAssignments.outputs - - inputs?.forEach { propertyName, propertyAssignment -> - val propertyDefinition = operationDefinition.inputs?.get(propertyName) - ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " + - "property definition({})", nodeTemplateName, operationAssignmentName, propertyName)) - // Check the property values with property definition - validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) - } - - outputs?.forEach { propertyName, propertyAssignment -> - val propertyDefinition = operationDefinition.outputs?.get(propertyName) - ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " + - "output property definition({})", nodeTemplateName, operationAssignmentName, - propertyName)) - // Check the property values with property definition - validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) - } - - } - } - - } - - @Throws(BluePrintException::class) - open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { - val capabilities = nodeType.capabilities - paths.add("capabilities") - capabilities?.forEach { capabilityName, capabilityDefinition -> - paths.add(capabilityName) - - validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition) - - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String, - capabilityDefinition: CapabilityDefinition) { - val capabilityType = capabilityDefinition.type - check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { - throw BluePrintException(format("Failed to get CapabilityType({}) for NodeType({})", - capabilityType, nodeTypeName)) - } - } - - @Throws(BluePrintException::class) - open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { - paths.add("requirements") - val requirements = nodeType.requirements - - requirements?.forEach { requirementDefinitionName, requirementDefinition -> - paths.add(requirementDefinitionName) - message.appendln("Validating : " + paths.joinToString(separator)) - validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String, - requirementDefinition: RequirementDefinition) { - - log.info("Validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName) - val requirementNodeTypeName = requirementDefinition.node!! - val capabilityName = requirementDefinition.capability - val relationship = requirementDefinition.relationship!! - - check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { - throw BluePrintException(format("Failed to get relationship({}) for NodeType({})'s requirement({}) ", - relationship, nodeTypeName, requirementDefinitionName)) - } - - val relationShipNodeType = serviceTemplate.nodeTypes?.get(requirementNodeTypeName) - ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s for requirement({}) ", - requirementNodeTypeName, requirementDefinitionName)) - - relationShipNodeType.capabilities?.get(capabilityName) - ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s capability({}) for NodeType ({})'s requirement({}) ", - requirementNodeTypeName, capabilityName, nodeTypeName, requirementDefinitionName)) - - } - - - @Throws(BluePrintException::class) - open fun validateInterfaceDefinitions(interfaces: MutableMap) { - paths.add("interfaces") - interfaces.forEach { interfaceName, interfaceDefinition -> - paths.add(interfaceName) - message.appendln("Validating : " + paths.joinToString(separator)) - interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateOperationDefinitions(operations: MutableMap) { - paths.add("operations") - operations.forEach { opertaionName, operationDefinition -> - paths.add(opertaionName) - message.appendln("Validating : " + paths.joinToString(separator)) - operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } - operationDefinition.inputs?.let { validatePropertyDefinitions(operationDefinition.inputs!!) } - operationDefinition.outputs?.let { validatePropertyDefinitions(operationDefinition.outputs!!) } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateImplementation(implementation: Implementation) { - checkNotEmptyOrThrow(implementation.primary) - } - - @Throws(BluePrintException::class) - open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { - - val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") - - checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) - } - - @Throws(BluePrintException::class) - open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") - } - } - - @Throws(BluePrintException::class) - open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) - } - } - - @Throws(BluePrintException::class) - open fun checkValidRelationshipTypeDerivedFrom(relationshipTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validRelationShipDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get relationship type ({})'s derivedFrom({}) definition ", relationshipTypeName, derivedFrom)) - } - } - - open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { - val propertyType = propertyDefinition.type - val isValid: Boolean - - if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { - isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) - - } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { - - val entrySchemaType = propertyDefinition.entrySchema?.type - ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) - - if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { - checkPropertyDataType(entrySchemaType, propertyName) - } - isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) - } else { - checkPropertyDataType(propertyType, propertyName) - isValid = true - } - - check(isValid) { - throw BluePrintException(format("property({}) defined of type({}) is not comptable with the value ({})", - propertyName, propertyType, propertyAssignment)) - } - } - - private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { - - val dataType = serviceTemplate.dataTypes?.get(dataTypeName) - ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) - - checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) - - } - - private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { - if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { - return true - } else { - throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) - } - } - - private fun checkDataType(key: String): Boolean { - return serviceTemplate.dataTypes?.containsKey(key) ?: false - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt deleted file mode 100644 index 17380fc0f..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils - -/** - * - * - * @author Brinda Santh - */ -class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService>) { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext() - -/* - -If Property Assignment is Expression. - Get the Expression - Recursively resolve the expression - */ - - fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String, - assignment: JsonNode): JsonNode { - val valueNode: JsonNode - log.trace("Assignment ({})", assignment) - val expressionData = BluePrintExpressionService.getExpressionData(assignment) - - if (expressionData.isExpression) { - valueNode = resolveExpression(nodeTemplateName, assignmentName, expressionData) - } else { - valueNode = expressionData.valueNode - } - return valueNode - } - - fun resolveExpression(nodeTemplateName: String, propName: String, expressionData: ExpressionData): JsonNode { - - var valueNode: JsonNode = NullNode.getInstance() - - if (expressionData.isExpression) { - val command = expressionData.command!! - - when (command) { - BluePrintConstants.EXPRESSION_GET_INPUT -> { - valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!) - } - BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { - valueNode = resolveAttributeExpression(nodeTemplateName, expressionData.attributeExpression!!) - } - BluePrintConstants.EXPRESSION_GET_PROPERTY -> { - valueNode = resolvePropertyExpression(nodeTemplateName, expressionData.propertyExpression!!) - } - BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { - valueNode = resolveOperationOutputExpression(nodeTemplateName, expressionData.operationOutputExpression!!) - } - BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { - valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!) - } - BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> { - - } - else -> { - throw BluePrintException(format("for property ({}), command ({}) is not supported ", propName, command)) - } - } - } - return valueNode - } - - /* - get_property: [ , , , - , ..., ] - */ - fun resolveAttributeExpression(nodeTemplateName: String, attributeExpression: AttributeExpression): JsonNode { - val valueNode: JsonNode - - val attributeName = attributeExpression.attributeName - val subAttributeName: String? = attributeExpression.subAttributeName - - var attributeNodeTemplateName = nodeTemplateName - when (attributeExpression.modelableEntityName) { - "ENV" -> { - val environmentValue = System.getProperty(attributeName) - valueNode = JacksonUtils.jsonNode(environmentValue) - } - else -> { - if (!attributeExpression.modelableEntityName.equals("SELF", true)) { - attributeNodeTemplateName = attributeExpression.modelableEntityName - } - /* Enable in ONAP Dublin Release - val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName) - ?: throw BluePrintException(format("failed to get attribute definitions for node template " + - "({})'s property name ({}) ", nodeTemplateName, attributeName)) - - var attributeDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!! - - log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) - */ - - valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName) - ?: throw BluePrintException(format("failed to get node template ({})'s attribute ({}) ", nodeTemplateName, attributeName)) - } - - } -// subPropertyName?.let { -// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) -// } - return valueNode - } - - /* - get_property: [ , , , - , ..., ] - */ - fun resolvePropertyExpression(nodeTemplateName: String, propertyExpression: PropertyExpression): JsonNode { - val valueNode: JsonNode - - val propertyName = propertyExpression.propertyName - val subPropertyName: String? = propertyExpression.subPropertyName - - var propertyNodeTemplateName = nodeTemplateName - if (!propertyExpression.modelableEntityName.equals("SELF", true)) { - propertyNodeTemplateName = propertyExpression.modelableEntityName - } - - val nodeTemplatePropertyExpression = bluePrintContext.nodeTemplateByName(propertyNodeTemplateName).properties?.get(propertyName) - ?: throw BluePrintException(format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, propertyName)) - - var propertyDefinition: PropertyDefinition = bluePrintContext.nodeTemplateNodeType(propertyNodeTemplateName).properties?.get(propertyName)!! - - log.info("node template name ({}), property Name ({}) resolved value ({})", propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) - - // Check it it is a nested expression - valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) - -// subPropertyName?.let { -// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) -// } - return valueNode - } - - /* - get_operation_output: , , , - */ - fun resolveOperationOutputExpression(nodeTemplateName: String, operationOutputExpression: OperationOutputExpression): JsonNode { - var outputNodeTemplateName = nodeTemplateName - if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) { - outputNodeTemplateName = operationOutputExpression.modelableEntityName - } - return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName, - operationOutputExpression.interfaceName, operationOutputExpression.operationName, - operationOutputExpression.propertyName) - } - - /* - get_artifact: [ , , , ] - */ - fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode { - - var artifactNodeTemplateName = nodeTemplateName - if (!artifactExpression.modelableEntityName.equals("SELF", true)) { - artifactNodeTemplateName = artifactExpression.modelableEntityName - } - val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName) - .artifacts?.get(artifactExpression.artifactName) - ?: throw BluePrintException(format("failed to get artifact definitions for node template ({})'s " + - "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName)) - - return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition)) - } - - fun artifactContent(artifactDefinition: ArtifactDefinition): String { - val bluePrintBasePath: String = bluePrintContext.rootPath - - if (artifactDefinition.repository != null) { - TODO() - } else if (artifactDefinition.file != null) { - return ResourceResolverUtils.getFileContent(artifactDefinition.file!!, bluePrintBasePath) - } - return "" - } -} - diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt deleted file mode 100755 index fe7929e85..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking -import org.apache.commons.compress.archivers.zip.ZipArchiveEntry -import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream -import org.apache.commons.io.IOUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.slf4j.LoggerFactory -import java.io.BufferedInputStream -import java.io.File -import java.io.FileInputStream -import java.io.IOException -import java.nio.charset.Charset -import java.util.zip.ZipFile - -class BluePrintArchiveUtils { - - companion object { - private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) - - fun getFileContent(fileName: String): String = runBlocking { - async { - try { - File(fileName).readText(Charsets.UTF_8) - } catch (e: Exception) { - throw BluePrintException("couldn't find file($fileName)") - } - }.await() - } - - fun compress(source: String, destination: String, absolute: Boolean): Boolean { - val rootDir = File(source) - val saveFile = File(destination) - return compress(rootDir, saveFile, absolute) - } - - /** - * Create a new Zip from a root directory - * - * @param source the base directory - * @param destination the output filename - * @param absolute store absolute filepath (from directory) or only filename - * @return True if OK - */ - fun compress(source: File, destination: File, absolute: Boolean): Boolean { - try { - ZipArchiveOutputStream(destination).use { - recurseFiles(source, source, it, absolute) - } - } catch (e: Exception) { - log.error("Fail to compress folder(:$source) to path(${destination.path}", e) - return false - } - return true - } - - /** - * Recursive traversal to add files - * - * @param root - * @param file - * @param zaos - * @param absolute - * @throws IOException - */ - @Throws(IOException::class) - private fun recurseFiles(root: File, file: File, zaos: ZipArchiveOutputStream, - absolute: Boolean) { - if (file.isDirectory) { - // recursive call - val files = file.listFiles() - for (fileChild in files!!) { - recurseFiles(root, fileChild, zaos, absolute) - } - } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) { - val filename = if (absolute) { - file.absolutePath.substring(root.absolutePath.length) - } else { - file.name - } - val zae = ZipArchiveEntry(filename) - zae.size = file.length() - zaos.putArchiveEntry(zae) - FileInputStream(file).use { IOUtils.copy(it, zaos) } - zaos.closeArchiveEntry() - } - } - - - fun deCompress(zipFile: File, targetPath: String): File { - val zip = ZipFile(zipFile, Charset.defaultCharset()) - val enumeration = zip.entries() - while (enumeration.hasMoreElements()) { - val entry = enumeration.nextElement() - val destFilePath = File(targetPath, entry.name) - destFilePath.parentFile.mkdirs() - - if (entry.isDirectory) - continue - - val bufferedIs = BufferedInputStream(zip.getInputStream(entry)) - bufferedIs.use { - destFilePath.outputStream().buffered(1024).use { bos -> - bufferedIs.copyTo(bos) - } - } - } - - val destinationDir = File(targetPath) - check(destinationDir.isDirectory && destinationDir.exists()) { - throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ") - } - - return destinationDir - } - - /** - * Get the first item in directory - * - * @param zipFile - * @return string - */ - fun getFirstItemInDirectory(dir: File): String { - return dir.walk().map { it.name }.elementAt(1) - } - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt deleted file mode 100755 index 9746bf579..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import kotlinx.coroutines.runBlocking -import org.apache.commons.io.FileUtils -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.ErrorCode -import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import java.io.File -import java.io.FileFilter -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardOpenOption - - -class BluePrintFileUtils { - companion object { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - fun createEmptyBluePrint(basePath: String) { - - val blueprintDir = File(basePath) - FileUtils.deleteDirectory(blueprintDir) - - Files.createDirectories(blueprintDir.toPath()) - - val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR)) - Files.createDirectories(metaDataDir.toPath()) - - val metaFile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants - .TOSCA_METADATA_ENTRY_DEFINITION_FILE)) - Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) - - val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)) - Files.createDirectories(definitionsDir.toPath()) - - val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_SCRIPTS_DIR)) - Files.createDirectories(scriptsDir.toPath()) - - val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_PLANS_DIR)) - Files.createDirectories(plansDir.toPath()) - - val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_TEMPLATES_DIR)) - Files.createDirectories(templatesDir.toPath()) - - } - - fun copyBluePrint(sourcePath: String, targetPath: String) { - val sourceFile = File(sourcePath) - val targetFile = File(targetPath) - sourceFile.copyRecursively(targetFile, true) - } - - fun deleteBluePrintTypes(basePath: String) { - val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) - log.info("deleting definition types under : $definitionPath") - - val definitionDir = File(definitionPath) - // Find the Type Definitions - val fileFilter = FileFilter { pathname -> pathname.absolutePath.endsWith("_types.json") } - // Delete the Type Files - definitionDir.listFiles(fileFilter).forEach { - Files.deleteIfExists(it.toPath()) - } - } - - fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) { - - // Write Blueprint Types - writeBluePrintTypes(blueprintContext) - // Re Populate the Imports - populateDefaultImports(blueprintContext) - // Rewrite the Entry Definition Files - writeEntryDefinitionFile(blueprintContext) - - } - - fun writeBluePrintTypes(blueprintContext: BluePrintContext) { - - val basePath = blueprintContext.rootPath - val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) - val definitionDir = File(definitionPath) - - check(definitionDir.exists()) { - throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + - "path(${definitionDir.absolutePath})") - } - - blueprintContext.serviceTemplate.dataTypes?.let { - val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) - } - - blueprintContext.serviceTemplate.relationshipTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) - } - - blueprintContext.serviceTemplate.artifactTypes?.let { - val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) - } - - blueprintContext.serviceTemplate.nodeTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) - } - - blueprintContext.serviceTemplate.policyTypes?.let { - val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) - writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent) - } - } - - private fun populateDefaultImports(blueprintContext: BluePrintContext) { - // Get the Default Types - val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES, - BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES, - BluePrintConstants.PATH_POLICY_TYPES) - - // Clean Type Imports - cleanImportTypes(blueprintContext.serviceTemplate) - - val imports = mutableListOf() - types.forEach { typeName -> - val import = ImportDefinition() - import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") - imports.add(import) - } - - blueprintContext.serviceTemplate.imports = imports - } - - fun cleanImportTypes(serviceTemplate: ServiceTemplate) { - // Clean the Type imports - val toDeleteTypes = serviceTemplate.imports?.filter { - it.file.endsWith("_types.json") - } - - if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) { - serviceTemplate.imports?.removeAll(toDeleteTypes) - } - } - - /** - * Re Generate the Blueprint Service Template Definition file based on BluePrint Context. - */ - private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { - - val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition) - - val serviceTemplate = blueprintContext.serviceTemplate - - // Clone the Service Template - val writeServiceTemplate = serviceTemplate.clone() - writeServiceTemplate.dataTypes = null - writeServiceTemplate.artifactTypes = null - writeServiceTemplate.policyTypes = null - writeServiceTemplate.relationshipTypes = null - writeServiceTemplate.nodeTypes = null - - // Write the Service Template - writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true)) - } - - fun writeDefinitionFile(definitionFileName: String, content: String) = runBlocking { - val definitionFile = File(definitionFileName) - // Delete the File If exists - Files.deleteIfExists(definitionFile.toPath()) - - Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) - check(definitionFile.exists()) { - throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " + - "path(${definitionFile.absolutePath})") - } - } - - private fun writeTypeFile(definitionPath: String, type: String, content: String) = runBlocking { - val typeFile = File(definitionPath.plus(File.separator).plus("$type.json")) - - Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) - check(typeFile.exists()) { - throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " + - "path(${typeFile.absolutePath})") - } - } - - private fun getMetaDataContent(): String { - return "TOSCA-Meta-File-Version: 1.0.0" + - "\nCSAR-Version: " + - "\nCreated-By: " + - "\nEntry-Definitions: Definitions/.json" + - "\nTemplate-Tags: " - } - - - fun getBluePrintFile(fileName: String, targetPath: Path) : File { - val filePath = targetPath.resolve(fileName).toString() - val file = File(filePath) - check(file.exists()) { - throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + - "path(${file.absolutePath})") - } - return file - } - - fun getCbaStorageDirectory(path: String): Path { - check(StringUtils.isNotBlank(path)) { - throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " + - "Blueprint folder under path($path)") - } - - val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize() - - if (!Files.exists(fileStorageLocation)) - Files.createDirectories(fileStorageLocation) - - return fileStorageLocation - } - - fun stripFileExtension(fileName: String): String { - val dotIndexe = fileName.lastIndexOf('.') - - // In case dot is in first position, we are dealing with a hidden file rather than an extension - return if (dotIndexe > 0) fileName.substring(0, dotIndexe) else fileName - } - - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt deleted file mode 100644 index 5b5561f64..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import org.apache.commons.io.FileUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintImportService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService -import java.io.File -import java.nio.charset.Charset - -class BluePrintMetadataUtils { - companion object { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - - fun toscaMetaData(basePath: String): ToscaMetaData { - val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) - return toscaMetaDataFromMetaFile(toscaMetaPath) - } - - fun entryDefinitionFile(basePath: String): String { - val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) - .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) - return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions - } - - fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData { - val toscaMetaData = ToscaMetaData() - val lines: MutableList = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset()) - lines.forEach { line -> - if (line.contains(":")) { - val keyValue = line.split(":") - if (keyValue.size == 2) { - val value: String = keyValue[1].trim() - when (keyValue[0]) { - "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value - "CSAR-Version" -> toscaMetaData.csarVersion = value - "Created-By" -> toscaMetaData.createdBy = value - "Entry-Definitions" -> toscaMetaData.entityDefinitions = value - "Template-Tags" -> toscaMetaData.templateTags = value - } - } - } - - } - return toscaMetaData - } - - fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - - val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() - context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() - - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.setExecutionContext(context) - - return bluePrintRuntimeService - } - - fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { - - val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) - val context: MutableMap = hashMapOf() - context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() - context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() - - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.setExecutionContext(context) - - return bluePrintRuntimeService - } - - fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap): BluePrintRuntimeService> { - val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) - val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) - bluePrintRuntimeService.setExecutionContext(executionContext) - return bluePrintRuntimeService - } - - fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { - - val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) - - log.info("Reading blueprint path($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") - - return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) - } - - private fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { - val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) - // Clean Type files - BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) - val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) - val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) - - // Clean the Import Definitions - BluePrintFileUtils.cleanImportTypes(rootServiceTemplate) - - val blueprintContext = BluePrintContext(rootServiceTemplate) - blueprintContext.rootPath = blueprintBasePath - blueprintContext.entryDefinition = toscaMetaData.entityDefinitions - return blueprintContext - } - - private fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { - val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) - val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) - // Recursively Import Template files - val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath) - val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() - val blueprintContext = BluePrintContext(completeServiceTemplate) - blueprintContext.rootPath = basePath - blueprintContext.entryDefinition = entityDefinitions - return blueprintContext - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt deleted file mode 100644 index 4501275cf..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.NullNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext - -/** - * - * - * @author Brinda Santh - */ -object BluePrintRuntimeUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { - val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) - return assignInputs(bluePrintContext, jsonNode, context) - } - - fun assignInputsFromClassPathFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { - val jsonNode = JacksonUtils.jsonNodeFromClassPathFile(fileName) - return assignInputs(bluePrintContext, jsonNode, context) - } - - fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap) { - val jsonNode: JsonNode = JacksonUtils.jsonNode(content) - return assignInputs(bluePrintContext, jsonNode, context) - } - - fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap) { - log.info("assignInputs from input JSON ({})", jsonNode.toString()) - bluePrintContext.inputs?.forEach { propertyName, _ -> - val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() - - val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName) - log.trace("setting input path ({}), values ({})", path, valueNode) - context[path] = valueNode - } - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt deleted file mode 100644 index e3c2a710b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import reactor.core.publisher.Mono -import reactor.core.publisher.toMono - -@Deprecated("Reactor will be replaced by coroutines by default") -object JacksonReactorUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @JvmStatic - fun getContent(fileName: String): Mono { - return JacksonUtils.getContent(fileName).toMono() - } - - @JvmStatic - fun getClassPathFileContent(fileName: String): Mono { - return JacksonUtils.getClassPathFileContent(fileName).toMono() - } - - @JvmStatic - fun readValue(content: String, valueType: Class): Mono { - return Mono.just(jacksonObjectMapper().readValue(content, valueType)) - } - - @JvmStatic - fun jsonNode(content: String): Mono { - return Mono.just(jacksonObjectMapper().readTree(content)) - } - - @JvmStatic - fun getJson(any: kotlin.Any, pretty: Boolean = false): Mono { - return Mono.just(JacksonUtils.getJson(any, pretty)) - } - - @JvmStatic - fun getListFromJson(content: String, valueType: Class): Mono> { - val objectMapper = jacksonObjectMapper() - val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) - return objectMapper.readValue>(content, javaType).toMono() - } - - @JvmStatic - fun readValueFromFile(fileName: String, valueType: Class): Mono { - return getContent(fileName) - .flatMap { content -> - readValue(content, valueType) - } - } - - @JvmStatic - fun readValueFromClassPathFile(fileName: String, valueType: Class): Mono { - return getClassPathFileContent(fileName) - .flatMap { content -> - readValue(content, valueType) - } - } - - @JvmStatic - fun jsonNodeFromFile(fileName: String): Mono { - return getContent(fileName) - .flatMap { content -> - jsonNode(content) - } - } - - @JvmStatic - fun jsonNodeFromClassPathFile(fileName: String): Mono { - return getClassPathFileContent(fileName) - .flatMap { content -> - jsonNode(content) - } - } - - @JvmStatic - fun getListFromFile(fileName: String, valueType: Class): Mono> { - return getContent(fileName) - .flatMap { content -> - getListFromJson(content, valueType) - } - } - - @JvmStatic - fun getListFromClassPathFile(fileName: String, valueType: Class): Mono> { - return getClassPathFileContent(fileName) - .flatMap { content -> - getListFromJson(content, valueType) - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt deleted file mode 100644 index 2e5a040c5..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.core.type.TypeReference -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializationFeature -import com.fasterxml.jackson.databind.node.ArrayNode -import com.fasterxml.jackson.databind.node.NullNode -import com.fasterxml.jackson.databind.node.ObjectNode -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withContext -import org.apache.commons.io.IOUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import java.io.File -import java.nio.charset.Charset -import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType - -/** - * - * - * @author Brinda Santh - */ -class JacksonUtils { - companion object { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - inline fun readValue(content: String): T = - jacksonObjectMapper().readValue(content, T::class.java) - - fun readValue(content: String, valueType: Class): T? { - return jacksonObjectMapper().readValue(content, valueType) - } - - fun readValue(node: JsonNode, valueType: Class): T? { - return jacksonObjectMapper().treeToValue(node, valueType) - } - - fun removeJsonNullNode(node: JsonNode) { - val it = node.iterator() - while (it.hasNext()) { - val child = it.next() - if (child.isNull) { - it.remove() - } else { - removeJsonNullNode(child) - } - } - } - - fun getContent(fileName: String): String = runBlocking { - async { - try { - File(fileName).readText(Charsets.UTF_8) - } catch (e: Exception) { - throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") - } - }.await() - } - - fun getClassPathFileContent(fileName: String): String { - return runBlocking { - withContext(Dispatchers.Default) { - IOUtils.toString(JacksonUtils::class.java.classLoader - .getResourceAsStream(fileName), Charset.defaultCharset()) - } - } - } - - fun readValueFromFile(fileName: String, valueType: Class): T? { - val content: String = getContent(fileName) - return readValue(content, valueType) - } - - fun readValueFromClassPathFile(fileName: String, valueType: Class): T? { - val content: String = getClassPathFileContent(fileName) - return readValue(content, valueType) - } - - fun jsonNodeFromObject(from: kotlin.Any): JsonNode { - return jacksonObjectMapper().convertValue(from, JsonNode::class.java) - } - - fun jsonNodeFromClassPathFile(fileName: String): JsonNode { - val content: String = getClassPathFileContent(fileName) - return jsonNode(content) - } - - fun jsonNodeFromFile(fileName: String): JsonNode { - val content: String = getContent(fileName) - return jsonNode(content) - } - - fun jsonNode(content: String): JsonNode { - return jacksonObjectMapper().readTree(content) - } - - fun getJson(any: kotlin.Any): String { - return getJson(any, false) - } - - fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String { - val wrapperMap = hashMapOf() - wrapperMap[wrapper] = any - return getJson(wrapperMap, pretty) - } - - fun getJson(any: kotlin.Any, pretty: Boolean = false): String { - val objectMapper = jacksonObjectMapper() - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) - if (pretty) { - objectMapper.enable(SerializationFeature.INDENT_OUTPUT) - } - return objectMapper.writeValueAsString(any) - } - - fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode { - val objectMapper = jacksonObjectMapper() - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) - if (pretty) { - objectMapper.enable(SerializationFeature.INDENT_OUTPUT) - } - return objectMapper.valueToTree(any) - } - - fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { - return getListFromJson(node.toString(), valueType) - } - - fun getListFromJson(content: String, valueType: Class): List? { - val objectMapper = jacksonObjectMapper() - val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) - return objectMapper.readValue>(content, javaType) - } - - fun getListFromFile(fileName: String, valueType: Class): List? { - val content: String = getContent(fileName) - return getListFromJson(content, valueType) - } - - fun getListFromClassPathFile(fileName: String, valueType: Class): List? { - val content: String = getClassPathFileContent(fileName) - return getListFromJson(content, valueType) - } - - fun getMapFromJson(content: String, valueType: Class): MutableMap? { - val objectMapper = jacksonObjectMapper() - val typeRef = object : TypeReference>() {} - return objectMapper.readValue(content, typeRef) - } - - fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { - val content: String = getContent(fileName) - return getMapFromJson(content, valueType) - } - - fun getInstanceFromMap(properties: MutableMap, classType: Class): T { - return readValue(getJson(properties), classType) - ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)") - } - - fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { - if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { - return checkJsonNodeValueOfPrimitiveType(type, jsonNode) - } else if (BluePrintTypes.validCollectionTypes().contains(type)) { - return checkJsonNodeValueOfCollectionType(type, jsonNode) - } - return false - } - - fun checkIfPrimitiveType(primitiveType: String): Boolean { - return when (primitiveType.toLowerCase()) { - BluePrintConstants.DATA_TYPE_STRING -> true - BluePrintConstants.DATA_TYPE_BOOLEAN -> true - BluePrintConstants.DATA_TYPE_INTEGER -> true - BluePrintConstants.DATA_TYPE_FLOAT -> true - BluePrintConstants.DATA_TYPE_DOUBLE -> true - BluePrintConstants.DATA_TYPE_TIMESTAMP -> true - else -> false - } - } - - fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { - return when (primitiveType.toLowerCase()) { - BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual - BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean - BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt - BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble - BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble - BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual - else -> false - } - } - - fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { - return when (type.toLowerCase()) { - BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray - BluePrintConstants.DATA_TYPE_MAP -> jsonNode.isContainerNode - else -> false - } - } - - fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) { - when (primitiveType.toLowerCase()) { - BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean) - BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int) - BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float) - BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, value as Double) - BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String) - else -> objectNode.put(key, value as String) - } - } - - fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) { - when (primitiveType.toLowerCase()) { - BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean) - BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int) - BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float) - BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(value as Double) - BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String) - else -> arrayNode.add(value as String) - } - } - - fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { - when (primitiveType.toLowerCase()) { - BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false) - BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0) - BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0) - BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, 0.0) - else -> objectNode.put(key, "") - } - } - - fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { - when (primitiveType.toLowerCase()) { - BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false) - BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0) - BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0) - BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(0.0) - else -> arrayNode.add("") - } - } - - fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { - if (nodeValue == null || nodeValue is NullNode) { - objectNode.set(key, nodeValue) - } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { - populatePrimitiveValues(key, nodeValue, type, objectNode) - } else { - objectNode.set(key, nodeValue) - } - } - - fun convertPrimitiveResourceValue(type: String, value: String): JsonNode { - return when (type.toLowerCase()) { - BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(java.lang.Boolean.valueOf(value)) - BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(Integer.valueOf(value)) - BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(java.lang.Float.valueOf(value)) - BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(java.lang.Double.valueOf(value)) - else -> getJsonNode(value) - } - } - - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt deleted file mode 100644 index bc0d9b4c6..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import org.apache.commons.io.FileUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import java.io.File -import java.net.URL -import java.nio.charset.Charset -/** - * - * - * @author Brinda Santh - */ -object ResourceResolverUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @JvmStatic - fun getFileContent(filename : String, basePath : String?): String { - log.trace("file ({}), basePath ({}) ", filename, basePath) - try{ - var resolvedFileName : String = filename - if(filename.startsWith("http", true) - || filename.startsWith("https", true)){ - val givenUrl : String = URL(filename).toString() - val systemUrl : String = File(".").toURI().toURL().toString() - log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl) - if(givenUrl.startsWith(systemUrl)){ - - } - }else{ - if(!filename.startsWith("/")){ - if (checkNotEmpty(basePath)) { - resolvedFileName = basePath.plus(File.separator).plus(filename) - }else{ - resolvedFileName = javaClass.classLoader.getResource(".").path.plus(filename) - } - } - } - return FileUtils.readFileToString(File(resolvedFileName), Charset.defaultCharset()) - }catch (e : Exception){ - throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt deleted file mode 100644 index 0249e20b1..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import org.apache.commons.io.FileUtils -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate -import java.io.File -import java.nio.charset.Charset - -/** - * - * - * @author Brinda Santh - */ -object ServiceTemplateUtils { - - @JvmStatic - fun getServiceTemplate(fileName: String): ServiceTemplate { - val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) - return getServiceTemplateFromContent(content) - } - - - @JvmStatic - fun getServiceTemplateFromContent(content: String): ServiceTemplate { - return JacksonUtils.readValue(content) - } - - fun merge(parentServiceTemplate: ServiceTemplate, toMerge: ServiceTemplate, removeImports: Boolean? = true): ServiceTemplate { - if (removeImports!!) { - parentServiceTemplate.imports = null - toMerge.imports = null - } - - toMerge.metadata?.let { - parentServiceTemplate.metadata = parentServiceTemplate.metadata ?: hashMapOf() - parentServiceTemplate.metadata?.putAll(toMerge.metadata as MutableMap) - } - - toMerge.dslDefinitions?.let { - parentServiceTemplate.dslDefinitions = parentServiceTemplate.dslDefinitions ?: hashMapOf() - parentServiceTemplate.dslDefinitions?.putAll(toMerge.dslDefinitions as MutableMap) - } - - toMerge.dataTypes?.let { - parentServiceTemplate.dataTypes = parentServiceTemplate.dataTypes ?: hashMapOf() - parentServiceTemplate.dataTypes?.putAll(toMerge.dataTypes as MutableMap) - } - - toMerge.nodeTypes?.let { - parentServiceTemplate.nodeTypes = parentServiceTemplate.nodeTypes ?: hashMapOf() - parentServiceTemplate.nodeTypes?.putAll(toMerge.nodeTypes as MutableMap) - } - - toMerge.artifactTypes?.let { - parentServiceTemplate.artifactTypes = parentServiceTemplate.artifactTypes ?: hashMapOf() - parentServiceTemplate.artifactTypes?.putAll(toMerge.artifactTypes as MutableMap) - } - - toMerge.repositories?.let { - parentServiceTemplate.repositories = parentServiceTemplate.repositories ?: hashMapOf() - parentServiceTemplate.repositories?.putAll(toMerge.repositories as MutableMap) - } - - parentServiceTemplate.topologyTemplate = parentServiceTemplate.topologyTemplate ?: TopologyTemplate() - - toMerge.topologyTemplate?.inputs?.let { - parentServiceTemplate.topologyTemplate?.inputs = parentServiceTemplate.topologyTemplate?.inputs ?: hashMapOf() - parentServiceTemplate.topologyTemplate?.inputs?.putAll(parentServiceTemplate.topologyTemplate?.inputs as MutableMap) - } - - toMerge.topologyTemplate?.nodeTemplates?.let { - parentServiceTemplate.topologyTemplate?.nodeTemplates = parentServiceTemplate.topologyTemplate?.nodeTemplates ?: hashMapOf() - parentServiceTemplate.topologyTemplate?.nodeTemplates?.putAll(parentServiceTemplate.topologyTemplate?.nodeTemplates as MutableMap) - } - - toMerge.topologyTemplate?.relationshipTemplates?.let { - parentServiceTemplate.topologyTemplate?.relationshipTemplates = parentServiceTemplate.topologyTemplate?.relationshipTemplates ?: hashMapOf() - parentServiceTemplate.topologyTemplate?.relationshipTemplates?.putAll(parentServiceTemplate.topologyTemplate?.relationshipTemplates as MutableMap) - } - - toMerge.topologyTemplate?.policies?.let { - parentServiceTemplate.topologyTemplate?.policies = parentServiceTemplate.topologyTemplate?.policies ?: hashMapOf() - parentServiceTemplate.topologyTemplate?.policies?.putAll(parentServiceTemplate.topologyTemplate?.policies as MutableMap) - } - - toMerge.topologyTemplate?.workflows?.let { - parentServiceTemplate.topologyTemplate?.workflows = parentServiceTemplate.topologyTemplate?.workflows ?: hashMapOf() - parentServiceTemplate.topologyTemplate?.workflows?.putAll(parentServiceTemplate.topologyTemplate?.workflows as MutableMap) - } - return parentServiceTemplate - } - - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt deleted file mode 100644 index 9d6fe084a..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import java.util.* - -/** - * - * - * @author Brinda Santh - */ -class TopologicalSortingUtils { - - private val neighbors: MutableMap> = hashMapOf() - - val isDag: Boolean - get() = topSort() != null - - override fun toString(): String { - val s = StringBuffer() - for (v in neighbors.keys) - s.append("\n " + v + " -> " + neighbors[v]) - return s.toString() - } - - fun getNeighbors(): Map> { - return neighbors - } - - fun add(vertex: V) { - if (neighbors.containsKey(vertex)) - return - neighbors[vertex] = arrayListOf() - } - - operator fun contains(vertex: V): Boolean { - return neighbors.containsKey(vertex) - } - - fun add(from: V, to: V) { - this.add(from) - this.add(to) - neighbors[from]?.add(to) - } - - fun remove(from: V, to: V) { - if (!(this.contains(from) && this.contains(to))) - throw IllegalArgumentException("Nonexistent vertex") - neighbors[from]?.remove(to) - } - - fun outDegree(): Map { - val result: MutableMap = hashMapOf() - for (v in neighbors.keys) - result[v] = neighbors[v]!!.size - return result - } - - - fun inDegree(): MutableMap { - val result = HashMap() - for (v in neighbors.keys) - result[v] = 0 // All in-degrees are 0 - for (from in neighbors.keys) { - for (to in neighbors[from]!!) { - result[to] = result[to]!! + 1 // Increment in-degree - } - } - return result - } - - fun topSort(): List? { - val degree = inDegree() - // Determine all vertices with zero in-degree - val zeroVerts = Stack() // Stack as good as any here - for (v in degree.keys) { - if (degree[v] == 0) zeroVerts.push(v) - } - // Determine the topological order - val result = ArrayList() - while (!zeroVerts.isEmpty()) { - val v = zeroVerts.pop() // Choose a vertex with zero in-degree - result.add(v) // Vertex v is next in topol order - // "Remove" vertex v by updating its neighbors - for (neighbor in neighbors[v]!!) { - degree[neighbor] = degree[neighbor]!! - 1 - // Remember any vertices that now have zero in-degree - if (degree[neighbor] == 0) zeroVerts.push(neighbor) - } - } - // Check that we have used the entire graph (if not, there was a cycle) - return if (result.size != neighbors.size) null else result - } - - - fun bfsDistance(start: V): Map<*, *> { - val distance: MutableMap = hashMapOf() - // Initially, all distance are infinity, except start node - for (v in neighbors.keys) - distance[v] = -1 - distance[start] = 0 - // Process nodes in queue order - val queue = LinkedList() - queue.offer(start) // Place start node in queue - while (!queue.isEmpty()) { - val v = queue.remove() - val vDist = distance[v]!! - // Update neighbors - for (neighbor in neighbors[v]!!) { - if (distance[neighbor] != null) continue // Ignore if already done - distance[neighbor] = vDist + 1 - queue.offer(neighbor) - } - } - return distance - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt deleted file mode 100644 index e383588ee..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator { - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { - - artifactType.properties?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, artifactType.properties!!) - } - // TODO ("Files Present ") - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt deleted file mode 100644 index 53a27b53d..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) { - //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt deleted file mode 100644 index 980302bf9..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString()) - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { - log.trace("Validating DataType($name)") - - dataType.properties?.let { - - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, dataType.properties!!) - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt deleted file mode 100644 index 0ed87f813..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils - - -open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) - - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - lateinit var bluePrintContext: BluePrintContext - var paths: MutableList = arrayListOf() - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - log.info("Validating NodeTemplate($nodeTemplateName)") - - this.bluePrintRuntimeService = bluePrintRuntimeService - this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() - - paths.add(nodeTemplateName) - - val type: String = nodeTemplate.type - - val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type) - ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)") - - nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } - nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } - nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } - - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateArtifactDefinitions(artifacts: MutableMap) { - paths.add("artifacts") - artifacts.forEach { artifactDefinitionName, artifactDefinition -> - paths.add(artifactDefinitionName) - val type: String = artifactDefinition.type - ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)") - // Check Artifact Type - checkValidArtifactType(artifactDefinitionName, type) - - val file: String = artifactDefinition.file - ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)") - - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - - @Throws(BluePrintException::class) - open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, - properties: MutableMap) { - properties.forEach { propertyName, propertyAssignment -> - val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] - ?: throw BluePrintException("failed to get definition for the property ($propertyName)") - - validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) - - } - } - - @Throws(BluePrintException::class) - open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition, - propertyAssignment: JsonNode) { - // Check and Validate if Expression Node - val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) - if (!expressionData.isExpression) { - checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) - } - } - - @Throws(BluePrintException::class) - open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - val capabilities = nodeTemplate.capabilities - paths.add("capabilities") - capabilities?.forEach { capabilityName, capabilityAssignment -> - paths.add(capabilityName) - - val capabilityDefinition = nodeType.capabilities?.get(capabilityName) - ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) capability definition ($capabilityName) " + - "from NodeType(${nodeTemplate.type})") - - validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) - - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - @Throws(BluePrintException::class) - open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String, - capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) { - - capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } - - } - - @Throws(BluePrintException::class) - open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - val requirements = nodeTemplate.requirements - paths.add("requirements") - requirements?.forEach { requirementName, requirementAssignment -> - paths.add(requirementName) - val requirementDefinition = nodeType.requirements?.get(requirementName) - ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) requirement definition ($requirementName) from" + - " NodeType(${nodeTemplate.type})") - // Validate Requirement Assignment - validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - - } - - @Throws(BluePrintException::class) - open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, - requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { - log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) - val requirementNodeTemplateName = requirementAssignment.node!! - val capabilityName = requirementAssignment.capability - val relationship = requirementAssignment.relationship!! - - check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { - throw BluePrintException("Failed to get relationship type ($relationship) for NodeTemplate($nodeTemplateName)'s requirement($requirementAssignmentName)") - } - - val relationShipNodeTemplate = bluePrintContext.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) - ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + - "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)") - - relationShipNodeTemplate.capabilities?.get(capabilityName) - ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + - "capability($capabilityName) for NodeTemplate ($nodeTemplateName)'s requirement($requirementAssignmentName)") - - - } - - @Throws(BluePrintException::class) - open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { - - val interfaces = nodeTemplate.interfaces - paths.add("interfaces") - interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> - paths.add(interfaceAssignmentName) - val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) - ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) interface definition ($interfaceAssignmentName) from" + - " NodeType(${nodeTemplate.type})") - - validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, - interfaceAssignment) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - - - } - - @Throws(BluePrintException::class) - open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String, - interfaceDefinition: InterfaceDefinition, - interfaceAssignment: InterfaceAssignment) { - - val operations = interfaceAssignment.operations - operations?.let { - validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, - interfaceAssignment) - } - - } - - @Throws(BluePrintException::class) - open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String, - interfaceDefinition: InterfaceDefinition, - interfaceAssignment: InterfaceAssignment) { - - val operations = interfaceAssignment.operations - operations?.let { - it.forEach { operationAssignmentName, operationAssignments -> - - val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) - ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)") - - log.info("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation ($operationAssignmentName)") - - val inputs = operationAssignments.inputs - val outputs = operationAssignments.outputs - - inputs?.forEach { propertyName, propertyAssignment -> - val propertyDefinition = operationDefinition.inputs?.get(propertyName) - ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation " + - "definition ($operationAssignmentName) property definition($propertyName)") - // Check the property values with property definition - validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) - } - - outputs?.forEach { propertyName, propertyAssignment -> - val propertyDefinition = operationDefinition.outputs?.get(propertyName) - ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " + - "output property definition($propertyName)") - // Check the property values with property definition - validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) - } - - } - } - - } - - open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { - - val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) - ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") - - checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) - } - - @Throws(BluePrintException::class) - open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") - } - } - - open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { - val propertyType = propertyDefinition.type - val isValid: Boolean - - if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { - isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) - - } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { - - val entrySchemaType = propertyDefinition.entrySchema?.type - ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) - - if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { - checkPropertyDataType(entrySchemaType, propertyName) - } - isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) - } else { - checkPropertyDataType(propertyType, propertyName) - isValid = true - } - - check(isValid) { - throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)") - } - } - - private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { - - val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName) - ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found") - - checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) - - } - - private fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ") - } - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt deleted file mode 100644 index 1077f347e..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - - -open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - lateinit var bluePrintContext: BluePrintContext - var paths: MutableList = arrayListOf() - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTypeName: String, nodeType: NodeType) { - log.trace("Validating NodeType($nodeTypeName)") - this.bluePrintRuntimeService = bluePrintRuntimeService - this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() - - paths.add(nodeTypeName) - - val derivedFrom: String = nodeType.derivedFrom - //Check Derived From - checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) - - if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { - bluePrintContext.serviceTemplate.nodeTypes?.get(derivedFrom) - ?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)") - } - - nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) } - nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } - nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } - nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } - - paths.removeAt(paths.lastIndex) - } - - fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException("Failed to get node type ($nodeTypeName)'s derivedFrom($derivedFrom) definition ") - } - } - - open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { - val capabilities = nodeType.capabilities - paths.add("capabilities") - capabilities?.forEach { capabilityName, capabilityDefinition -> - paths.add(capabilityName) - - validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition) - - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String, - capabilityDefinition: CapabilityDefinition) { - val capabilityType = capabilityDefinition.type - check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { - throw BluePrintException("failed to get CapabilityType($capabilityType) for NodeType($nodeTypeName)") - } - } - - open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { - paths.add("requirements") - val requirements = nodeType.requirements - - requirements?.forEach { requirementDefinitionName, requirementDefinition -> - paths.add(requirementDefinitionName) - validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition) - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String, - requirementDefinition: RequirementDefinition) { - - log.info("validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName) - val requirementNodeTypeName = requirementDefinition.node!! - val capabilityName = requirementDefinition.capability - val relationship = requirementDefinition.relationship!! - - check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { - throw BluePrintException("failed to get relationship($relationship) for NodeType($nodeTypeName)'s requirement($requirementDefinitionName)") - } - - val relationShipNodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(requirementNodeTypeName) - ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s for requirement($requirementDefinitionName) ") - - relationShipNodeType.capabilities?.get(capabilityName) - ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s " + - "capability($nodeTypeName) for NodeType ($capabilityName)'s requirement($requirementDefinitionName) ") - - } - - open fun validateInterfaceDefinitions(interfaces: MutableMap) { - paths.add("interfaces") - interfaces.forEach { interfaceName, interfaceDefinition -> - paths.add(interfaceName) - interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - open fun validateOperationDefinitions(operations: MutableMap) { - paths.add("operations") - operations.forEach { opertaionName, operationDefinition -> - paths.add(opertaionName) - operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } - - operationDefinition.inputs?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, operationDefinition.inputs!!) - } - - operationDefinition.outputs?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, operationDefinition.outputs!!) - } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - } - - open fun validateImplementation(implementation: Implementation) { - checkNotEmptyOrThrow(implementation.primary) - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt deleted file mode 100644 index ca156190c..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { - this.bluePrintRuntimeService = bluePrintRuntimeService - - - log.trace("Validating PropertyDefinition($name)") - - val dataType: String = propertyDefinition.type - - when { - BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { - // Do Nothing - } - BluePrintTypes.validCollectionTypes().contains(dataType) -> { - val entrySchemaType: String = propertyDefinition.entrySchema?.type - ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, name)) - checkPrimitiveOrComplex(entrySchemaType, name) - } - else -> checkPropertyDataType(dataType, name) - } - } - - - private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { - if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { - return true - } else { - throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) - } - } - - private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { - - val dataType = bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.get(dataTypeName) - ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) - - checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) - } - - private fun checkDataType(key: String): Boolean { - return bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.containsKey(key) ?: false - } - - open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { - check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { - throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) - } - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt deleted file mode 100644 index 61159cf8b..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.google.common.base.Preconditions -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError -import org.onap.ccsdk.apps.controllerblueprints.core.data.* -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - lateinit var error: BluePrintError - - var paths: MutableList = arrayListOf() - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { - log.trace("Validating Service Template..") - try { - this.bluePrintRuntimeService = bluePrintRuntimeService - this.error = bluePrintRuntimeService.getBluePrintError() - - serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } - serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } - serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) } - serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } - serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } - } catch (e: Exception) { - log.error("failed in blueprint service template validation", e) - error.addError(BluePrintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) - } - } - - fun validateMetadata(metaDataMap: MutableMap) { - - paths.add(BluePrintConstants.PATH_METADATA) - - val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] - val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] - val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] - val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] - - Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") - Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") - Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") - Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") - - paths.removeAt(paths.lastIndex) - } - - - fun validateDataTypes(dataTypes: MutableMap) { - - paths.add(BluePrintConstants.PATH_DATA_TYPES) - dataTypes.forEach { dataTypeName, dataType -> - // Validate Single Data Type - bluePrintTypeValidatorService.validateDataType(bluePrintRuntimeService, dataTypeName, dataType) - } - paths.removeAt(paths.lastIndex) - } - - fun validateArtifactTypes(artifactTypes: MutableMap) { - paths.add(BluePrintConstants.PATH_ARTIFACT_TYPES) - artifactTypes.forEach { artifactName, artifactType -> - // Validate Single Artifact Type - bluePrintTypeValidatorService.validateArtifactType(bluePrintRuntimeService, artifactName, artifactType) - } - paths.removeAt(paths.lastIndex) - } - - fun validateNodeTypes(nodeTypes: MutableMap) { - paths.add(BluePrintConstants.PATH_NODE_TYPES) - nodeTypes.forEach { nodeTypeName, nodeType -> - // Validate Single Node Type - bluePrintTypeValidatorService.validateNodeType(bluePrintRuntimeService, nodeTypeName, nodeType) - } - paths.removeAt(paths.lastIndex) - } - - fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { - paths.add(BluePrintConstants.PATH_TOPOLOGY_TEMPLATE) - bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintRuntimeService, "topologyTemplate", topologyTemplate) - paths.removeAt(paths.lastIndex) - } -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt deleted file mode 100644 index b87666d2d..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { - log.trace("Validating Topology Template..") - this.bluePrintRuntimeService = bluePrintRuntimeService - - // Validate Inputs - topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } - // Validate Node Templates - topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) } - // Validate Workflow - topologyTemplate.workflows?.let { validateWorkflows(topologyTemplate.workflows!!) } - } - - @Throws(BluePrintException::class) - fun validateInputs(inputs: MutableMap) { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, inputs) - } - - - @Throws(BluePrintException::class) - fun validateNodeTemplates(nodeTemplates: MutableMap) { - - nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> - // Validate Single Node Template - bluePrintTypeValidatorService.validateNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeTemplate) - } - } - - @Throws(BluePrintException::class) - open fun validateWorkflows(workflows: MutableMap) { - - workflows.forEach { workflowName, workflow -> - // Validate Single workflow - bluePrintTypeValidatorService.validateWorkflow(bluePrintRuntimeService, workflowName, workflow) - } - } - -} \ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt deleted file mode 100644 index 4f68342eb..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import java.util.* - - -open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) - - override fun validateBluePrints(basePath: String): Boolean { - - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) - return validateBluePrints(bluePrintRuntimeService) - } - - override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { - - bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", - bluePrintRuntimeService.bluePrintContext().serviceTemplate) - if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { - throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") - } - return true - } -} diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt deleted file mode 100644 index f55449efa..000000000 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService - -open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) - lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> - - var paths: MutableList = arrayListOf() - - override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, workflowName: String, workflow: Workflow) { - log.info("Validating Workflow($workflowName)") - - this.bluePrintRuntimeService = bluePrintRuntimeService - - - paths.add(workflowName) - paths.joinToString(BluePrintConstants.PATH_DIVIDER) - - // Step Validation Start - paths.add("steps") - workflow.steps?.forEach { stepName, step -> - paths.add(stepName) - paths.joinToString(BluePrintConstants.PATH_DIVIDER) - - // Validate target - step.target?.let { - try { - val nodeTemplate = bluePrintRuntimeService.bluePrintContext().nodeTemplateByName(it) - - val nodeTypeDerivedFrom = bluePrintRuntimeService.bluePrintContext().nodeTemplateNodeType(it).derivedFrom - - check(nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_DG) { - "NodeType(${nodeTemplate.type}) derived from is '$nodeTypeDerivedFrom', Expected is " + - "'${BluePrintConstants.MODEL_TYPE_NODE_DG}'" - } - } catch (e: Exception) { - bluePrintRuntimeService.getBluePrintError() - .addError("Failed to validate Workflow($workflowName)'s step($stepName)'s " + - "definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) - } - } - paths.removeAt(paths.lastIndex) - } - paths.removeAt(paths.lastIndex) - // Step Validation Ends - paths.removeAt(paths.lastIndex) - - workflow.inputs?.let { - bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!) - } - } -} \ No newline at end of file diff --git a/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory deleted file mode 100644 index 89838f44f..000000000 --- a/components/core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright © 2017-2018 AT&T Intellectual Property. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt deleted file mode 100644 index 128b7f576..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core - -import org.junit.Test -import kotlin.test.assertEquals -/** - * - * - * @author Brinda Santh - */ -class CustomFunctionsTest { - @Test - fun testFormat(): Unit { - val returnValue : String = format("This is {} for times {}", "test", 2) - assertEquals("This is test for times 2", returnValue, "Failed to format String") - - val returnValue1 : String = format("This is test for times 2") - assertEquals("This is test for times 2", returnValue1, "Failed to format empty args") - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt deleted file mode 100644 index 4c174f92e..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.mock - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* -import org.onap.ccsdk.apps.controllerblueprints.core.validation.* - -class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService { - - override fun getServiceTemplateValidators(): List { - return listOf(BluePrintServiceTemplateValidatorImpl(this)) - } - - override fun getDataTypeValidators(): List { - return listOf(BluePrintDataTypeValidatorImpl(this)) - } - - override fun getArtifactTypeValidators(): List { - return listOf(BluePrintArtifactTypeValidatorImpl(this)) - } - - override fun getNodeTypeValidators(): List { - return listOf(BluePrintNodeTypeValidatorImpl(this)) - } - - override fun getTopologyTemplateValidators(): List { - return listOf(BluePrintTopologyTemplateValidatorImpl(this)) - } - - override fun getNodeTemplateValidators(): List { - return listOf(BluePrintNodeTemplateValidatorImpl(this)) - } - - override fun getWorkflowValidators(): List { - return listOf(BluePrintWorkflowValidatorImpl(this)) - } - - override fun getPropertyDefinitionValidators(): List { - return listOf(BluePrintPropertyDefinitionValidatorImpl(this)) - } - - override fun getAttributeDefinitionValidators(): List { - return listOf(BluePrintAttributeDefinitionValidatorImpl(this)) - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt deleted file mode 100644 index 6cfed3246..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import kotlin.test.assertNotNull - -/** - * - * - * @author Brinda Santh - */ -class BluePrintContextTest { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") - - @Test - fun testBluePrintContextCreation() { - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) - assertNotNull(bluePrintContext, "Failed to populate Blueprint context") - } - - @Test - fun testChainedProperty() { - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) - val nodeType = bluePrintContext.nodeTypeChained("component-resource-assignment") - assertNotNull(nodeType, "Failed to get chained node type") - log.trace("Properties {}", JacksonUtils.getJson(nodeType, true)) - } - - -} diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt deleted file mode 100644 index a0214023e..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -/** - * - * - * @author Brinda Santh - */ -class BluePrintExpressionServiceTest { - @Test - fun testInputExpression() { - val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }") - val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) - assertNotNull(expressionData, " Failed to populate expression data") - assertEquals(expressionData.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData.inputExpression, " Failed to populate input expression data") - assertEquals("input-name", expressionData.inputExpression?.propertyName, "Failed to get propertyName from expression data") - } - - @Test - fun testPropertyExpression() { - val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }") - val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) - assertNotNull(expressionData, " Failed to populate expression data") - assertEquals(expressionData.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data") - assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName") - - val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }") - val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) - assertNotNull(expressionData1, " Failed to populate expression data") - assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression") - assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data") - assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName") - assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data") - } - - @Test - fun testAttributeExpression() { - val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }") - val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) - assertNotNull(expressionData, " Failed to populate expression data") - assertEquals(expressionData.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data") - assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName") - - val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }") - val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) - assertNotNull(expressionData1, " Failed to populate expression data") - assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data") - assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName") - assertEquals("resource/name",expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data") - } - - - @Test - fun testOutputOperationExpression() { - val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }") - val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) - assertNotNull(expressionData, " Failed to populate expression data") - assertEquals(expressionData.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data") - assertEquals("SELF", expressionData.operationOutputExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("interface-name", expressionData.operationOutputExpression?.interfaceName, " Failed to get expected interfaceName") - assertEquals("operation-name", expressionData.operationOutputExpression?.operationName, " Failed to get expected operationName") - assertEquals("output-property-name", expressionData.operationOutputExpression?.propertyName, " Failed to get expected propertyName") - } - - - @Test - fun testArtifactExpression() { - val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }") - val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) - assertNotNull(expressionData, " Failed to populate expression data") - assertEquals(expressionData.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data") - assertEquals("SELF", expressionData.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName") - - - val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }") - val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) - assertNotNull(expressionData1, " Failed to populate expression data") - assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") - assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data") - assertEquals("SELF", expressionData1.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName") - assertEquals("artifact-template", expressionData1.artifactExpression?.artifactName, " Failed to get expected artifactName") - assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location") - assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove") - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt deleted file mode 100644 index 9348a237e..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import kotlin.test.assertNotNull - -/** - * BluePrintRepoFileServiceTest - * @author Brinda Santh - * - */ -class BluePrintRepoFileServiceTest { - - private val basePath = "load/model_type" - private val bluePrintRepoFileService = BluePrintRepoFileService(basePath) - - @Test - fun testGetDataType() { - val dataType = bluePrintRepoFileService.getDataType("dt-v4-aggregate") - assertNotNull(dataType, "Failed to get DataType from repo") - } - - @Test - fun testGetNodeType() { - val nodeType = bluePrintRepoFileService.getNodeType("component-resource-assignment") - assertNotNull(nodeType, "Failed to get NodeType from repo") - } - - @Test - fun testGetArtifactType() { - val nodeType = bluePrintRepoFileService.getArtifactType("artifact-template-velocity") - assertNotNull(nodeType, "Failed to get ArtifactType from repo") - } - - @Test(expected = BluePrintException::class) - fun testModelNotFound() { - val dataType = bluePrintRepoFileService.getDataType("dt-not-found") - assertNotNull(dataType, "Failed to get DataType from repo") - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt deleted file mode 100644 index 02148f08a..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.NullNode -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - -/** - * - * - * @author Brinda Santh - */ -class BluePrintRuntimeServiceTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @Test - fun `test Resolve NodeTemplate Properties`() { - log.info("************************ testResolveNodeTemplateProperties **********************") - - val bluePrintRuntimeService = getBluePrintRuntimeService() - - val inputDataPath = "src/test/resources/data/default-context.json" - - val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath) - bluePrintRuntimeService.assignInputs(inputNode) - - val propContext: MutableMap = bluePrintRuntimeService - .resolveNodeTemplateProperties("activate-process") - - assertNotNull(propContext, "Failed to populate interface property values") - } - - @Test - fun `test resolve NodeTemplate Capability Properties`() { - log.info("************************ testResolveNodeTemplateRequirementProperties **********************") - val bluePrintRuntimeService = getBluePrintRuntimeService() - - val executionContext = bluePrintRuntimeService.getExecutionContext() - - BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), - "data/default-context.json", executionContext) - - val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", - "netconf") - assertNotNull(capProperties, "Failed to populate capability property values") - assertEquals(capProperties["target-ip-address"], JacksonUtils.jsonNodeFromObject("localhost"), "Failed to populate parameter target-ip-address") - assertEquals(capProperties["port-number"], JacksonUtils.jsonNodeFromObject(830), "Failed to populate parameter port-number") - } - - @Test - fun `test Resolve NodeTemplate Interface Operation Inputs`() { - log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") - - val bluePrintRuntimeService = getBluePrintRuntimeService() - - val executionContext = bluePrintRuntimeService.getExecutionContext() - - BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), - "data/default-context.json", executionContext) - - val inContext: MutableMap = bluePrintRuntimeService - .resolveNodeTemplateInterfaceOperationInputs("resource-assignment", - "ResourceAssignmentComponent", "process") - - assertNotNull(inContext, "Failed to populate interface input property values") - assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") - assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name") - } - - @Test - fun `test Resolve NodeTemplate Interface Operation Outputs`() { - log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************") - - val bluePrintRuntimeService = getBluePrintRuntimeService() - - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance()) - - bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", - "ResourceAssignmentComponent", "process") - - val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "ResourceAssignmentComponent", "process", "status") - assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status") - - val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", - "ResourceAssignmentComponent", "process", "resource-assignment-params") - assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params") - - } - - @Test - fun `test NodeTemplate Context Property`() { - log.info("************************ testNodeTemplateContextProperty **********************") - val bluePrintRuntimeService = getBluePrintRuntimeService() - - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1", - JacksonUtils.jsonNodeFromObject("context1-value")) - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2", - JacksonUtils.jsonNodeFromObject("context2-value")) - - val keys = listOf("context1", "context2") - - val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys) - assertNotNull(jsonValueNode, "Failed to get Json for Node Template Context Properties") - log.info("JSON Prepared Value Context {}", jsonValueNode) - - } - - private fun getBluePrintRuntimeService(): BluePrintRuntimeService> { - val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") - val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) - val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) - - assertEquals(blueprintBasePath.asJsonPrimitive(), checkBasePath, "Failed to get base path after runtime creation") - - return blueprintRuntime - } - -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt deleted file mode 100644 index 663a3751a..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import kotlin.test.assertNotNull - -class BluePrintTemplateServiceTest { - - @Test - fun testGenerateContent() { - - val template = JacksonUtils.getClassPathFileContent("templates/base-config-template.vtl") - val json = JacksonUtils.getClassPathFileContent("templates/base-config-data.json") - - val content = BluePrintTemplateService.generateContent(template, json) - assertNotNull(content, "failed to generate content for velocity template") - - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt deleted file mode 100644 index 09c58170f..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.junit.Before -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils - -/** - * - * - * @author Brinda Santh - */ -class BluePrintValidatorDefaultServiceTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @Before - fun setUp(): Unit { - - } - - @Test - fun testValidateBluePrint() { - - val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) - val properties: MutableMap = hashMapOf() - - val validatorService = BluePrintValidatorDefaultService() - validatorService.validateBlueprint(bluePrintContext.serviceTemplate, properties) - log.info("Validation Message {}", properties) - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt deleted file mode 100644 index 59a037199..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import kotlinx.coroutines.runBlocking -import org.junit.Test -import java.io.File -import java.nio.file.Paths -import kotlin.test.assertTrue - - -class BluePrintFileUtilsTest { - - @Test - fun testNewBlueprint() = runBlocking { - val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-new-test") - BluePrintFileUtils.createEmptyBluePrint(targetPath) - - } - - @Test - fun testBlueprintCopy() = runBlocking { - val sourcePath: String = "./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration" - - val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-copy-test") - - val targetDir = File(targetPath) - targetDir.deleteOnExit() - // Copy the BP file - BluePrintFileUtils.copyBluePrint(sourcePath, targetDir.absolutePath) - - assertTrue(targetDir.exists(), "faield to copy blueprint to ${targetDir.absolutePath}") - - // Delete Type Files - BluePrintFileUtils.deleteBluePrintTypes(targetDir.absolutePath) - - // Generate the Type Files - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(sourcePath) - bluePrintContext.rootPath = targetDir.absolutePath - - BluePrintFileUtils.writeBluePrintTypes(bluePrintContext) - - - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt deleted file mode 100644 index d5b184f6e..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - - -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData -import kotlin.test.assertNotNull - -class BluePrintMetadataUtilsTest { - - @Test - fun testToscaMetaData(){ - - val basePath : String = "./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration" - - val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath) - assertNotNull(toscaMetaData, "Missing Tosca Definition Object") - assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version") - assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version") - assertNotNull(toscaMetaData.createdBy, "Missing Created by") - assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition") - assertNotNull(toscaMetaData.templateTags, "Missing Template Tags") - - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt deleted file mode 100644 index b5edab0fa..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import kotlin.test.assertNotNull -import kotlin.test.assertTrue - -/** - * JacksonUtilsTest - * @author Brinda Santh - * ${DATA} - */ -class JacksonUtilsTest { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) - - @Test - fun testJsonNodeFromClassPathFile() { - val filePath = "data/default-context.json" - JacksonUtils.jsonNodeFromClassPathFile(filePath) - } - - @Test - fun testJsonNodeFromFile() { - val filePath = "src/test/resources/data/default-context.json" - JacksonUtils.jsonNodeFromFile(filePath) - } - - @Test - fun testGetListFromJson() { - val content = "[\"good\",\"boy\" ]" - val nodeType = JacksonUtils.getListFromJson(content, String::class.java) - assertNotNull(nodeType, "Failed to get String array from content") - } - - - @Test - fun testJsonValue() { - val filePath = "data/alltype-data.json" - val rootJson = JacksonUtils.jsonNodeFromClassPathFile(filePath) - assertNotNull(rootJson, "Failed to get all type data json node") - val intValue = rootJson.get("intValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value") - val floatValue = rootJson.get("floatValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value") - val stringValue = rootJson.get("stringValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value") - val booleanValue = rootJson.get("booleanValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value") - val arrayStringValue = rootJson.get("arrayStringValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value") - val mapValue = rootJson.get("mapValue") - assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value") - - assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed") - - - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt deleted file mode 100644 index 3fa4f75d9..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.utils - -import org.junit.Test - -class TopologicalSortingUtilsTest { - - @Test - fun testSorting(): Unit { - val graph: TopologicalSortingUtils = TopologicalSortingUtils() - graph.add("bundle-id", "bundle-mac") - graph.add("bundle-id", "bundle-ip") - graph.add("bundle-mac", "bundle-ip") - graph.add("bundle-ip", "bundle-mac") - - println("The current graph: " + graph) - println("In-degrees: " + graph.inDegree()) - println("Out-degrees: " + graph.outDegree()) - println("A topological sort of the vertices: " + graph.topSort()) - } -} \ No newline at end of file diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt deleted file mode 100644 index 344b0cca8..000000000 --- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.core.validation - -import io.mockk.every -import io.mockk.mockk -import org.junit.Ignore -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType -import org.onap.ccsdk.apps.controllerblueprints.core.data.Step -import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow -import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext -import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -class BluePrintValidatorServiceImplTest { - - private val blueprintBasePath: String = ("./../model-catalog/blueprint-model/starter-blueprint/baseconfiguration") - private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) - private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() - private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) - private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService) - - @Test - fun testValidateOfType() { - val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime) - assertTrue(valid, "failed in blueprint Validation") - } - - @Test - fun testValidateWorkflowFailToFoundNodeTemplate() { - val workflowName = "resource-assignment" - - val step = Step() - step.target = "TestCaseFailNoNodeTemplate" - val workflow = Workflow() - workflow.steps = mutableMapOf("test" to step) - workflowValidator.validate(bluePrintRuntime, workflowName, workflow) - - assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size) - assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : could't get node template for the name(TestCaseFailNoNodeTemplate)", bluePrintRuntime.getBluePrintError().errors[0]) - } - - @Test - fun testValidateWorkflowFailNodeTemplateNotDgGeneric() { - val workflowName = "resource-assignment" - val nodeTemplateName = "resource-assignment-process" - - val nodeTemplate = mockk() - every { nodeTemplate.type } returns "TestNodeType" - - val nodeType = mockk() - every { nodeType.derivedFrom } returns "tosca.nodes.TEST" - - val blueprintContext = mockk() - every { blueprintContext.nodeTemplateByName(nodeTemplateName) } returns nodeTemplate - every { blueprintContext.nodeTemplateNodeType(nodeTemplateName) } returns nodeType - - val bluePrintRuntime = mockk("1234") - - every { bluePrintRuntime.getBluePrintError() } returns BluePrintError() - every { bluePrintRuntime.bluePrintContext() } returns blueprintContext - - val step = Step() - step.target = nodeTemplateName - val workflow = Workflow() - workflow.steps = mutableMapOf("test" to step) - workflowValidator.validate(bluePrintRuntime, workflowName, workflow) - - assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size) - assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', Expected is 'tosca.nodes.DG'", bluePrintRuntime.getBluePrintError().errors[0]) - } - - @Test - fun testValidateWorkflowSuccess() { - val workflowName = "resource-assignment" - workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName)) - } - -} - diff --git a/components/core/src/test/resources/componentnode/default.json b/components/core/src/test/resources/componentnode/default.json deleted file mode 100644 index 184b59881..000000000 --- a/components/core/src/test/resources/componentnode/default.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "metadata": { - "template_author": "bs2796", - "vendor": "Juniper", - "os": "XXX", - "service-type": "AVPN", - "vnf-type": "VRR", - "action": "Base Configuration", - "sub-action": "Generate Configuration", - "template_name": "VRR-baseconfiguration", - "template_version": "1.0.0" - }, - "topology_template": { - "inputs": { - "service-instance-id": { - "required": true, - "type": "string" - }, - "vnf-id": { - "required": true, - "type": "string" - }, - "service": { - "required": true, - "type": "string" - }, - "region": { - "required": true, - "type": "string" - }, - "bundle-id": { - "required": true, - "type": "string" - }, - "bundle-mac": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "generate-configuration": { - "type": "mock-component-generateConfig", - "interfaces": { - "org-onap-ccsdk-config-params-service-MockComponentNode": { - "operations": { - "process": { - "inputs": { - "entity-type": "vnf-type", - "template-content": "sample-template", - "entity-id": { "get_input" : "vnf-id" } - }, - "outputs": { - "mergedData": "merged Data", - "status": "status" - } - } - } - } - } - } - } - }, - "node_types": { - "mock-component-generateConfig": { - "interfaces": { - "org-onap-ccsdk-config-params-service-MockComponentNode": { - "operations": { - "process": { - "inputs": { - "entity-type": { - "required": false, - "type": "string" - }, - "template-content": { - "required": false, - "type": "string" - }, - "entity-id": { - "required": true, - "type": "string" - } - }, - "outputs": { - "generated-config": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - } - } -} diff --git a/components/core/src/test/resources/data/alltype-data.json b/components/core/src/test/resources/data/alltype-data.json deleted file mode 100644 index 055b09658..000000000 --- a/components/core/src/test/resources/data/alltype-data.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "intValue" : 1, - "floatValue" : 1.34, - "booleanValue" : true, - "stringValue" : "sample-String", - "timeValue" : "2018-09-29", - "arrayStringValue" : ["one", "two"], - "mapValue" : {"profile_name1":"profile_name1", - "profile_name2":"profile_name2"} -} \ No newline at end of file diff --git a/components/core/src/test/resources/data/default-context.json b/components/core/src/test/resources/data/default-context.json deleted file mode 100644 index e033f6f57..000000000 --- a/components/core/src/test/resources/data/default-context.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "request-id" : "12345", - "hostname" : "localhost", - "template_name": "baseconfiguration", - "template_version": "1.0.0", - "action-name" : "sample-action" -} \ No newline at end of file diff --git a/components/core/src/test/resources/dictionary/dictionary_schema.json b/components/core/src/test/resources/dictionary/dictionary_schema.json deleted file mode 100644 index 51db5f51a..000000000 --- a/components/core/src/test/resources/dictionary/dictionary_schema.json +++ /dev/null @@ -1,261 +0,0 @@ -{ - "type": "object", - "properties": { - "resource-path": { - "type": "string", - "required": true - }, - "description": { - "type": "string" - }, - "updated-by": { - "type": "string" - }, - "data-type": { - "type": "string", - "required": true - }, - "source": { - "type": "object", - "required": true, - "properties": { - "input": { - "type": "object", - "properties": { - "key": { - "type": "string" - } - } - }, - "component": { - "type": "object", - "properties": { - "name": { - "type": "string", - "required": true - }, - "input-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "output-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "default": { - "type": "any" - }, - "aai": { - "type": "any" - }, - "primary-config-data": { - "type": "object", - "properties": { - "path": { - "type": "string", - "required": true - }, - "url-path": { - "type": "string", - "required": true - }, - "input-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "type": { - "type": "string", - "required": true - }, - "output-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "base": { - "type": "string", - "required": true - } - } - }, - "network-resource-discovery": { - "type": "object", - "properties": { - "input-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "output-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - }, - "primary-db": { - "type": "object", - "properties": { - "query": { - "type": "string", - "required": true - }, - "input-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "type": { - "type": "string", - "required": true - }, - "output-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "base": { - "type": "string", - "required": true - } - } - }, - "policy": { - "type": "object", - "properties": { - "input-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "output-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - } - } - } - }, - "candidate-dependency": { - "type": "object", - "properties": { - "input": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "component": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "aai": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "primary-config-data": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "network-resource-discovery": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "primary-db": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "policy": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "tags": { - "type": "string" - }, - "default": { - "type": "any" - }, - "name": { - "type": "string", - "required": true - }, - "valid-values": { - "type": "string" - }, - "resource-type": { - "type": "string", - "required": true - }, - "sample-value": { - "type": "string" - }, - "entry-schema": { - "type": "string" - } - } -} diff --git a/components/core/src/test/resources/properties/convert.json b/components/core/src/test/resources/properties/convert.json deleted file mode 100644 index 966b02533..000000000 --- a/components/core/src/test/resources/properties/convert.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "type": "sdnc-component-getResourceAssignment", - "interfaces": { - "ResourceAssignmentService": { - "operations": { - "getResourceAssignment": { - "inputs": { - "assignment-mappings": [ - { - "name": "service-name", - "mapping-field": "service", - "mapping-category": "SDN", - "required": true - }, - { - "name": "region-name", - "mapping-field": "region", - "mapping-category": "SDN", - "required": true - } - ], - "pre-data": { - "get_input": "get-resource-assignment.config-params" - }, - "prifix": "get-resource-assignment" - }, - "outputs": { - "resource-assignment-status": "success", - "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" - } - } - } - } - } -} - diff --git a/components/core/src/test/resources/properties/default.json b/components/core/src/test/resources/properties/default.json deleted file mode 100644 index ec416dc95..000000000 --- a/components/core/src/test/resources/properties/default.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "default": { "get_input" : "loopback-default" }, - "domain": "ethernet", - "criteria": [ - { - "value": "attga301me1", - "type": "complex", - "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" - }, - { - "value": { "get_input" : "host-ip-address" }, - "type": "simple", - "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" - } - ] -} diff --git a/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts b/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts deleted file mode 100644 index 44cc957d2..000000000 --- a/components/core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode - -open class SampleBlueprintFunctionNode : BlueprintFunctionNode{ - - override fun getName(): String { - return "Kotlin-Script-Function-Node" - } - - override fun prepareRequest(executionRequest: String): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun process(executionRequest: String) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun recover(runtimeException: RuntimeException, executionRequest: String) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun prepareResponse(): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun apply(t: String): String { - return "$t-status" - } -} \ No newline at end of file diff --git a/components/core/src/test/resources/templates/base-config-data.json b/components/core/src/test/resources/templates/base-config-data.json deleted file mode 100755 index 2acc6fcdd..000000000 --- a/components/core/src/test/resources/templates/base-config-data.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "node0_hostname": "sdnc-host", - "node0_backup_router_address": "2001:1890:1253::192:168:100:1", - "servers": [ - "Server1", - "Server2", - "Server3" - ], - "tacplus-servers": [ - { - "tacplus-server-name": "tacplus-server-name1", - "tacplus-server-source-address": "enc-dsdsasa1" - }, - { - "tacplus-server-name": "tacplus-server-name2", - "tacplus-server-source-address": "enc-dsdsasa2" - } - ], - "classes": [ - { - "name": "superuser-class", - "idle-timeout": 5, - "permissions": "all" - }, - { - "name": "tacacs-adv-class", - "idle-timeout": 5 - }, - { - "name": "tacacs-base-class", - "idle-timeout": 5 - } - ], - "system-password": "teamops-system-password", - "root-password": "teamops-root-password" -} diff --git a/components/core/src/test/resources/templates/base-config-template.vtl b/components/core/src/test/resources/templates/base-config-template.vtl deleted file mode 100755 index f7b1269b3..000000000 --- a/components/core/src/test/resources/templates/base-config-template.vtl +++ /dev/null @@ -1,61 +0,0 @@ - - 15.1X49-D50.3 - - node0 - - #foreach($server in ${servers}) - $StringUtils.upperCase("$server") - #end - - - ${node0_hostname} - -
${node0_backup_router_address}
- $node0_backup_router_address -
- #foreach($tacplus-server in ${tacplus-servers}) - - $tacplus-server.tacplus-server-name - $tacplus-server.tacplus-server-source-address - - #end - - ONAP information assets - #foreach($class in ${classes}) - - $class.name - $class.idle-timeout - #if ($class.permissions) - $class.permissions - #end - - #end - - readonly - Read Only Account Access - 1001 - tacacs-base-class - - - readwrite - Read - Write Account Access - 1002 - tacacs-adv-class - - ${system-password} - - - - readwrite - Emergency Access Only - 1000 - superuser-class - - ${root-password} - - - -
-
-
\ No newline at end of file diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 6d5c2c140..761b0fad7 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -202,18 +202,6 @@
- - - org.onap.ccsdk.apps.controllerblueprints - core - ${project.version} - - - org.onap.ccsdk.apps.controllerblueprints - resource-dict - ${project.version} - - io.mockk diff --git a/components/pom.xml b/components/pom.xml index 95ffd5c02..c18e968fe 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -1,6 +1,7 @@ - - 4.0.0 - - org.onap.ccsdk.apps.components - parent - 0.4.1-SNAPSHOT - ../parent - - org.onap.ccsdk.apps.controllerblueprints - resource-dict - Controller Blueprints Resource Dictionary - - - - org.onap.ccsdk.apps.controllerblueprints - core - - - org.jetbrains.kotlin - kotlin-test-junit - test - - - - - diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt deleted file mode 100644 index d141ed0cb..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict - -import com.fasterxml.jackson.annotation.JsonFormat -import com.fasterxml.jackson.annotation.JsonProperty -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition -import java.io.Serializable -import java.util.* - -open class ResourceDefinition { - - @JsonProperty(value = "name", required = true) - lateinit var name: String - - @JsonProperty(value = "property", required = true) - lateinit var property: PropertyDefinition - - var tags: String? = null - - @JsonProperty(value = "updated-by") - lateinit var updatedBy: String - - @JsonProperty(value = "sources", required = true) - lateinit var sources: MutableMap -} - -open class ResourceAssignment { - - @JsonProperty(value = "name", required = true) - lateinit var name: String - - @JsonProperty(value = "property") - var property: PropertyDefinition? = null - - @JsonProperty("input-param") - var inputParameter: Boolean = false - - @JsonProperty("dictionary-name") - var dictionaryName: String? = null - - @JsonProperty("dictionary-source") - var dictionarySource: String? = null - - @JsonProperty("dependencies") - var dependencies: MutableList? = null - - @JsonProperty("version") - var version: Int = 0 - - @JsonProperty("status") - var status: String? = null - - @JsonProperty("message") - var message: String? = null - - @JsonProperty("updated-date") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - var updatedDate: Date? = null - - @JsonProperty("updated-by") - var updatedBy: String? = null - - override fun toString(): String { - return StringBuilder() - .append("[") - .append("name=", name) - .append(", dictionaryName=", dictionaryName) - .append(", dictionarySource=", dictionarySource) - .append("]") - .toString() - } -} - -/** - * Interface for Source Definitions (ex Input Source, - * Default Source, Database Source, Rest Sources, etc) - */ -interface ResourceSource : Serializable - - -open class ResourceSourceMapping { - lateinit var resourceSourceMappings: MutableMap -} diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt deleted file mode 100644 index aa06c9da0..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict - -/** - * ResourceDictionaryConstants - * - * @author Brinda Santh - */ -object ResourceDictionaryConstants { - const val SOURCE_INPUT = "input" - const val SOURCE_DEFAULT = "default" - const val SOURCE_PRIMARY_CONFIG_DATA = "primary-config-data" - const val SOURCE_PRIMARY_DB = "primary-db" - - const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" - - const val PROPERTY_TYPE = "type" - const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" - const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" - const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies" - - const val PATH_RESOURCE_DEFINITION_TYPE = "resource_definition_types" -} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt deleted file mode 100644 index 2911ab26a..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping - -/** - * ResourceSourceMappingFactory. - * - * @author Brinda Santh - */ -object ResourceSourceMappingFactory { - - private val resourceSourceMappings: MutableMap = hashMapOf() - - fun registerSourceMapping(sourceInstance: String, nodeTypeName: String) { - resourceSourceMappings[sourceInstance] = nodeTypeName - } - - fun getRegisterSourceMapping(sourceInstance: String): String { - return resourceSourceMappings[sourceInstance] - ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance)) - } - - fun getRegisterSourceMapping(): ResourceSourceMapping { - val resourceSourceMapping = ResourceSourceMapping() - resourceSourceMapping.resourceSourceMappings = resourceSourceMappings - return resourceSourceMapping - } -} - diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt deleted file mode 100644 index d71fbbf80..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.apache.commons.collections.CollectionUtils -import org.apache.commons.lang3.StringUtils -import org.apache.commons.lang3.text.StrBuilder -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory -import java.io.Serializable - -/** - * ResourceAssignmentValidationService. - * - * @author Brinda Santh - */ -interface ResourceAssignmentValidationService : Serializable { - - @Throws(BluePrintException::class) - fun validate(resourceAssignments: List): Boolean -} - -/** - * ResourceAssignmentValidationServiceImpl. - * - * @author Brinda Santh - */ -open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceImpl::class.java) - - open var resourceAssignmentMap: Map = hashMapOf() - open val validationMessage = StrBuilder() - - override fun validate(resourceAssignments: List): Boolean { - try { - validateSources(resourceAssignments) - validateTemplateNDictionaryKeys(resourceAssignments) - validateCyclicDependency(resourceAssignments) - if (StringUtils.isNotBlank(validationMessage)) { - throw BluePrintException("Resource Assignment Validation Failure") - } - } catch (e: Exception) { - throw BluePrintException("Resource Assignment Validation :" + validationMessage.toString(), e) - } - return true - } - - open fun validateSources(resourceAssignments: List) { - log.info("validating resource assignment sources") - // Check the Resource Assignment Source(Dynamic Instance) is valid. - resourceAssignments.forEach { resourceAssignment -> - try { - ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!) - } catch (e: BluePrintException) { - validationMessage.appendln(e.message + format(" for resource assignment({})", resourceAssignment.name)) - } - } - } - - open fun validateTemplateNDictionaryKeys(resourceAssignments: List) { - - resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap() - - // Check the Resource Assignment has Duplicate Key Names - val duplicateKeyNames = resourceAssignments.groupBy { it.name } - .filter { it.value.size > 1 } - .map { it.key } - - if (duplicateKeyNames.isNotEmpty()) { - validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames)) - } - - // Check the Resource Assignment has Duplicate Dictionary Names - val duplicateDictionaryKeyNames = resourceAssignments.groupBy { it.dictionaryName } - .filter { it.value.size > 1 } - .map { it.key } - if (duplicateDictionaryKeyNames.isNotEmpty()) { - validationMessage.appendln(String.format("Duplicate Assignment Dictionary Keys (%s) is Present", duplicateDictionaryKeyNames)) - } - - // Collect all the dependencies as a single list - val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten() - - // Check all the dependencies keys have Resource Assignment mappings. - val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct() - if (notPresentDictionaries.isNotEmpty()) { - validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries)) - } - - if (StringUtils.isNotBlank(validationMessage)) { - throw BluePrintException("Resource Assignment Validation Failure") - } - } - - open fun validateCyclicDependency(resourceAssignments: List) { - val startResourceAssignment = ResourceAssignment() - startResourceAssignment.name = "*" - - val topologySorting = TopologicalSortingUtils() - - resourceAssignmentMap.map { it.value }.map { resourceAssignment -> - if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { - resourceAssignment.dependencies!!.map { - log.info("Topological Graph link from {} to {}", it, resourceAssignment.name) - topologySorting.add(resourceAssignmentMap[it]!!, resourceAssignment) - } - } else { - topologySorting.add(startResourceAssignment, resourceAssignment) - } - } - - if (!topologySorting.isDag) { - val graph = getTopologicalGraph(topologySorting) - validationMessage.appendln("Cyclic Dependency :$graph") - } - } - - open fun getTopologicalGraph(topologySorting: TopologicalSortingUtils): String { - val s = StringBuilder() - val neighbors = topologySorting.getNeighbors() - - neighbors.forEach { v, vs -> - if (v.name == "*") { - s.append("\n * -> [") - for (resourceAssignment in vs) { - s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name - + "),") - } - s.append("]") - } else { - s.append("\n (" + v.dictionaryName + ":" + v.name + ") -> [") - for (resourceAssignment in vs) { - s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name - + "),") - } - s.append("]") - } - } - return s.toString() - } - - -} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt deleted file mode 100644 index 9541a7b89..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright © 2018 IBM. - * Modifications Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.google.common.base.Preconditions -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType -import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition -import org.onap.ccsdk.apps.controllerblueprints.core.format -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import java.io.Serializable - -/** - * ResourceDefinitionValidationService. - * - * @author Brinda Santh - */ -interface ResourceDefinitionValidationService : Serializable { - - @Throws(BluePrintException::class) - fun validate(resourceDefinition: ResourceDefinition) - -} - -/** - * ResourceDefinitionValidationService. - * - * @author Brinda Santh - */ -open class ResourceDefinitionValidationServiceImpl(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java) - - override fun validate(resourceDefinition: ResourceDefinition) { - Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition") - log.trace("Validating Resource Dictionary Definition {}", resourceDefinition.name) - - resourceDefinition.sources.forEach { name, nodeTemplate -> - val sourceType = nodeTemplate.type - - val sourceNodeType = bluePrintRepoService.getNodeType(sourceType) - - // Validate Property Name, expression, values and Data Type - validateNodeTemplateProperties(nodeTemplate, sourceNodeType) - } - } - - - open fun validateNodeTemplateProperties(nodeTemplate: NodeTemplate, nodeType: NodeType) { - nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } - } - - - open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, - properties: MutableMap) { - properties.forEach { propertyName, propertyAssignment -> - val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] - ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) - // Check and Validate if Expression Node - val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) - if (!expressionData.isExpression) { - checkPropertyValue(propertyDefinition, propertyName, propertyAssignment) - } else { - throw BluePrintException(format("property({}) of expression ({}) is not supported", - propertyName, propertyAssignment)) - } - } - } - - open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) { - val propertyType = propertyDefinition.type - val isValid: Boolean - - if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { - isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) - - } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { - - isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) - } else { - bluePrintRepoService.getDataType(propertyType) - isValid = true - } - - check(isValid) { - throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})", - propertyName, propertyType, propertyAssignment)) - } - } -} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt deleted file mode 100644 index 747639c89..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils - -import com.att.eelf.configuration.EELFLogger -import org.apache.commons.collections.CollectionUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import com.att.eelf.configuration.EELFManager -import java.util.ArrayList -/** - * BulkResourceSequencingUtils. - * - * @author Brinda Santh - */ -object BulkResourceSequencingUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java) - - @JvmStatic - fun process(resourceAssignments: MutableList): List> { - val resourceAssignmentMap: MutableMap = hashMapOf() - val sequenceBatchResourceAssignment = ArrayList>() - log.info("Assignments ({})", resourceAssignments) - // Prepare Map - resourceAssignments.forEach { resourceAssignment -> - log.trace("Processing Key ({})", resourceAssignment.name) - resourceAssignmentMap.put(resourceAssignment.name, resourceAssignment) - } - - val startResourceAssignment = ResourceAssignment() - startResourceAssignment.name = "*" - - // Preepare Sorting Map - val topologySorting = TopologicalSortingUtils() - resourceAssignmentMap.forEach { _, resourceAssignment -> - if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { - for (dependency in resourceAssignment.dependencies!!) { - topologySorting.add(resourceAssignmentMap[dependency]!!, resourceAssignment) - } - } else { - topologySorting.add(startResourceAssignment, resourceAssignment) - } - } - - val sequencedResourceAssignments: MutableList = topologySorting.topSort()!! as MutableList - log.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments) - - var batchResourceAssignment: MutableList? = null - var batchAssignmentName: MutableList? = null - - // Prepare Sorting - sequencedResourceAssignments.forEachIndexed { index, resourceAssignment -> - - var previousResourceAssignment: ResourceAssignment? = null - - if (index > 0) { - previousResourceAssignment = sequencedResourceAssignments[index - 1] - } - - var dependencyPresence = false - if (batchAssignmentName != null && resourceAssignment.dependencies != null) { - dependencyPresence = CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.dependencies) - } - - log.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name, - batchAssignmentName, resourceAssignment.dependencies, dependencyPresence) - - if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null - && resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true) - && !dependencyPresence) { - batchResourceAssignment!!.add(resourceAssignment) - batchAssignmentName!!.add(resourceAssignment.name) - } else { - if (batchResourceAssignment != null) { - sequenceBatchResourceAssignment.add(batchResourceAssignment!!) - log.trace("Created old Set ({})", batchAssignmentName) - } - batchResourceAssignment = arrayListOf() - batchResourceAssignment!!.add(resourceAssignment) - - batchAssignmentName = arrayListOf() - batchAssignmentName!!.add(resourceAssignment.name) - } - - if (index == sequencedResourceAssignments.size - 1) { - log.trace("Created old Set ({})", batchAssignmentName) - sequenceBatchResourceAssignment.add(batchResourceAssignment!!) - } - } - log.info("Batched Sequence : ({})", sequenceBatchResourceAssignment) - - return sequenceBatchResourceAssignment - } - -} \ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt deleted file mode 100644 index 1aeda0ba1..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.node.NullNode -import org.apache.commons.collections.MapUtils -import org.apache.commons.lang3.StringUtils -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants -import java.io.File - - -object ResourceDictionaryUtils { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java) - - @JvmStatic - fun populateSourceMapping(resourceAssignment: ResourceAssignment, - resourceDefinition: ResourceDefinition) { - - if (StringUtils.isBlank(resourceAssignment.dictionarySource)) { - - if (MapUtils.isNotEmpty(resourceDefinition.sources)) { - val source = findFirstSource(resourceDefinition.sources) - - // Populate and Assign First Source - if (StringUtils.isNotBlank(source)) { - // Set Dictionary Source - resourceAssignment.dictionarySource = source - } else { - resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT - } - log.info("auto map resourceAssignment : {}", resourceAssignment) - } else { - resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT - } - } - } - - @JvmStatic - fun findFirstSource(sources: Map): String? { - var source: String? = null - if (MapUtils.isNotEmpty(sources)) { - source = sources.keys.stream().findFirst().get() - } - return source - } - - @JvmStatic - fun assignInputs(data: JsonNode, context: MutableMap) { - log.trace("assignInputs from input JSON ({})", data.toString()) - data.fields().forEach { field -> - val valueNode: JsonNode = data.at("/".plus(field.key)) ?: NullNode.getInstance() - - val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(field.key) - log.trace("setting path ({}), values ({})", path, valueNode) - context[path] = valueNode - } - } - - fun getResourceAssignmentFromFile(filePath: String): List { - return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) - ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") - } - - fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map) { - val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) - .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json") - val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true) - BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent) - } -} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java deleted file mode 100644 index 1ed306e21..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceDefinitionTest { - private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class); - private String basePath = "load/resource_dictionary"; - - @Test - public void testDictionaryDefinitionInputSource(){ - - String fileName = basePath + "/input-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionDefaultSource(){ - - String fileName = basePath + "/default-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionDBSource(){ - - String fileName = basePath + "/primary-db-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for primary-db type", resourceDefinition); - } - - @Test - public void testDictionaryDefinitionMDSALSource(){ - String fileName = basePath + "/mdsal-source.json"; - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); - } -} diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java deleted file mode 100644 index f11638e35..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory; - -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; -import org.springframework.util.Assert; - -public class ResourceSourceMappingFactoryTest { - - @Test - public void testRegisterResourceMapping() { - - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); - ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-config-data", "source-rest"); - - String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db"); - Assert.notNull(nodeTypeName, "Failed to get primary-db mapping"); - - ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); - Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); - Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings"); - - } - -} diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt deleted file mode 100644 index 191f568f1..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service - -import com.att.eelf.configuration.EELFLogger -import org.junit.Assert -import org.junit.Test -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import com.att.eelf.configuration.EELFManager -import org.junit.Before -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils - -/** - * ResourceAssignmentValidationServiceTest. - * - * @author Brinda Santh - */ -class ResourceAssignmentValidationServiceTest { - private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) - @Before - fun setUp() { - // Setup dummy Source Instance Mapping - ResourceDictionaryTestUtils.setUpResourceSourceMapping() - } - - @Test - fun testValidateSuccess() { - log.info("**************** testValidateSuccess *****************") - val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() - val result = resourceAssignmentValidator.validate(assignments!!) - Assert.assertTrue("Failed to Validate", result) - } - - @Test(expected = BluePrintException::class) - fun testValidateDuplicate() { - log.info(" **************** testValidateDuplicate *****************") - val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() - resourceAssignmentValidator.validate(assignments!!) - } - - @Test(expected = BluePrintException::class) - fun testValidateCyclic() { - log.info(" **************** testValidateCyclic *****************") - val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java) - val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() - resourceAssignmentValidator.validate(assignments!!) - } -} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java deleted file mode 100644 index 7f040b2e2..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; - -public class ResourceDefinitionValidationServiceTest { - private String basePath = "load/model_type"; - private String dictionaryPath = "load/resource_dictionary"; - private BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath); - - @Test - public void testValidateSource() throws Exception { - - String inputFileName = dictionaryPath + "/input-source.json"; - testValidate(inputFileName); - - String dbFileName = dictionaryPath + "/primary-db-source.json"; - testValidate(dbFileName); - - String defaultFileName = dictionaryPath + "/default-source.json"; - testValidate(defaultFileName); - - String restFileName = dictionaryPath + "/mdsal-source.json"; - testValidate(restFileName); - } - - private void testValidate(String fileName) throws Exception { - - ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); - Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition); - - ResourceDefinitionValidationService resourceDictionaryValidationService = - new ResourceDefinitionValidationServiceImpl(bluePrintRepoFileService); - resourceDictionaryValidationService.validate(resourceDefinition); - Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition); - } -} diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java deleted file mode 100644 index a2c2310be..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import java.util.List; -/** - * BulkResourceSequencingUtils. - * - * @author Brinda Santh - */ -public class BulkResourceSequencingUtilsTest { - - @Test - public void testProcess(){ - List assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); - Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); - BulkResourceSequencingUtils.process(assignments); - } -} \ No newline at end of file diff --git a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java deleted file mode 100644 index 92bfa7301..000000000 --- a/components/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils; - - -import com.fasterxml.jackson.databind.JsonNode; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.HashMap; -import java.util.Map; -/** - * ResourceDictionaryUtilsTest. - * - * @author Brinda Santh - */ -public class ResourceDictionaryUtilsTest { - private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); - - @Test - public void testPopulateSourceMapping() { - - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("sample-assignment"); - ResourceDefinition resourceDefinition = new ResourceDefinition(); - Map sources = new HashMap<>(); - resourceDefinition.setSources(sources); - // To Check Empty Source - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource()); - - // To Check First Source - resourceAssignment.setDictionarySource(null); - sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate()); - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); - - // To Check Assigned Source - resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PRIMARY_DB); - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.getDictionarySource()); - - } - - @Test - public void testFindFirstSource() { - //To check if Empty Source - Map sources = new HashMap<>(); - String firstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertNull("Source populated, which is not expected.", firstSource); - - // TO check the first Source - sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate()); - String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); - - // TO check the multiple Source - sources.put(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, new NodeTemplate()); - String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); - Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); - - } - - @Test - public void testAssignInputs() { - JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); - Map context = new HashMap<>(); - ResourceDictionaryUtils.assignInputs(data, context); - String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue"); - log.info("populated context {}", context); - Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path)); - - } - - -} diff --git a/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt deleted file mode 100644 index 74ef6d6de..000000000 --- a/components/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils - -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory - -object ResourceDictionaryTestUtils { - - @JvmStatic - fun setUpResourceSourceMapping() { - ResourceSourceMappingFactory.registerSourceMapping("primary-db", "source-primary-db") - ResourceSourceMappingFactory.registerSourceMapping("input", "source-input") - ResourceSourceMappingFactory.registerSourceMapping("default", "source-default") - ResourceSourceMappingFactory.registerSourceMapping("primary-config-data", "source-rest") - } -} \ No newline at end of file diff --git a/components/resource-dict/src/test/resources/data/resource-assignment-input.json b/components/resource-dict/src/test/resources/data/resource-assignment-input.json deleted file mode 100644 index d79c90682..000000000 --- a/components/resource-dict/src/test/resources/data/resource-assignment-input.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "intValue" : 1, - "floatValue" : 1.34, - "booleanValue" : true, - "stringValue" : "sample-String", - "timeValue" : "2018-09-29", - "arrayStringValue" : ["one", "two"], - "mapValue" : {"profile_name1":"profile_name1", - "profile_name2":"profile_name2"} -} \ No newline at end of file diff --git a/components/resource-dict/src/test/resources/validation/cyclic.json b/components/resource-dict/src/test/resources/validation/cyclic.json deleted file mode 100644 index 98cd14446..000000000 --- a/components/resource-dict/src/test/resources/validation/cyclic.json +++ /dev/null @@ -1,111 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "managed-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip", - "dictionary-source": "primary-config-data", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "primary-config-data", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "primary-db", - "dependencies": [ - "bundle-mac", - "managed-ip1" - ] - } -] diff --git a/components/resource-dict/src/test/resources/validation/duplicate.json b/components/resource-dict/src/test/resources/validation/duplicate.json deleted file mode 100644 index 7581ff64d..000000000 --- a/components/resource-dict/src/test/resources/validation/duplicate.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "primary-config-data", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "primary-config-data", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "primary-db", - "dependencies": [ - "bundle-mac" - ] - } -] diff --git a/components/resource-dict/src/test/resources/validation/success.json b/components/resource-dict/src/test/resources/validation/success.json deleted file mode 100644 index 486251d60..000000000 --- a/components/resource-dict/src/test/resources/validation/success.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "primary-config-data", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "managed-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip", - "dictionary-source": "primary-config-data", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "primary-config-data", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "primary-db", - "dependencies": [ - "bundle-mac" - ] - } -] -- cgit 1.2.3-korg From ada281414b25536118e7b59368d92817ac687c4f Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 8 Feb 2019 12:15:11 -0500 Subject: Refactor test blueprint catalog Change-Id: I948067b25787c7a79f769ac4055c34ffdd2f172d Issue-ID: CCSDK-1047 Signed-off-by: Muthuramalingam, Brinda Santh --- .../Definitions/activation-blueprint.json | 336 --------------------- .../Definitions/artifact_types.json | 45 --- .../Definitions/baseconfig-mapping.json | 36 --- .../baseconfiguration/Definitions/data_types.json | 82 ----- .../baseconfiguration/Definitions/node_types.json | 234 -------------- .../Definitions/policy_types.json | 4 - .../Definitions/relationship_types.json | 9 - .../Definitions/resources_definition_types.json | 62 ---- .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 ---- .../Plans/CONFIG_ActivateNetconf_1.0.0.xml | 34 --- .../Plans/CONFIG_AssignActivateNetconf_1.0.0.xml | 42 --- .../Plans/CONFIG_ResourceAssignment_1.0.0.xml | 34 --- .../kotlin/ResourceAssignmentProcessor.cba.kts | 44 --- .../Scripts/kotlin/ScriptComponent.cba.kts | 46 --- .../Scripts/python/DefaultGetNetConfig.py | 50 --- .../Scripts/python/SamplePythonComponentNode.py | 12 - .../baseconfiguration/Scripts/python/__init__.py | 0 .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 8 - .../Templates/baseconfig-template.vtl | 1 - .../test-blueprint/CBA_Zip_Test.zip | Bin 0 -> 5382 bytes .../Definitions/activation-blueprint.json | 336 +++++++++++++++++++++ .../Definitions/artifact_types.json | 45 +++ .../Definitions/baseconfig-mapping.json | 36 +++ .../baseconfiguration/Definitions/data_types.json | 82 +++++ .../baseconfiguration/Definitions/node_types.json | 234 ++++++++++++++ .../Definitions/policy_types.json | 4 + .../Definitions/relationship_types.json | 9 + .../Definitions/resources_definition_types.json | 62 ++++ .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 ++++ .../Plans/CONFIG_ActivateNetconf_1.0.0.xml | 34 +++ .../Plans/CONFIG_AssignActivateNetconf_1.0.0.xml | 42 +++ .../Plans/CONFIG_ResourceAssignment_1.0.0.xml | 34 +++ .../kotlin/ResourceAssignmentProcessor.cba.kts | 44 +++ .../Scripts/kotlin/ScriptComponent.cba.kts | 46 +++ .../Scripts/python/DefaultGetNetConfig.py | 50 +++ .../Scripts/python/SamplePythonComponentNode.py | 12 + .../baseconfiguration/Scripts/python/__init__.py | 0 .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 8 + .../Templates/baseconfig-template.vtl | 1 + .../test-blueprints/CBA_Zip_Test.zip | Bin 5382 -> 0 bytes 40 files changed, 1145 insertions(+), 1145 deletions(-) delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/__init__.py delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl create mode 100755 components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/artifact_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/policy_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/relationship_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/baseconfig-template.vtl delete mode 100755 components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json deleted file mode 100644 index 822cc68b7..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json +++ /dev/null @@ -1,336 +0,0 @@ -{ - "metadata": { - "template_author": "Brinda Santh Muthuramalingam", - "author-email": "brindasanth@in.ibm.com", - "user-groups": "ADMIN, OPERATION", - "template_name": "baseconfiguration", - "template_version": "1.0.0", - "template_tags": "brinda, tosca" - }, - "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" - } - ], - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "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/CONFIG_ResourceAssignment_1.0.0.xml" - } - } - }, - "activate-process": { - "type": "dg-generic", - "properties": { - "content": { - "get_artifact": [ - "SELF", - "dg-activate-process" - ] - }, - "dependency-node-templates": [ - "activate-jython" - ] - }, - "artifacts": { - "dg-activate-process": { - "type": "artifact-directed-graph", - "file": "Plans/CONFIG_ActivateNetconf_1.0.0.xml" - } - } - }, - "assign-activate-process": { - "type": "dg-generic", - "properties": { - "content": { - "get_artifact": [ - "SELF", - "dg-assign-activate-process" - ] - }, - "dependency-node-templates": [ - "resource-assignment", - "activate-jython" - ] - }, - "artifacts": { - "dg-assign-activate-process": { - "type": "artifact-directed-graph", - "file": "Plans/CONFIG_AssignActivateNetconf_1.0.0.xml" - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "action-name": { - "get_input": "action-name" - }, - "resource-type": "vnf-type", - "request-id": { - "get_input": "request-id" - }, - "resource-id": { - "get_input": "hostname" - }, - "artifact-prefix-names": [ - "baseconfig" - ] - }, - "outputs": { - "resource-assignment-params": { - "get_attribute": [ - "SELF", - "assignment-params" - ] - }, - "status": "success" - } - } - } - } - }, - "artifacts": { - "baseconfig-template": { - "type": "artifact-template-velocity", - "file": "Templates/baseconfig-template.vtl" - }, - "baseconfig-mapping": { - "type": "artifact-mapping-resource", - "file": "Definitions/baseconfig-mapping.json" - } - } - }, - "resource-assignment-py": { - "type": "component-resource-assignment", - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "implementation": { - "primary": "component-script" - }, - "inputs": { - "action-name": { - "get_input": "action-name" - } - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "artifacts": { - "component-script": { - "type": "artifact-script-jython", - "file": "Scripts/python/SamplePythonComponentNode.py" - } - } - }, - "activate-jython": { - "type": "component-jython-executor", - "interfaces": { - "JythonExecutorComponent": { - "operations": { - "process": { - "implementation": { - "primary": "component-script" - }, - "inputs": { - "instance-dependencies": [ - "json-parser-service", - "netconf-rpc-service" - ] - }, - "outputs": { - "response-data": "", - "status": "" - } - } - } - } - }, - "artifacts": { - "component-script": { - "type": "artifact-script-jython", - "file": "Scripts/python/SamplePythonComponentNode.py" - } - } - }, - "activate-netconf": { - "type": "component-netconf-executor", - "interfaces": { - "NetconfExecutorComponent": { - "operations": { - "process": { - "implementation": { - "primary": "component-script" - }, - "inputs": { - "instance-dependencies": [ - "json-parser-service", - "netconf-rpc-service" - ] - }, - "outputs": { - "response-data": "", - "status": "" - } - } - } - } - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "sample-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "artifacts": { - "component-script": { - "type": "artifact-script-jython", - "file": "Scripts/python/DefaultGetNetConfig.py" - } - } - }, - "sample-netconf-device": { - "type": "vnf-netconf-device", - "capabilities": { - "netconf": { - "properties": { - "login-key": "sample-key", - "login-account": "sample-account", - "target-ip-address": "localhost", - "port-number": 830, - "connection-time-out": 30 - } - } - } - } - }, - "workflows": { - "resource-assignment": { - "inputs": { - "resource-assignment-properties": { - "required": true, - "type": "dt-resource-assignment-properties" - } - }, - "steps": { - "call-resource-assignment": { - "description": "Resource Assignment Workflow", - "target": "resource-assignment-process", - "activities": [ - { - "call_operation": "CONFIG.ResourceAssignment" - } - ] - } - } - }, - "activate": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "steps": { - "activate-process": { - "description": "Netconf Activation Workflow", - "target": "activate-process", - "activities": [ - { - "call_operation": "CONFIG.ActivateProcess" - } - ] - } - } - }, - "assign-activate": { - "inputs": { - "assign-activate-properties": { - "required": true, - "type": "dt-assign-activate-properties" - } - }, - "steps": { - "activate-process": { - "description": "Resource Assign and Netconf Activation Workflow", - "target": "assign-activate-process", - "activities": [ - { - "call_operation": "CONFIG.AssignActivateProcess" - } - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json deleted file mode 100644 index d741d151e..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/artifact_types.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "artifact_types": { - "artifact-template-velocity": { - "description": "Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-mapping-resource": { - "description": "Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-jython": { - "description": "Jython Script File", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-directed-graph": { - "description": "Directed Graph File", - "version": "1.0.0", - "file_ext": [ - "json", - "xml" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-component-jar": { - "description": "Component Jar", - "version": "1.0.0", - "file_ext": [ - "jar" - ], - "derived_from": "tosca.artifacts.Implementation" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json deleted file mode 100644 index 67d2a914e..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [ - ] - }, - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "vnf_name", - "input-param": false, - "property": { - "type": "string" - }, - "dictionary-name": "vnf_name", - "dictionary-source": "primary-config-data", - "dependencies": [ - "service-instance-id", - "vnf-id" - ] - } -] diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json deleted file mode 100644 index 6d771cd68..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "data_types": { - "sample-property": { - "description": "This is sample data type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "dt-resource-assignment-properties": { - "description": "This is Dynamically generated data type for workflow activate", - "version": "1.0.0", - "properties": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "vnf-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - }, - "vnf_name": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Dynamic" - }, - "dt-assign-activate-properties": { - "description": "This is Dynamically generated data type for workflow assign-activate", - "version": "1.0.0", - "properties": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Dynamic" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json deleted file mode 100644 index f7970bfbd..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json +++ /dev/null @@ -1,234 +0,0 @@ -{ - "node_types": { - "dg-generic": { - "description": "This is Generic Directed Graph Type", - "version": "1.0.0", - "properties": { - "content": { - "required": true, - "type": "string" - }, - "dependency-node-templates": { - "required": true, - "description": "Dependent Step Components", - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.DG" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph Node Type", - "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.Vnf" : { - "description" : "This is VNF Node Type", - "version" : "1.0.0", - "derived_from" : "tosca.nodes.Root" - }, - "tosca.nodes.component.Jython": { - "description": "This is Resource Assignment Jython Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "component-netconf-executor": { - "description": "This is Netconf Transaction Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vnf-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "NetconfExecutorComponent": { - "operations": { - "process": { - "inputs": { - "instance-dependencies": { - "description": "Instance Names to Inject to Jython Script.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "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.Jython" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "attributes": { - "assignment-params": { - "required": true, - "type": "string" - } - }, - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "artifact-prefix-names": { - "required": false, - "description": "Template , Resource Assignment Artifact Prefix names", - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "component-jython-executor": { - "description": "This is Jython Execution Component.", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "JythonExecutorComponent": { - "operations": { - "process": { - "inputs": { - "instance-dependencies": { - "required": true, - "description": "Instance Names to Inject to Jython Script.", - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "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.Jython" - }, - "vnf-netconf-device": { - "description": "This is VNF Device with Netconf Capability", - "version": "1.0.0", - "capabilities": { - "netconf": { - "type": "tosca.capabilities.Netconf", - "properties": { - "login-key": { - "required": true, - "type": "string", - "default": "sdnc" - }, - "login-account": { - "required": true, - "type": "string", - "default": "sdnc-tacacs" - }, - "source": { - "required": true, - "type": "string", - "default": "npm" - }, - "target-ip-address": { - "required": true, - "type": "string" - }, - "port-number": { - "required": true, - "type": "integer", - "default": 830 - }, - "connection-time-out": { - "required": false, - "type": "integer", - "default": 30 - } - } - } - }, - "derived_from": "tosca.nodes.Vnf" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json deleted file mode 100644 index 0c9b99252..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/policy_types.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "policy_types": { - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json deleted file mode 100644 index 87d2dc586..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "relationship_types": { - "tosca.relationships.ConnectsTo": { - "description": "Relationship tosca.relationships.ConnectsTo", - "version": "1.0.0", - "derived_from": "tosca.relationships.Root" - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json deleted file mode 100644 index c88712146..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "service-instance-id": { - "name": "service-instance-id", - "tags": "service-instance-id, tosca.datatypes.Root, data_type", - "updated-by": "Singal, Kapil ", - "property": { - "description": "To be provided", - "type": "string" - }, - "sources": { - "input": { - "type": "source-input", - "properties": {} - } - } - }, - "vnf-id": { - "name": "vnf-id", - "tags": "vnf-id", - "updated-by": "Singal, Kapil ", - "property": { - "description": "vnf-id", - "type": "string" - }, - "sources": { - "input": { - "type": "source-input", - "properties": {} - } - } - }, - "vnf_name": { - "name": "vnf_name", - "tags": "vnf_name", - "updated-by": "Singal, Kapil ", - "property": { - "description": "vnf_name", - "type": "string" - }, - "sources": { - "primary-config-data": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "vnf_name": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } - } -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn deleted file mode 100644 index 89ae342f8..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn +++ /dev/null @@ -1,66 +0,0 @@ - - - - - SequenceFlow_0l0dq58 - - - SequenceFlow_1ay0k6p - - - - - - - - - - SequenceFlow_0l0dq58 - SequenceFlow_1ay0k6p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml deleted file mode 100644 index 2f6d2eda8..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml deleted file mode 100644 index eb41b7dfa..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml deleted file mode 100644 index a197877f5..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts deleted file mode 100644 index f1da61407..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* -import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive - -open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() { - - lateinit var resourceAssignment: ResourceAssignment - - override fun getName(): String { - return "resource-assignment-processor-custom-capability" - } - - override fun process(resourceAssignment: ResourceAssignment) { - this.resourceAssignment = resourceAssignment - } - - override fun prepareResponse(): ResourceAssignment { - return resourceAssignment - } - - override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { - TODO("To Implement") - } - -} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts deleted file mode 100644 index 184c49335..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode - -open class SampleKotlinComponent : BlueprintFunctionNode { - - override fun getName(): String { - return "my Name" - } - - override fun prepareRequest(executionRequest: String): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun process(executionRequest: String) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun recover(runtimeException: RuntimeException, executionRequest: String) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun prepareResponse(): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun apply(t: String): String { - return "Successfully Executed Scripts" - } -} diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py deleted file mode 100644 index 4db7c731b..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py +++ /dev/null @@ -1,50 +0,0 @@ -import netconf_constant -from netconfclient import NetconfClient -from java.lang import Exception -from abstract_blueprint_function import AbstractPythonComponentFunction -from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService -from org.onap.ccsdk.apps.controllerblueprints.core.utils import JacksonUtils -from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces import DeviceInfo -from org.onap.ccsdk.apps.controllerblueprints.core.service import BluePrintRuntimeService - - -class DefaultGetNetConfig(AbstractPythonComponentFunction): - def process(self, execution_request): - try: - log = globals()[netconf_constant.SERVICE_LOG] - print(globals()) - #requestId = globals()[netconf_constant.PARAM_REQUEST_ID] - requestId = '1234' - - bluePrintRuntimeService = globals()['bluePrintRuntimeService'] - - capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf") - - log.info("capabilityProperty {}",capabilityProperty) - netconfService = NetconfRpcService() - nc = NetconfClient(log, netconfService) - - nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty)) - runningConfigTemplate = "runningconfig-template" - - runningConfigMessageId = "get-config-" + requestId - - deviceResponse = nc.getConfig(messageId=runningConfigMessageId, - filter=runningConfigTemplate) - - log.info("Get Running Config Response {} ", deviceResponse.responseMessage) - if(deviceResponse !='null') : - status = deviceResponse.status - responseData = "{}" - if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'): - errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage - - except Exception, err: - log.info("Exception in the script {}",err.getMessage()) - status = netconf_constant.STATUS_FAILURE - errorMessage = "Get Running Config Failure ::"+err.getMessage() - - def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None - diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py deleted file mode 100644 index 0a583dc57..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py +++ /dev/null @@ -1,12 +0,0 @@ -from abstract_blueprint_function import AbstractPythonComponentFunction -from blueprint_constants import * - -class SamplePythonComponentNode(AbstractPythonComponentFunction): - - def process(self, execution_request): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None - - def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/__init__.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/python/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta deleted file mode 100644 index 9066e4845..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta +++ /dev/null @@ -1,8 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: Brinda Santh M -Entry-Definitions: Definitions/activation-blueprint.json -Template-Tags: Brinda Santh, activation-blueprint - -Name: Plans/ActivateProcess.bpmn -Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl deleted file mode 100644 index 026c59176..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Templates/baseconfig-template.vtl +++ /dev/null @@ -1 +0,0 @@ -This is Sample Velocity Template \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip b/components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip new file mode 100755 index 000000000..77882ef14 Binary files /dev/null and b/components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip differ 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 new file mode 100644 index 000000000..822cc68b7 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json @@ -0,0 +1,336 @@ +{ + "metadata": { + "template_author": "Brinda Santh Muthuramalingam", + "author-email": "brindasanth@in.ibm.com", + "user-groups": "ADMIN, OPERATION", + "template_name": "baseconfiguration", + "template_version": "1.0.0", + "template_tags": "brinda, tosca" + }, + "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" + } + ], + "topology_template": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "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/CONFIG_ResourceAssignment_1.0.0.xml" + } + } + }, + "activate-process": { + "type": "dg-generic", + "properties": { + "content": { + "get_artifact": [ + "SELF", + "dg-activate-process" + ] + }, + "dependency-node-templates": [ + "activate-jython" + ] + }, + "artifacts": { + "dg-activate-process": { + "type": "artifact-directed-graph", + "file": "Plans/CONFIG_ActivateNetconf_1.0.0.xml" + } + } + }, + "assign-activate-process": { + "type": "dg-generic", + "properties": { + "content": { + "get_artifact": [ + "SELF", + "dg-assign-activate-process" + ] + }, + "dependency-node-templates": [ + "resource-assignment", + "activate-jython" + ] + }, + "artifacts": { + "dg-assign-activate-process": { + "type": "artifact-directed-graph", + "file": "Plans/CONFIG_AssignActivateNetconf_1.0.0.xml" + } + } + }, + "resource-assignment": { + "type": "component-resource-assignment", + "interfaces": { + "ResourceAssignmentComponent": { + "operations": { + "process": { + "inputs": { + "action-name": { + "get_input": "action-name" + }, + "resource-type": "vnf-type", + "request-id": { + "get_input": "request-id" + }, + "resource-id": { + "get_input": "hostname" + }, + "artifact-prefix-names": [ + "baseconfig" + ] + }, + "outputs": { + "resource-assignment-params": { + "get_attribute": [ + "SELF", + "assignment-params" + ] + }, + "status": "success" + } + } + } + } + }, + "artifacts": { + "baseconfig-template": { + "type": "artifact-template-velocity", + "file": "Templates/baseconfig-template.vtl" + }, + "baseconfig-mapping": { + "type": "artifact-mapping-resource", + "file": "Definitions/baseconfig-mapping.json" + } + } + }, + "resource-assignment-py": { + "type": "component-resource-assignment", + "interfaces": { + "ResourceAssignmentComponent": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "action-name": { + "get_input": "action-name" + } + }, + "outputs": { + "resource-assignment-params": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-jython", + "file": "Scripts/python/SamplePythonComponentNode.py" + } + } + }, + "activate-jython": { + "type": "component-jython-executor", + "interfaces": { + "JythonExecutorComponent": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "instance-dependencies": [ + "json-parser-service", + "netconf-rpc-service" + ] + }, + "outputs": { + "response-data": "", + "status": "" + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-jython", + "file": "Scripts/python/SamplePythonComponentNode.py" + } + } + }, + "activate-netconf": { + "type": "component-netconf-executor", + "interfaces": { + "NetconfExecutorComponent": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "instance-dependencies": [ + "json-parser-service", + "netconf-rpc-service" + ] + }, + "outputs": { + "response-data": "", + "status": "" + } + } + } + } + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "sample-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-jython", + "file": "Scripts/python/DefaultGetNetConfig.py" + } + } + }, + "sample-netconf-device": { + "type": "vnf-netconf-device", + "capabilities": { + "netconf": { + "properties": { + "login-key": "sample-key", + "login-account": "sample-account", + "target-ip-address": "localhost", + "port-number": 830, + "connection-time-out": 30 + } + } + } + } + }, + "workflows": { + "resource-assignment": { + "inputs": { + "resource-assignment-properties": { + "required": true, + "type": "dt-resource-assignment-properties" + } + }, + "steps": { + "call-resource-assignment": { + "description": "Resource Assignment Workflow", + "target": "resource-assignment-process", + "activities": [ + { + "call_operation": "CONFIG.ResourceAssignment" + } + ] + } + } + }, + "activate": { + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "steps": { + "activate-process": { + "description": "Netconf Activation Workflow", + "target": "activate-process", + "activities": [ + { + "call_operation": "CONFIG.ActivateProcess" + } + ] + } + } + }, + "assign-activate": { + "inputs": { + "assign-activate-properties": { + "required": true, + "type": "dt-assign-activate-properties" + } + }, + "steps": { + "activate-process": { + "description": "Resource Assign and Netconf Activation Workflow", + "target": "assign-activate-process", + "activities": [ + { + "call_operation": "CONFIG.AssignActivateProcess" + } + ] + } + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/artifact_types.json new file mode 100644 index 000000000..d741d151e --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/artifact_types.json @@ -0,0 +1,45 @@ +{ + "artifact_types": { + "artifact-template-velocity": { + "description": "Velocity Template used for Configuration", + "version": "1.0.0", + "file_ext": [ + "vtl" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-mapping-resource": { + "description": "Velocity Template Resource Mapping File used along with Configuration template", + "version": "1.0.0", + "file_ext": [ + "json" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-script-jython": { + "description": "Jython Script File", + "version": "1.0.0", + "file_ext": [ + "py" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-directed-graph": { + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" + }, + "artifact-component-jar": { + "description": "Component Jar", + "version": "1.0.0", + "file_ext": [ + "jar" + ], + "derived_from": "tosca.artifacts.Implementation" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json new file mode 100644 index 000000000..67d2a914e --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json @@ -0,0 +1,36 @@ +[ + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [ + ] + }, + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "vnf_name", + "input-param": false, + "property": { + "type": "string" + }, + "dictionary-name": "vnf_name", + "dictionary-source": "primary-config-data", + "dependencies": [ + "service-instance-id", + "vnf-id" + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json new file mode 100644 index 000000000..6d771cd68 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/data_types.json @@ -0,0 +1,82 @@ +{ + "data_types": { + "sample-property": { + "description": "This is sample data type", + "version": "1.0.0", + "properties": { + "content": { + "required": false, + "type": "string" + }, + "process-name": { + "required": false, + "type": "string" + }, + "version": { + "required": false, + "type": "string", + "default": "LATEST" + } + }, + "derived_from": "tosca.datatypes.Root" + }, + "dt-resource-assignment-properties": { + "description": "This is Dynamically generated data type for workflow activate", + "version": "1.0.0", + "properties": { + "request-id": { + "required": true, + "type": "string" + }, + "service-instance-id": { + "required": true, + "type": "string" + }, + "vnf-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + }, + "vnf_name": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-assign-activate-properties": { + "description": "This is Dynamically generated data type for workflow assign-activate", + "version": "1.0.0", + "properties": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + } + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..f7970bfbd --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json @@ -0,0 +1,234 @@ +{ + "node_types": { + "dg-generic": { + "description": "This is Generic Directed Graph Type", + "version": "1.0.0", + "properties": { + "content": { + "required": true, + "type": "string" + }, + "dependency-node-templates": { + "required": true, + "description": "Dependent Step Components", + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.DG" + }, + "tosca.nodes.Component": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.DG": { + "description": "This is Directed Graph Node Type", + "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.Vnf" : { + "description" : "This is VNF Node Type", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "tosca.nodes.component.Jython": { + "description": "This is Resource Assignment Jython Component API", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "component-netconf-executor": { + "description": "This is Netconf Transaction Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "vnf-netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "NetconfExecutorComponent": { + "operations": { + "process": { + "inputs": { + "instance-dependencies": { + "description": "Instance Names to Inject to Jython Script.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "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.Jython" + }, + "component-resource-assignment": { + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "attributes": { + "assignment-params": { + "required": true, + "type": "string" + } + }, + "interfaces": { + "ResourceAssignmentComponent": { + "operations": { + "process": { + "inputs": { + "action-name": { + "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", + "required": false, + "type": "string" + }, + "resource-type": { + "required": false, + "type": "string" + }, + "request-id": { + "description": "Request Id used to store the generated configuration, in the database along with the template-name", + "required": true, + "type": "string" + }, + "resource-id": { + "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", + "required": true, + "type": "string" + }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, + "component-jython-executor": { + "description": "This is Jython Execution Component.", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "JythonExecutorComponent": { + "operations": { + "process": { + "inputs": { + "instance-dependencies": { + "required": true, + "description": "Instance Names to Inject to Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "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.Jython" + }, + "vnf-netconf-device": { + "description": "This is VNF Device with Netconf Capability", + "version": "1.0.0", + "capabilities": { + "netconf": { + "type": "tosca.capabilities.Netconf", + "properties": { + "login-key": { + "required": true, + "type": "string", + "default": "sdnc" + }, + "login-account": { + "required": true, + "type": "string", + "default": "sdnc-tacacs" + }, + "source": { + "required": true, + "type": "string", + "default": "npm" + }, + "target-ip-address": { + "required": true, + "type": "string" + }, + "port-number": { + "required": true, + "type": "integer", + "default": 830 + }, + "connection-time-out": { + "required": false, + "type": "integer", + "default": 30 + } + } + } + }, + "derived_from": "tosca.nodes.Vnf" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/policy_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/policy_types.json new file mode 100644 index 000000000..0c9b99252 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/policy_types.json @@ -0,0 +1,4 @@ +{ + "policy_types": { + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/relationship_types.json new file mode 100644 index 000000000..87d2dc586 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/relationship_types.json @@ -0,0 +1,9 @@ +{ + "relationship_types": { + "tosca.relationships.ConnectsTo": { + "description": "Relationship tosca.relationships.ConnectsTo", + "version": "1.0.0", + "derived_from": "tosca.relationships.Root" + } + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..c88712146 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json @@ -0,0 +1,62 @@ +{ + "service-instance-id": { + "name": "service-instance-id", + "tags": "service-instance-id, tosca.datatypes.Root, data_type", + "updated-by": "Singal, Kapil ", + "property": { + "description": "To be provided", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf-id": { + "name": "vnf-id", + "tags": "vnf-id", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf-id", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input", + "properties": {} + } + } + }, + "vnf_name": { + "name": "vnf_name", + "tags": "vnf_name", + "updated-by": "Singal, Kapil ", + "property": { + "description": "vnf_name", + "type": "string" + }, + "sources": { + "primary-config-data": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "path": "/param/0/value", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + "vnf_name": "value" + }, + "key-dependencies": [ + "service-instance-id", + "vnf-id" + ] + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn new file mode 100644 index 000000000..89ae342f8 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn @@ -0,0 +1,66 @@ + + + + + SequenceFlow_0l0dq58 + + + SequenceFlow_1ay0k6p + + + + + + + + + + SequenceFlow_0l0dq58 + SequenceFlow_1ay0k6p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml new file mode 100644 index 000000000..2f6d2eda8 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml new file mode 100644 index 000000000..eb41b7dfa --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml new file mode 100644 index 000000000..a197877f5 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..f1da61407 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive + +open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() { + + lateinit var resourceAssignment: ResourceAssignment + + override fun getName(): String { + return "resource-assignment-processor-custom-capability" + } + + override fun process(resourceAssignment: ResourceAssignment) { + this.resourceAssignment = resourceAssignment + } + + override fun prepareResponse(): ResourceAssignment { + return resourceAssignment + } + + 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/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts new file mode 100644 index 000000000..184c49335 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts @@ -0,0 +1,46 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode + +open class SampleKotlinComponent : BlueprintFunctionNode { + + override fun getName(): String { + return "my Name" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "Successfully Executed Scripts" + } +} diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py new file mode 100644 index 000000000..4db7c731b --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py @@ -0,0 +1,50 @@ +import netconf_constant +from netconfclient import NetconfClient +from java.lang import Exception +from abstract_blueprint_function import AbstractPythonComponentFunction +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService +from org.onap.ccsdk.apps.controllerblueprints.core.utils import JacksonUtils +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces import DeviceInfo +from org.onap.ccsdk.apps.controllerblueprints.core.service import BluePrintRuntimeService + + +class DefaultGetNetConfig(AbstractPythonComponentFunction): + def process(self, execution_request): + try: + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) + #requestId = globals()[netconf_constant.PARAM_REQUEST_ID] + requestId = '1234' + + bluePrintRuntimeService = globals()['bluePrintRuntimeService'] + + capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf") + + log.info("capabilityProperty {}",capabilityProperty) + netconfService = NetconfRpcService() + nc = NetconfClient(log, netconfService) + + nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty)) + runningConfigTemplate = "runningconfig-template" + + runningConfigMessageId = "get-config-" + requestId + + deviceResponse = nc.getConfig(messageId=runningConfigMessageId, + filter=runningConfigTemplate) + + log.info("Get Running Config Response {} ", deviceResponse.responseMessage) + if(deviceResponse !='null') : + status = deviceResponse.status + responseData = "{}" + if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'): + errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage + + except Exception, err: + log.info("Exception in the script {}",err.getMessage()) + status = netconf_constant.STATUS_FAILURE + errorMessage = "Get Running Config Failure ::"+err.getMessage() + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py new file mode 100644 index 000000000..0a583dc57 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py @@ -0,0 +1,12 @@ +from abstract_blueprint_function import AbstractPythonComponentFunction +from blueprint_constants import * + +class SamplePythonComponentNode(AbstractPythonComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..9066e4845 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Brinda Santh M +Entry-Definitions: Definitions/activation-blueprint.json +Template-Tags: Brinda Santh, activation-blueprint + +Name: Plans/ActivateProcess.bpmn +Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/baseconfig-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/baseconfig-template.vtl new file mode 100644 index 000000000..026c59176 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/baseconfig-template.vtl @@ -0,0 +1 @@ +This is Sample Velocity Template \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip b/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip deleted file mode 100755 index 77882ef14..000000000 Binary files a/components/model-catalog/blueprint-model/test-blueprints/CBA_Zip_Test.zip and /dev/null differ -- cgit 1.2.3-korg From 7816ef331a873af0ba96f7478d45badefd135c62 Mon Sep 17 00:00:00 2001 From: "Cherukuri, Venkatanaresh (vn166g)" Date: Mon, 11 Feb 2019 10:36:36 -0500 Subject: Blueprint modeled Netconf capability components Adding Netconf Executor Function module Change-Id: I8b896fef84a465db2b9365d038b611e9fdf793ea Issue-ID: CCSDK-790 Signed-off-by: Cherukuri, Venkatanaresh (vn166g) --- .../baseconfiguration/Scripts/python/DefaultGetNetConfig.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py index 4db7c731b..e2f5655a2 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py @@ -3,9 +3,7 @@ from netconfclient import NetconfClient from java.lang import Exception from abstract_blueprint_function import AbstractPythonComponentFunction from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService -from org.onap.ccsdk.apps.controllerblueprints.core.utils import JacksonUtils -from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces import DeviceInfo -from org.onap.ccsdk.apps.controllerblueprints.core.service import BluePrintRuntimeService + class DefaultGetNetConfig(AbstractPythonComponentFunction): -- cgit 1.2.3-korg From d73ea79d225154e9edfd88901374cf5ed33947d1 Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Mon, 11 Feb 2019 23:35:16 -0500 Subject: Jython execution component and service Change-Id: I2610e73a9c7ba073b5fa9d148dcd6fb5b9ad9ae3 Issue-ID: CCSDK-696 Signed-off-by: Steve Alphonse Siani --- .../Scripts/SampleResourceAssignmentProcessorScript.py | 13 +++++++++++++ .../blueprint-model/test-blueprint/CBA_Zip_Test.zip | Bin 5382 -> 0 bytes .../Scripts/python/SampleRAProcessor.py | 13 +++++++++++++ .../python/ccsdk_blueprints/abstract_ra_processor.py | 12 ++++++++++++ .../python/ccsdk_blueprints/resource_assignment_utils.py | 14 ++++++++++++++ .../ccsdk_blueprints/sample_ra_processor_function.py | 12 ++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py delete mode 100755 components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py create mode 100644 components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py create mode 100644 components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py create mode 100644 components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py new file mode 100644 index 000000000..f9b533090 --- /dev/null +++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py @@ -0,0 +1,13 @@ +from resource_assignment_processor_function import JythonComponentFunction +from blueprint_constants import * + + +class SampleJythonComponentNode(JythonComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip b/components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip deleted file mode 100755 index 77882ef14..000000000 Binary files a/components/model-catalog/blueprint-model/test-blueprint/CBA_Zip_Test.zip and /dev/null differ diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py new file mode 100644 index 000000000..9729f04f2 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py @@ -0,0 +1,13 @@ +from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * + + +class SampleRAProcessor(AbstractRAProcessor): + + def process(self, execution_request): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py new file mode 100644 index 000000000..f7d54ea88 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py @@ -0,0 +1,12 @@ +from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor + + +class AbstractRAProcessor(ResourceAssignmentProcessor): + + def process(self, execution_request): + print "Processing calling.." + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + return None diff --git a/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py b/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py new file mode 100644 index 000000000..53cc5d708 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py @@ -0,0 +1,14 @@ +class ResourceAssignmentUtils: + + + @classmethod + def set_ressource_data_value(cls, ra, runtime_exception, value): + print "Set resource here..." + # TODO + return None + + @staticmethod + def set_ressource_value(ra, runtime_exception, value): + print "Set resource here..." + # TODO + return None \ No newline at end of file diff --git a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py new file mode 100644 index 000000000..8f68bfec0 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py @@ -0,0 +1,12 @@ +from abstract_ra_processor import AbstractRAProcessor + + +class SampleRAProcessorFunction(AbstractRAProcessor): + + def process(self, execution_request): + print "Processing calling.." + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + return None -- cgit 1.2.3-korg From 50b404400a599b826511593218bf98acdf7fa55e Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sat, 9 Feb 2019 18:33:55 -0500 Subject: Multiple fixes & enhancement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rework docker image build - Fix compress function - Fix node type name for source-primary-db Change-Id: Ide38e17036e76047d9f850b714ba0da4add5cd9d Issue-ID: CCSDK-414 Signed-off-by: Alexis de Talhouët --- .../starter-type/node_type/source-db.json | 44 ---------------------- .../starter-type/node_type/source-primary-db.json | 44 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-db.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-db.json b/components/model-catalog/definition-type/starter-type/node_type/source-db.json deleted file mode 100644 index 661a9503b..000000000 --- a/components/model-catalog/definition-type/starter-type/node_type/source-db.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "description": "This is Database Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": true, - "type": "string", - "constraints": [ - { - "valid_values": [ - "SQL", - "PLSQL" - ] - } - ] - }, - "query": { - "required": true, - "type": "string" - }, - "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" -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json b/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json new file mode 100644 index 000000000..661a9503b --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json @@ -0,0 +1,44 @@ +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "query": { + "required": true, + "type": "string" + }, + "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" +} \ No newline at end of file -- cgit 1.2.3-korg From 4d7d6d918a724e9c83692bf8e5c7a491f073d970 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 11 Feb 2019 17:23:48 -0500 Subject: Fixes: manual integration test of CDS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - support to overwrite cba - fix map to json - finish meshing - fix python context not having the bluePrintRuntimeService injected - load all properties in the properties store Issue-ID: CCSDK-414 Change-Id: I6b65201529d0ffd9c3e18023a33e0081236b01de Signed-off-by: Alexis de Talhouët --- .../Definitions/activation-blueprint.json | 10 +-- .../baseconfiguration/Definitions/node_types.json | 6 +- .../node_type/component-jython-executor.json | 2 +- .../node_type/component-resource-assignment.json | 82 ---------------------- .../node_type/component-resource-resolution.json | 82 ++++++++++++++++++++++ 5 files changed, 91 insertions(+), 91 deletions(-) delete mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json 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 822cc68b7..5af64caa7 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 @@ -106,9 +106,9 @@ } }, "resource-assignment": { - "type": "component-resource-assignment", + "type": "component-resource-resolution", "interfaces": { - "ResourceAssignmentComponent": { + "ResourceResolutionComponent": { "operations": { "process": { "inputs": { @@ -151,9 +151,9 @@ } }, "resource-assignment-py": { - "type": "component-resource-assignment", + "type": "component-resource-resolution", "interfaces": { - "ResourceAssignmentComponent": { + "ResourceResolutionComponent": { "operations": { "process": { "implementation": { @@ -182,7 +182,7 @@ "activate-jython": { "type": "component-jython-executor", "interfaces": { - "JythonExecutorComponent": { + "ComponentJythonExecutor": { "operations": { "process": { "implementation": { 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 f7970bfbd..400db435c 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 @@ -91,7 +91,7 @@ }, "derived_from": "tosca.nodes.component.Jython" }, - "component-resource-assignment": { + "component-resource-resolution": { "description": "This is Resource Assignment Component API", "version": "1.0.0", "attributes": { @@ -101,7 +101,7 @@ } }, "interfaces": { - "ResourceAssignmentComponent": { + "ResourceResolutionComponent": { "operations": { "process": { "inputs": { @@ -158,7 +158,7 @@ } }, "interfaces": { - "JythonExecutorComponent": { + "ComponentJythonExecutor": { "operations": { "process": { "inputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json index 4959a9dd1..af8aae12e 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json @@ -7,7 +7,7 @@ } }, "interfaces": { - "JythonExecutorComponent": { + "ComponentJythonExecutor": { "operations": { "process": { "inputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json deleted file mode 100644 index 38fc97d70..000000000 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "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": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "template-version": { - "description": "Service Template Version.", - "required": true, - "type": "string" - }, - "resource-type": { - "description": "Request type.", - "required": true, - "type": "string" - }, - "template-names": { - "description": "Name of the artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "artifact-prefix-names": { - "required": false, - "description": "Template , Resource Assignment Artifact Prefix names", - "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": true, - "type": "string" - }, - "action-name": { - "description": "Action Name of the process", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json new file mode 100644 index 000000000..d01660efc --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json @@ -0,0 +1,82 @@ +{ + "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": { + "template-name": { + "description": "Service Template Name.", + "required": true, + "type": "string" + }, + "template-version": { + "description": "Service Template Version.", + "required": true, + "type": "string" + }, + "resource-type": { + "description": "Request type.", + "required": true, + "type": "string" + }, + "template-names": { + "description": "Name of the artifact Node Templates, to get the template Content.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "request-id": { + "description": "Request Id, Unique Id for the request.", + "required": false, + "type": "string" + }, + "resource-id": { + "description": "Resource Id.", + "required": false, + "type": "string" + }, + "action-name": { + "description": "Action Name of the process", + "required": false, + "type": "string" + } + }, + "outputs": { + "resource-assignment-params": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" +} \ No newline at end of file -- cgit 1.2.3-korg From f7c657993d50ed855a1ac359b5dd325960a6051b Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Tue, 12 Feb 2019 15:26:19 -0500 Subject: Add netconf script component function Change-Id: I094025fba5626bae0b4b13320f1cbbb76cda3bfd Issue-ID: CCSDK-790 Signed-off-by: Muthuramalingam, Brinda Santh --- .../Definitions/activation-blueprint.json | 6 ++---- .../Scripts/python/DefaultGetNetConfig.py | 19 ++++++------------- .../scripts/python/ccsdk_netconf/netconfclient.py | 10 +++++++--- 3 files changed, 15 insertions(+), 20 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 5af64caa7..637b589f6 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 @@ -190,8 +190,7 @@ }, "inputs": { "instance-dependencies": [ - "json-parser-service", - "netconf-rpc-service" + "json-parser-service" ] }, "outputs": { @@ -220,8 +219,7 @@ }, "inputs": { "instance-dependencies": [ - "json-parser-service", - "netconf-rpc-service" + "json-parser-service" ] }, "outputs": { diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py index e2f5655a2..c966b1a4b 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py @@ -1,28 +1,21 @@ import netconf_constant from netconfclient import NetconfClient from java.lang import Exception -from abstract_blueprint_function import AbstractPythonComponentFunction -from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfComponentFunction +class DefaultGetNetConfig(NetconfComponentFunction): - -class DefaultGetNetConfig(AbstractPythonComponentFunction): def process(self, execution_request): try: log = globals()[netconf_constant.SERVICE_LOG] print(globals()) #requestId = globals()[netconf_constant.PARAM_REQUEST_ID] requestId = '1234' + nc = NetconfClient(log, self) - bluePrintRuntimeService = globals()['bluePrintRuntimeService'] - - capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf") - - log.info("capabilityProperty {}",capabilityProperty) - netconfService = NetconfRpcService() - nc = NetconfClient(log, netconfService) + # Create RPC Serivice + nc.createRPCServiceFromRequirement("netconf-connection") - nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty)) runningConfigTemplate = "runningconfig-template" runningConfigMessageId = "get-config-" + requestId @@ -38,7 +31,7 @@ class DefaultGetNetConfig(AbstractPythonComponentFunction): errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage except Exception, err: - log.info("Exception in the script {}",err.getMessage()) + log.error("Exception in the script {}",err.getMessage()) status = netconf_constant.STATUS_FAILURE errorMessage = "Get Running Config Failure ::"+err.getMessage() diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py index 448e03dc1..421e50098 100644 --- a/components/scripts/python/ccsdk_netconf/netconfclient.py +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -4,15 +4,19 @@ from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_DEFAULT_OPERATION_REP class NetconfClient: - def __init__(self, log, nc): + def __init__(self, log, componentFunction): self.log = log - self.nc = nc + self.componentFunction = componentFunction + self.nc = None + + def createRPCServiceFromRequirement(self, requirementName): + self.nc = self.componentFunction.netconfRpcClientService(requirementName) def disconnect(self): self.nc.disconnect() return - def connect(self,deviceInfo): + def connect(self, deviceInfo): self.nc.connect(deviceInfo) return -- cgit 1.2.3-korg From bc67e43da12a2b341a15087adfae6e613990b5a2 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Tue, 12 Feb 2019 15:53:39 -0500 Subject: Create restconf component function module Change-Id: I04c29bfc981b677d81da73441228215ce4868833 Issue-ID: CCSDK-1060 Signed-off-by: Muthuramalingam, Brinda Santh --- .../node_type/component-restconf-executor.json | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json new file mode 100644 index 000000000..884be5dc6 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json @@ -0,0 +1,40 @@ +{ + "description": "This is Netconf Transaction Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "ComponentRestconfExecutor": { + "operations": { + "process": { + "inputs": { + "instance-dependencies": { + "required": true, + "description": "Instance Names to Inject to Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "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" +} \ No newline at end of file -- cgit 1.2.3-korg From b33481f0d4251bb9d0ef8536c58e4a2d5b4ffe19 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Tue, 12 Feb 2019 19:16:47 -0500 Subject: Add Sub Attribute parsing capabilit Change-Id: Ie353f8e5b86f7472a4790c32705f4b8c3d5e5826 Issue-ID: CCSDK-1061 Signed-off-by: Muthuramalingam, Brinda Santh --- .../baseconfiguration/Definitions/activation-blueprint.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 637b589f6..84c78c62c 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 @@ -251,7 +251,14 @@ "properties": { "login-key": "sample-key", "login-account": "sample-account", - "target-ip-address": "localhost", + "target-ip-address": { + "get_attribute": [ + "resource-assignment", + "", + "assignment-params", + "$.ipAddress" + ] + }, "port-number": 830, "connection-time-out": 30 } -- cgit 1.2.3-korg From 1f53e61c6f5af7fdcd6be97ba3aff4d84694dc05 Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Wed, 13 Feb 2019 15:45:50 -0500 Subject: Python library for Jython execution Change-Id: Iee2701b4dade7207950f17c92ea1265c361cf803 Issue-ID: CCSDK-696 Signed-off-by: Steve Alphonse Siani --- .../SampleResourceAssignmentProcessorScript.py | 13 -- .../Definitions/resources_definition_types.json | 8 + .../Scripts/python/SamplePythonComponentNode.py | 10 +- .../Scripts/python/SampleRAProcessor.py | 20 ++- .../Definitions/activation-blueprint.json | 128 ++++++++++++++ .../Definitions/artifact_types.json | 28 ++++ .../Definitions/baseconfig-mapping.json | 23 +++ .../capability_python/Definitions/data_types.json | 17 ++ .../capability_python/Definitions/node_types.json | 183 +++++++++++++++++++++ .../Definitions/policy_types.json | 3 + .../Definitions/relationship_types.json | 3 + .../Definitions/resources_definition_types.json | 51 ++++++ .../Plans/CONFIG_AssignActivateNetconf_1.0.0.xml | 42 +++++ .../kotlin/ResourceAssignmentProcessor.cba.kts | 44 +++++ .../Scripts/kotlin/ScriptComponent.cba.kts | 46 ++++++ .../Scripts/python/DefaultGetNetConfig.py | 48 ++++++ .../Scripts/python/SamplePythonComponentNode.py | 18 ++ .../Scripts/python/SampleRAProcessor.py | 29 ++++ .../capability_python/TOSCA-Metadata/TOSCA.meta | 8 + .../Templates/baseconfig-template.vtl | 4 + .../abstract_blueprint_function.py | 8 +- .../ccsdk_blueprints/abstract_ra_processor.py | 43 ++++- .../python/ccsdk_blueprints/blueprint_constants.py | 3 + .../ccsdk_blueprints/blueprint_runtime_service.py | 8 + .../ccsdk_blueprints/resource_assignment_utils.py | 14 -- .../ccsdk_blueprints/sample_blueprint_component.py | 10 +- .../sample_ra_processor_function.py | 10 +- 27 files changed, 782 insertions(+), 40 deletions(-) delete mode 100644 components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/artifact_types.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/baseconfig-mapping.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/data_types.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/node_types.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/policy_types.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/relationship_types.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/resources_definition_types.json create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ScriptComponent.cba.kts create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/DefaultGetNetConfig.py create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SamplePythonComponentNode.py create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta create mode 100755 components/model-catalog/blueprint-model/test-blueprint/capability_python/Templates/baseconfig-template.vtl delete mode 100644 components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py deleted file mode 100644 index f9b533090..000000000 --- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Scripts/SampleResourceAssignmentProcessorScript.py +++ /dev/null @@ -1,13 +0,0 @@ -from resource_assignment_processor_function import JythonComponentFunction -from blueprint_constants import * - - -class SampleJythonComponentNode(JythonComponentFunction): - - def process(self, execution_request): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None - - def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None 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 c88712146..d2d32e81e 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 @@ -11,6 +11,14 @@ "input": { "type": "source-input", "properties": {} + }, + "capability": { + "type": "source-capability", + "properties": { + "type": "JYTHON-COMPONENT", + "instance-name": "SampleRAProcessor", + "instance-dependencies": [] + } } } }, diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py index 0a583dc57..890481219 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py @@ -1,12 +1,18 @@ from abstract_blueprint_function import AbstractPythonComponentFunction from blueprint_constants import * + class SamplePythonComponentNode(AbstractPythonComponentFunction): + def __init__(self): + AbstractPythonComponentFunction.__init__(self) + def process(self, execution_request): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + AbstractPythonComponentFunction.process(self, execution_request) + print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + AbstractPythonComponentFunction.recover(self, runtime_exception, execution_request) + print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py index 9729f04f2..30b9ff951 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py @@ -4,10 +4,26 @@ from blueprint_constants import * class SampleRAProcessor(AbstractRAProcessor): + def __init__(self): + AbstractRAProcessor.__init__(self) + def process(self, execution_request): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + + AbstractRAProcessor.process(self, execution_request) + print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH + if self.ra_valid is True: + value = self.resolve_values_script(execution_request, self.value_to_resolve) + self.set_resource_data_value(execution_request, value) + else: + raise BluePrintProcessorException("Error on resource assignment. Message = " + self.error_message) return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + AbstractRAProcessor.recover(self, runtime_exception, execution_request) + print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH return None + + def resolve_values_script(self, execution_request, value_to_resolve): + # TODO : DO business logic here + print "Resolve value for " + value_to_resolve + " here..." + return "test_python" diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json new file mode 100755 index 000000000..168732c1d --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json @@ -0,0 +1,128 @@ +{ + "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" : "capability_python", + "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" + } ], + "topology_template" : { + "inputs" : { + "request-id" : { + "required" : true, + "type" : "string" + }, + "action-name" : { + "required" : true, + "type" : "string" + } + }, + "workflows" : { + "assign-activate" : { + "steps" : { + "activate-process" : { + "description" : "Resource Assign and Netconf Activation Workflow", + "target" : "assign-activate-process", + "activities" : [ { + "call_operation" : "" + } ] + } + }, + "inputs" : { + "assign-activate-properties" : { + "description" : "Dynamic PropertyDefinition for workflow(assign-activate).", + "required" : true, + "type" : "dt-assign-activate-properties" + } + } + } + }, + "node_templates" : { + "assign-activate-process" : { + "type" : "dg-generic", + "properties" : { + "content" : { + "get_artifact" : [ "SELF", "dg-assign-activate-process" ] + }, + "dependency-node-templates" : [ "resource-assignment", "activate-jython" ] + }, + "artifacts" : { + "dg-assign-activate-process" : { + "type" : "artifact-directed-graph", + "file" : "Plans/CONFIG_AssignActivateNetconf_1.0.0.xml" + } + } + }, + "resource-assignment" : { + "type" : "component-resource-resolution", + "interfaces" : { + "ResourceResolutionComponent" : { + "operations" : { + "process" : { + "inputs" : { + "artifact-prefix-names" : [ "baseconfig" ] + }, + "outputs" : { + "resource-assignment-params" : { + "get_attribute" : [ "SELF", "assignment-params" ] + }, + "status" : "success" + } + } + } + } + }, + "artifacts" : { + "baseconfig-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/baseconfig-template.vtl" + }, + "baseconfig-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Definitions/baseconfig-mapping.json" + } + } + }, + "activate-jython" : { + "type" : "component-jython-executor", + "interfaces" : { + "ComponentJythonExecutor" : { + "operations" : { + "process" : { + "implementation" : { + "primary" : "component-script" + }, + "inputs" : { + "instance-dependencies" : [ ] + }, + "outputs" : { + "response-data" : "", + "status" : "" + } + } + } + } + }, + "artifacts" : { + "component-script" : { + "type" : "artifact-script-jython", + "file" : "Scripts/SamplePythonComponentNode.py" + } + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/artifact_types.json new file mode 100755 index 000000000..aa5295e44 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/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/test-blueprint/capability_python/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/baseconfig-mapping.json new file mode 100755 index 000000000..de6c24116 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/baseconfig-mapping.json @@ -0,0 +1,23 @@ +[ + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "capability", + "dependencies": [ + ] + }, + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/data_types.json new file mode 100755 index 000000000..98a8e4b79 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/data_types.json @@ -0,0 +1,17 @@ +{ + "data_types" : { + "dt-assign-activate-properties" : { + "description" : "Dynamic DataType definition for workflow(assign-activate).", + "version" : "1.0.0", + "properties" : { + "vnf-id" : { + "type" : "string" + }, + "service-instance-id" : { + "type" : "string" + } + }, + "derived_from" : "tosca.datatypes.Dynamic" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/node_types.json new file mode 100755 index 000000000..b40c8cb34 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/node_types.json @@ -0,0 +1,183 @@ +{ + "node_types" : { + "component-jython-executor" : { + "description" : "This is Jython Execution Component.", + "version" : "1.0.0", + "capabilities" : { + "component-node" : { + "type" : "tosca.capabilities.Node" + } + }, + "interfaces" : { + "ComponentJythonExecutor" : { + "operations" : { + "process" : { + "inputs" : { + "instance-dependencies" : { + "description" : "Instance Names to Inject to Jython Script.", + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "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.Jython" + }, + "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" : { + "template-name" : { + "description" : "Service Template Name.", + "required" : true, + "type" : "string" + }, + "template-version" : { + "description" : "Service Template Version.", + "required" : true, + "type" : "string" + }, + "resource-type" : { + "description" : "Request type.", + "required" : true, + "type" : "string" + }, + "template-names" : { + "description" : "Name of the artifact Node Templates, to get the template Content.", + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + }, + "artifact-prefix-names" : { + "description" : "Template , Resource Assignment Artifact Prefix names", + "required" : false, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + }, + "request-id" : { + "description" : "Request Id, Unique Id for the request.", + "required" : false, + "type" : "string" + }, + "resource-id" : { + "description" : "Resource Id.", + "required" : false, + "type" : "string" + }, + "action-name" : { + "description" : "Action Name of the process", + "required" : false, + "type" : "string" + } + }, + "outputs" : { + "resource-assignment-params" : { + "required" : true, + "type" : "string" + }, + "status" : { + "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.DG" + }, + "source-input" : { + "description" : "This is Input Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "key" : { + "required" : false, + "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.DG" : { + "description" : "This is Directed Graph Node Type", + "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.component.Jython" : { + "description" : "This is Jython Component", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/policy_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/policy_types.json new file mode 100755 index 000000000..1e44cc70a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/policy_types.json @@ -0,0 +1,3 @@ +{ + "policy_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/relationship_types.json new file mode 100755 index 000000000..4ddd7a57c --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/relationship_types.json @@ -0,0 +1,3 @@ +{ + "relationship_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/resources_definition_types.json new file mode 100755 index 000000000..d2c470fe8 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/resources_definition_types.json @@ -0,0 +1,51 @@ +{ + "service-instance-id" : { + "tags" : "service-instance-id, tosca.datatypes.Root, data_type", + "name" : "service-instance-id", + "property" : { + "description" : "To be provided", + "type" : "string" + }, + "updated-by" : "Singal, Kapil ", + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + }, + "primary-db": { + "type": "source-primary-db", + "properties": { + "query": "SELECT artifact_name FROM BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", + "input-key-mapping": { + }, + "output-key-mapping": { + "service-instance-id": "artifact_name" + } + } + }, + "capability": { + "type": "source-capability", + "properties": { + "type": "JYTHON-COMPONENT", + "instance-name": "SampleRAProcessor", + "instance-dependencies": [] + } + } + } + }, + "vnf-id" : { + "tags" : "vnf-id", + "name" : "vnf-id", + "property" : { + "description" : "vnf-id", + "type" : "string" + }, + "updated-by" : "Singal, Kapil ", + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml new file mode 100755 index 000000000..eb41b7dfa --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts new file mode 100755 index 000000000..f1da61407 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts @@ -0,0 +1,44 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.* +import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive + +open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() { + + lateinit var resourceAssignment: ResourceAssignment + + override fun getName(): String { + return "resource-assignment-processor-custom-capability" + } + + override fun process(resourceAssignment: ResourceAssignment) { + this.resourceAssignment = resourceAssignment + } + + override fun prepareResponse(): ResourceAssignment { + return resourceAssignment + } + + 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_python/Scripts/kotlin/ScriptComponent.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ScriptComponent.cba.kts new file mode 100755 index 000000000..184c49335 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/kotlin/ScriptComponent.cba.kts @@ -0,0 +1,46 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode + +open class SampleKotlinComponent : BlueprintFunctionNode { + + override fun getName(): String { + return "my Name" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "Successfully Executed Scripts" + } +} diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/DefaultGetNetConfig.py new file mode 100755 index 000000000..e2f5655a2 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/DefaultGetNetConfig.py @@ -0,0 +1,48 @@ +import netconf_constant +from netconfclient import NetconfClient +from java.lang import Exception +from abstract_blueprint_function import AbstractPythonComponentFunction +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService + + + +class DefaultGetNetConfig(AbstractPythonComponentFunction): + def process(self, execution_request): + try: + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) + #requestId = globals()[netconf_constant.PARAM_REQUEST_ID] + requestId = '1234' + + bluePrintRuntimeService = globals()['bluePrintRuntimeService'] + + capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf") + + log.info("capabilityProperty {}",capabilityProperty) + netconfService = NetconfRpcService() + nc = NetconfClient(log, netconfService) + + nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty)) + runningConfigTemplate = "runningconfig-template" + + runningConfigMessageId = "get-config-" + requestId + + deviceResponse = nc.getConfig(messageId=runningConfigMessageId, + filter=runningConfigTemplate) + + log.info("Get Running Config Response {} ", deviceResponse.responseMessage) + if(deviceResponse !='null') : + status = deviceResponse.status + responseData = "{}" + if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'): + errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage + + except Exception, err: + log.info("Exception in the script {}",err.getMessage()) + status = netconf_constant.STATUS_FAILURE + errorMessage = "Get Running Config Failure ::"+err.getMessage() + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SamplePythonComponentNode.py new file mode 100755 index 000000000..890481219 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SamplePythonComponentNode.py @@ -0,0 +1,18 @@ +from abstract_blueprint_function import AbstractPythonComponentFunction +from blueprint_constants import * + + +class SamplePythonComponentNode(AbstractPythonComponentFunction): + + def __init__(self): + AbstractPythonComponentFunction.__init__(self) + + def process(self, execution_request): + AbstractPythonComponentFunction.process(self, execution_request) + print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def recover(self, runtime_exception, execution_request): + AbstractPythonComponentFunction.recover(self, runtime_exception, execution_request) + print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py new file mode 100755 index 000000000..30b9ff951 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py @@ -0,0 +1,29 @@ +from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * + + +class SampleRAProcessor(AbstractRAProcessor): + + def __init__(self): + AbstractRAProcessor.__init__(self) + + def process(self, execution_request): + + AbstractRAProcessor.process(self, execution_request) + print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH + if self.ra_valid is True: + value = self.resolve_values_script(execution_request, self.value_to_resolve) + self.set_resource_data_value(execution_request, value) + else: + raise BluePrintProcessorException("Error on resource assignment. Message = " + self.error_message) + return None + + def recover(self, runtime_exception, execution_request): + AbstractRAProcessor.recover(self, runtime_exception, execution_request) + print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH + return None + + def resolve_values_script(self, execution_request, value_to_resolve): + # TODO : DO business logic here + print "Resolve value for " + value_to_resolve + " here..." + return "test_python" diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta new file mode 100755 index 000000000..9066e4845 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Brinda Santh M +Entry-Definitions: Definitions/activation-blueprint.json +Template-Tags: Brinda Santh, activation-blueprint + +Name: Plans/ActivateProcess.bpmn +Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Templates/baseconfig-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Templates/baseconfig-template.vtl new file mode 100755 index 000000000..9cbaec11b --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Templates/baseconfig-template.vtl @@ -0,0 +1,4 @@ +{ + "service-instance-id": "$service-instance-id", + "vnf-id": "$vnf-id" +} \ No newline at end of file diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py index 0ddab16e7..1ffa75d4b 100644 --- a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py +++ b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py @@ -1,11 +1,15 @@ from org.onap.ccsdk.apps.blueprintsprocessor.services.execution import AbstractComponentFunction + class AbstractPythonComponentFunction(AbstractComponentFunction): + def __init__(self): + AbstractComponentFunction.__init__(self) + def process(self, execution_request): - print "Processing calling.." + print "Processing calling from parent..." return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + print "Recovering calling from parent..." return None diff --git a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py index f7d54ea88..2cacaf526 100644 --- a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py +++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py @@ -1,12 +1,49 @@ from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor +from blueprint_constants import * +from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import ResourceAssignmentUtils +from org.onap.ccsdk.apps.controllerblueprints.core import BluePrintProcessorException +from java.lang import Exception class AbstractRAProcessor(ResourceAssignmentProcessor): + def __init__(self): + ResourceAssignmentProcessor.__init__(self) + self.status = PROPERTY_BLUEPRINT_STATUS_SUCCESS + self.error_message = None + self.ra_valid = False + self.value_to_resolve = None + def process(self, execution_request): - print "Processing calling.." - return None + print "Processing calling from parent..." + try: + self.ra_valid = self.validate(execution_request) + self.value_to_resolve = execution_request.name + except Exception, e: + self.status = PROPERTY_BLUEPRINT_STATUS_FAILURE + self.error_message = "Get Running python scripting Failure :" + e.getMessage() def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + print "Recovering calling from parent.." + return None + + def set_resource_data_value(self, execution_request, value): + try: + if value is not None: + ResourceAssignmentUtils.Companion.setResourceDataValue(execution_request, self.raRuntimeService, value) + else: + ResourceAssignmentUtils.Companion.setFailedResourceDataValue(execution_request, "Fail to resole value") + except BluePrintProcessorException, err: + raise BluePrintProcessorException("Error on resource assignment. Message = " + err.message) + return None + + @staticmethod + def validate(ra): + if ra.name is None or ra.name is None: + raise Exception("Failed getting value for template key (" + ra.name + ") and " + + "dictionary key (" + ra.dictionaryName + + ") of type (" + ra.type + ")") + else: + pass + return True diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py index 2ec95f312..50246773f 100644 --- a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py +++ b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py @@ -6,6 +6,9 @@ PROPERTY_BLUEPRINT_INPUTS_DATA= "blueprint-inputs-data" PROPERTY_BLUEPRINT_CONTEXT= "blueprint-context" PROPERTY_BLUEPRINT_NAME= "template_name" PROPERTY_BLUEPRINT_VERSION= "template_version" +PROPERTY_BLUEPRINT_USER_SYSTEM= "System" +PROPERTY_BLUEPRINT_STATUS_SUCCESS= "success" +PROPERTY_BLUEPRINT_STATUS_FAILURE= "failure" METADATA_USER_GROUPS = "user-groups" METADATA_TEMPLATE_NAME = "template_name" diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py index 022b47244..7c7beff7f 100644 --- a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py +++ b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py @@ -11,3 +11,11 @@ class BluePrintRuntimeService: def setNodeTemplatePropertyValue(self, nodeTemplateName, propertyName, value): return self.bps.setNodeTemplatePropertyValue(nodeTemplateName, propertyName, value) + + def put_resolution_store(self, ra_name, value): + self.bps.putResolutionStore(ra_name, value) + return None + + def put_dictionary_store(self, ra_dictionary_name, value): + self.bps.putResolutionStore(ra_dictionary_name, value) + return None diff --git a/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py b/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py deleted file mode 100644 index 53cc5d708..000000000 --- a/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py +++ /dev/null @@ -1,14 +0,0 @@ -class ResourceAssignmentUtils: - - - @classmethod - def set_ressource_data_value(cls, ra, runtime_exception, value): - print "Set resource here..." - # TODO - return None - - @staticmethod - def set_ressource_value(ra, runtime_exception, value): - print "Set resource here..." - # TODO - return None \ No newline at end of file diff --git a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py index 62665dc8f..a1e6c5d3b 100644 --- a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py +++ b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py @@ -1,12 +1,18 @@ from abstract_blueprint_function import AbstractPythonComponentFunction from blueprint_constants import * + class SampleBlueprintComponent(AbstractPythonComponentFunction): + def __init__(self): + AbstractPythonComponentFunction.__init__(self) + def process(self, execution_request): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + super(SamplePythonComponentNode, self).process(execution_request) + print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + super(SamplePythonComponentNode, self).recover(runtime_exception, execution_request) + print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH return None diff --git a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py index 8f68bfec0..6ec5d82ab 100644 --- a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py +++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py @@ -1,12 +1,18 @@ from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * class SampleRAProcessorFunction(AbstractRAProcessor): + def __init__(self): + AbstractRAProcessor.__init__(self) + def process(self, execution_request): - print "Processing calling.." + AbstractRAProcessor.process(self, execution_request) + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + AbstractRAProcessor.recover(self, runtime_exception, execution_request) + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None -- cgit 1.2.3-korg From 148dd1c3c3d394791817246bd973104142fe93d5 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 15 Feb 2019 13:58:24 -0500 Subject: Fix sonar build Sonar build on ccsdk/apps is failing because one of the submodules (components/model-catatlog/proto-definition) does not have the standard maven src/main and src/test directories. Adding these directories fixes sonar build (they need to contain a file - in this case a README - otherwise git will not add the empty directory) Change-Id: Ia74254b58e5b006bd72c35cd6ce872b88de35016 Issue-ID: CCSDK-1081 Signed-off-by: Timoney, Dan (dt5972) --- components/model-catalog/proto-definition/src/main/README.md | 1 + components/model-catalog/proto-definition/src/test/README.md | 1 + 2 files changed, 2 insertions(+) create mode 100644 components/model-catalog/proto-definition/src/main/README.md create mode 100644 components/model-catalog/proto-definition/src/test/README.md diff --git a/components/model-catalog/proto-definition/src/main/README.md b/components/model-catalog/proto-definition/src/main/README.md new file mode 100644 index 000000000..f63edde3f --- /dev/null +++ b/components/model-catalog/proto-definition/src/main/README.md @@ -0,0 +1 @@ +Standard maven directory for source diff --git a/components/model-catalog/proto-definition/src/test/README.md b/components/model-catalog/proto-definition/src/test/README.md new file mode 100644 index 000000000..4701e06b7 --- /dev/null +++ b/components/model-catalog/proto-definition/src/test/README.md @@ -0,0 +1 @@ +Standard maven directory for unit test cases -- cgit 1.2.3-korg From 3daf7d0156076f868ae566f4503135757a4afd4d Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 12 Feb 2019 23:05:01 -0500 Subject: Rework netconf-executor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rework connection logic - rework rpc service - rework netconf session handling - rework netconf device communicator - rework python netconf bindings - rework python netconf client - add python script showcasing netconf functions Change-Id: Ibb9bf811e7d96e993aa866371d56c172de83be2c Issue-ID: CCSDK-790:x Signed-off-by: Alexis de Talhouët --- .../Definitions/activation-blueprint.json | 4 +- .../baseconfiguration/Definitions/node_types.json | 2 +- .../Scripts/python/DefaultGetNetConfig.py | 41 ------- .../Scripts/python/NetconfRpcExample.py | 52 +++++++++ .../node_type/component-netconf-executor.json | 2 +- .../scripts/python/ccsdk_netconf/constant.py | 15 --- .../scripts/python/ccsdk_netconf/netconfclient.py | 126 ++++++++++++--------- 7 files changed, 126 insertions(+), 116 deletions(-) delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py delete mode 100644 components/scripts/python/ccsdk_netconf/constant.py 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 84c78c62c..07c988b19 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 @@ -211,7 +211,7 @@ "activate-netconf": { "type": "component-netconf-executor", "interfaces": { - "NetconfExecutorComponent": { + "ComponentNetconfExecutor": { "operations": { "process": { "implementation": { @@ -240,7 +240,7 @@ "artifacts": { "component-script": { "type": "artifact-script-jython", - "file": "Scripts/python/DefaultGetNetConfig.py" + "file": "Scripts/python/NetconfRpcExample.py" } } }, 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 400db435c..527307048 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 @@ -60,7 +60,7 @@ } }, "interfaces": { - "NetconfExecutorComponent": { + "ComponentNetconfExecutor": { "operations": { "process": { "inputs": { diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py deleted file mode 100644 index c966b1a4b..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py +++ /dev/null @@ -1,41 +0,0 @@ -import netconf_constant -from netconfclient import NetconfClient -from java.lang import Exception -from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfComponentFunction - -class DefaultGetNetConfig(NetconfComponentFunction): - - def process(self, execution_request): - try: - log = globals()[netconf_constant.SERVICE_LOG] - print(globals()) - #requestId = globals()[netconf_constant.PARAM_REQUEST_ID] - requestId = '1234' - nc = NetconfClient(log, self) - - # Create RPC Serivice - nc.createRPCServiceFromRequirement("netconf-connection") - - runningConfigTemplate = "runningconfig-template" - - runningConfigMessageId = "get-config-" + requestId - - deviceResponse = nc.getConfig(messageId=runningConfigMessageId, - filter=runningConfigTemplate) - - log.info("Get Running Config Response {} ", deviceResponse.responseMessage) - if(deviceResponse !='null') : - status = deviceResponse.status - responseData = "{}" - if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'): - errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage - - except Exception, err: - log.error("Exception in the script {}",err.getMessage()) - status = netconf_constant.STATUS_FAILURE - errorMessage = "Get Running Config Failure ::"+err.getMessage() - - def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH - return None - diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py new file mode 100644 index 000000000..acdb94aa1 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py @@ -0,0 +1,52 @@ +# Copyright (c) 2019 Bell Canada. +# +# 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 netconf_constant +from java.lang import Exception as JavaException +from netconfclient import NetconfClient +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \ + NetconfComponentFunction + + +class NetconfRpcExample(NetconfComponentFunction): + + def process(self, execution_request): + try: + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) + nc = NetconfClient(log, self, "netconf-connection") + nc.connect() + + payload = "DEMO" + + response = nc.lock(message_id="lock-123") + if not response.isSuccess(): + log.error(response.errorMessage) + + # nc.edit_config(message_id="edit-config-1", message_content=payload,edit_default_peration="none") + # nc.validate(message_id="validate-123") + # nc.discard_change(message_id="discard-123") + # nc.validate(message_id="validate-123") + # nc.commit(message_id="commit-123") + # nc.unlock(message_id="unlock-123") + # 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 "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index b8ac762e5..9565f6611 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -14,7 +14,7 @@ } }, "interfaces": { - "NetconfExecutorComponent": { + "ComponentNetconfExecutor": { "operations": { "process": { "inputs": { diff --git a/components/scripts/python/ccsdk_netconf/constant.py b/components/scripts/python/ccsdk_netconf/constant.py deleted file mode 100644 index 534ca9e13..000000000 --- a/components/scripts/python/ccsdk_netconf/constant.py +++ /dev/null @@ -1,15 +0,0 @@ -SERVICE_LOG = "log" -SERVICE_NETCONF = "netconfService" -SERVICE_MESSAGE = "messageService" - -PARAM_REQUEST_ID = "requestId" -PARAM_ACTION = "action" - -STATUS_SUCCESS = "success" -STATUS_FAILURE = "failure" - -CONFIG_TARGET_RUNNING = "running" -CONFIG_TARGET_CANDIDATE = "candidate" -CONFIG_DEFAULT_OPERATION_MERGE = "merge" -CONFIG_DEFAULT_OPERATION_REPLACE = "replace" -CONFIG_DEFAULT_OPERATION_NONE = "none" diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py index 421e50098..cdaf84092 100644 --- a/components/scripts/python/ccsdk_netconf/netconfclient.py +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -1,60 +1,74 @@ -from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_DEFAULT_OPERATION_REPLACE - +from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \ + CONFIG_DEFAULT_OPERATION_REPLACE class NetconfClient: - def __init__(self, log, componentFunction): - self.log = log - self.componentFunction = componentFunction - self.nc = None - - def createRPCServiceFromRequirement(self, requirementName): - self.nc = self.componentFunction.netconfRpcClientService(requirementName) - - def disconnect(self): - self.nc.disconnect() - return - - def connect(self, deviceInfo): - self.nc.connect(deviceInfo) - return - - def lock(self, messageId, configTarget, messageTimeout=30): - deviceResponse = self.nc.lock(messageId, configTarget, messageTimeout) - return deviceResponse - - def getConfig(self, messageId, filter, configTarget=CONFIG_TARGET_RUNNING, messageTimeout=30): - self.log.info("in the ncclient getConfig {}",messageId) - self.log.info("in the ncclient getConfig {}",filter) - deviceResponse = self.nc.getConfig(messageId, filter, configTarget, messageTimeout) - return deviceResponse - - def editConfig(self, messageId, messageContent, reConnect=False, wait=0, lock=False, - configTarget=CONFIG_TARGET_RUNNING, editDefaultOperation=CONFIG_DEFAULT_OPERATION_REPLACE, - deleteConfig= False, validate= False, commit=False, discardChanges =True, unlock=False, - preRestartWait=0, postRestartWait=0, messageTimeout=30): - deviceResponse = self.nc.editConfig(messageId, messageContent, reConnect, wait, lock, configTarget, - editDefaultOperation, deleteConfig, validate, commit, discardChanges, unlock, - preRestartWait, postRestartWait, messageTimeout) - return deviceResponse - - def commit(self, messageId, message, discardChanges =True, messageTimeout=30): - deviceResponse = self.nc.commit(messageId, message, discardChanges, messageTimeout) - return deviceResponse - - def unLock(self, messageId, configTarget, messageTimeout=30): - deviceResponse = self.nc.unLock(messageId, configTarget, messageTimeout) - return deviceResponse - - def discardChanges(self, messageId, messageTimeout=30): - deviceResponse = self.nc.discardChanges(messageId, messageTimeout) - return deviceResponse - - def close(self, messageId, force=False, messageTimeout=30): - deviceResponse = self.nc.close(messageId, force, messageTimeout) - return deviceResponse - - def rpc(self, request, messageId, messageTimeout=30): - deviceResponse = self.nc.rpc(request, messageId, messageTimeout) - return deviceResponse + def __init__(self, log, component_function, requirement_name): + self.log = log + self.component_function = component_function + netconf_device = self.component_function.initializeNetconfConnection( + requirement_name) + self.netconf_rpc_client = netconf_device.netconfRpcService + self.netconf_session = netconf_device.netconfSession + + def disconnect(self): + self.netconf_session.disconnect() + return + + def connect(self): + self.netconf_session.connect() + return + + def lock(self, message_id, config_target=CONFIG_TARGET_CANDIDATE, + message_timeout=30): + device_response = self.netconf_rpc_client.lock(message_id, config_target, + message_timeout) + return device_response + + def get_config(self, message_id, filter="", + config_target=CONFIG_TARGET_RUNNING, message_timeout=30): + self.log.info("in the ncclient getConfig {}", message_id) + device_response = self.netconf_rpc_client.getConfig(message_id, filter, + config_target, + message_timeout) + return device_response + + def edit_config(self, message_id, message_content, lock=False, + config_target=CONFIG_TARGET_CANDIDATE, + edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE, + deleteConfig=False, validate=False, commit=False, discard_change=False, + unlock=False, message_timeout=30): + device_response = self.netconf_rpc_client.editConfig(message_id, + message_content, lock, + config_target, + edit_default_peration, + deleteConfig, validate, + commit, discard_change, + unlock, + message_timeout) + return device_response + + def commit(self, message_id, discard_change=True, + message_timeout=30): + device_response = self.netconf_rpc_client.commit(message_id, discard_change, + message_timeout) + return device_response + + def unlock(self, message_id, config_target=CONFIG_TARGET_CANDIDATE, + message_timeout=30): + device_response = self.netconf_rpc_client.unLock(message_id, config_target, + message_timeout) + return device_response + + def validate(self, message_id, config_target=CONFIG_TARGET_CANDIDATE, + message_timeout=30): + device_response = self.netconf_rpc_client.validate(message_id, + config_target, + message_timeout) + return device_response + + def discard_change(self, message_id, message_timeout=30): + device_response = self.netconf_rpc_client.discardConfig(message_id, + message_timeout) + return device_response -- cgit 1.2.3-korg From 69a0884d638631452dcbb2989adc39c07b097409 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 15 Feb 2019 09:15:35 -0500 Subject: restconf kotlin script support Change-Id: I07eaa4a2422b461e1b7eb13ec04bf7d10ea08770 Issue-ID: CCSDK-1080 Signed-off-by: Muthuramalingam, Brinda Santh --- .../baseconfiguration/Definitions/node_types.json | 2 +- .../node_type/component-netconf-executor.json | 2 +- .../node_type/component-restconf-executor.json | 24 ++++++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) 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 527307048..65271838e 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 @@ -89,7 +89,7 @@ } } }, - "derived_from": "tosca.nodes.component.Jython" + "derived_from": "tosca.nodes.Component" }, "component-resource-resolution": { "description": "This is Resource Assignment Component API", diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index 9565f6611..0bbcba97c 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -43,5 +43,5 @@ } } }, - "derived_from": "tosca.nodes.component.Jython" + "derived_from": "tosca.nodes.Component" } \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json index 884be5dc6..192ed2566 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json @@ -1,5 +1,5 @@ { - "description": "This is Netconf Transaction Configuration Component API", + "description": "This is Restconf Transaction Configuration Component API", "version": "1.0.0", "capabilities": { "component-node": { @@ -11,9 +11,29 @@ "operations": { "process": { "inputs": { + "script-type": { + "description": "Script type, kotlin type is supported", + "required": true, + "type": "string", + "default": "internal", + "constraints": [ + { + "valid_values": [ + "kotlin", + "jython", + "internal" + ] + } + ] + }, + "script-class-reference": { + "description": "Kotlin Script class name or jython script name.", + "required": true, + "type": "string" + }, "instance-dependencies": { "required": true, - "description": "Instance Names to Inject to Jython Script.", + "description": "Instance names to inject to Jython or Kotlin Script.", "type": "list", "entry_schema": { "type": "string" -- cgit 1.2.3-korg From 455c33fc94acfad8d8f577e2439e5ac56adfa05c Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sun, 17 Feb 2019 09:31:35 -0500 Subject: Netconf resolution service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0346c88cd11136561426260a206bd7bf07f90dd3 Issue-ID: CCSDK-1086 Signed-off-by: Alexis de Talhouët --- .../Definitions/activation-blueprint.json | 13 +++++++++++- .../baseconfiguration/Definitions/node_types.json | 8 ++++++++ .../Scripts/python/NetconfRpcExample.py | 18 +++++++++-------- .../Templates/hostname-mapping.json | 13 ++++++++++++ .../Templates/hostname-template.vtl | 7 +++++++ .../node_type/component-netconf-executor.json | 10 +++++++++- components/scripts/python/ccsdk_netconf/common.py | 23 ++++++++++++++++++++++ .../scripts/python/ccsdk_netconf/netconfclient.py | 2 -- 8 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl 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 07c988b19..162411f8d 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 @@ -219,7 +219,10 @@ }, "inputs": { "instance-dependencies": [ - "json-parser-service" + + ], + "artifact-prefix-names": [ + "hostname" ] }, "outputs": { @@ -238,6 +241,14 @@ } }, "artifacts": { + "hostname-template": { + "type": "artifact-template-velocity", + "file": "Templates/hostname-template.vtl" + }, + "hostname-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/hostname-mapping.json" + }, "component-script": { "type": "artifact-script-jython", "file": "Scripts/python/NetconfRpcExample.py" 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 65271838e..d3093d9c3 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 @@ -71,6 +71,14 @@ "entry_schema": { "type": "string" } + }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } } }, "outputs": { diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py index acdb94aa1..26c66b667 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py @@ -13,8 +13,8 @@ # limitations under the License. import netconf_constant +from common import ResolutionHelper from java.lang import Exception as JavaException -from netconfclient import NetconfClient from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \ NetconfComponentFunction @@ -26,21 +26,23 @@ class NetconfRpcExample(NetconfComponentFunction): log = globals()[netconf_constant.SERVICE_LOG] print(globals()) nc = NetconfClient(log, self, "netconf-connection") - nc.connect() + rr = ResolutionHelper(self) - payload = "DEMO" + payload = rr.resolve_and_generate_message_from_template_prefix("hostname") + nc.connect() response = nc.lock(message_id="lock-123") if not response.isSuccess(): log.error(response.errorMessage) - # nc.edit_config(message_id="edit-config-1", message_content=payload,edit_default_peration="none") + nc.edit_config(message_id="edit-config-1", message_content=payload, + edit_default_peration="none") # nc.validate(message_id="validate-123") # nc.discard_change(message_id="discard-123") - # nc.validate(message_id="validate-123") - # nc.commit(message_id="commit-123") - # nc.unlock(message_id="unlock-123") - # nc.disconnect() + nc.validate(message_id="validate-123") + nc.commit(message_id="commit-123") + nc.unlock(message_id="unlock-123") + nc.disconnect() except JavaException, err: log.error("Java Exception in the script {}", err) diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json new file mode 100644 index 000000000..1e02d6900 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json @@ -0,0 +1,13 @@ +[ + { + "name": "hostname", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "hostname", + "dictionary-source": "input", + "dependencies": [ + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl new file mode 100644 index 000000000..1e80b6d1c --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-template.vtl @@ -0,0 +1,7 @@ + + + + + $hostname + + diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index 0bbcba97c..b59a7384b 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -25,6 +25,14 @@ "entry_schema": { "type": "string" } + }, + "artifact-prefix-names": { + "required": false, + "description": "Template , Resource Assignment Artifact Prefix names", + "type": "list", + "entry_schema": { + "type": "string" + } } }, "outputs": { @@ -43,5 +51,5 @@ } } }, - "derived_from": "tosca.nodes.Component" + "derived_from": "tosca.nodes.Component" } \ No newline at end of file diff --git a/components/scripts/python/ccsdk_netconf/common.py b/components/scripts/python/ccsdk_netconf/common.py index 139597f9c..25244b13a 100644 --- a/components/scripts/python/ccsdk_netconf/common.py +++ b/components/scripts/python/ccsdk_netconf/common.py @@ -1,2 +1,25 @@ +# Copyright (c) 2019 Bell Canada. +# +# 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. +class ResolutionHelper: + def __init__(self, component_function): + self.component_function = component_function + + def resolve_and_generate_message_from_template_prefix(self, artifact_prefix): + return self.component_function.resolveAndGenerateMessage(artifact_prefix) + + def resolve_and_generate_message(self, artifact_mapping, artifact_template): + return self.component_function.resolveAndGenerateMessage(artifact_mapping, + artifact_template) diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py index cdaf84092..341aae738 100644 --- a/components/scripts/python/ccsdk_netconf/netconfclient.py +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -1,7 +1,6 @@ from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \ CONFIG_DEFAULT_OPERATION_REPLACE - class NetconfClient: def __init__(self, log, component_function, requirement_name): @@ -28,7 +27,6 @@ class NetconfClient: def get_config(self, message_id, filter="", config_target=CONFIG_TARGET_RUNNING, message_timeout=30): - self.log.info("in the ncclient getConfig {}", message_id) device_response = self.netconf_rpc_client.getConfig(message_id, filter, config_target, message_timeout) -- cgit 1.2.3-korg From a69b9f500b4f15f78e468cce8561af193a7eb83b Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 18 Feb 2019 08:08:24 -0500 Subject: Simplify NetconfRpcService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6daac25c272ab6b437c07602167a76a2d61816db Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët --- .../Definitions/activation-blueprint.json | 8 +- .../Definitions/hostname-mapping.json | 13 + .../baseconfiguration/Definitions/node_types.json | 287 ++++++++++++++------- .../Definitions/resources_definition_types.json | 34 ++- .../Scripts/python/NetconfRpcExample.py | 16 +- .../Templates/hostname-mapping.json | 13 - .../node_type/component-netconf-executor.json | 30 ++- .../node_type/component-resource-resolution.json | 24 +- .../starter-type/node_type/source-capability.json | 16 -- .../starter-type/node_type/vnf-netconf-device.json | 2 +- .../starter-dictionary/hostname.json | 14 + .../scripts/python/ccsdk_netconf/netconfclient.py | 54 ++-- 12 files changed, 292 insertions(+), 219 deletions(-) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/hostname.json 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 162411f8d..c21f4c9d0 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 @@ -218,11 +218,9 @@ "primary": "component-script" }, "inputs": { + "script-type": "jython", + "script-class-reference": "Scripts/python/NetconfRpcExample.py", "instance-dependencies": [ - - ], - "artifact-prefix-names": [ - "hostname" ] }, "outputs": { @@ -247,7 +245,7 @@ }, "hostname-mapping": { "type": "artifact-mapping-resource", - "file": "Templates/hostname-mapping.json" + "file": "Definitions/hostname-mapping.json" }, "component-script": { "type": "artifact-script-jython", diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json new file mode 100644 index 000000000..1e02d6900 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/hostname-mapping.json @@ -0,0 +1,13 @@ +[ + { + "name": "hostname", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "hostname", + "dictionary-source": "input", + "dependencies": [ + ] + } +] 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 d3093d9c3..3912a472d 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 @@ -1,48 +1,44 @@ { "node_types": { - "dg-generic": { - "description": "This is Generic Directed Graph Type", + "component-jython-executor": { + "description": "This is Jython Execution Component.", "version": "1.0.0", - "properties": { - "content": { - "required": true, - "type": "string" - }, - "dependency-node-templates": { - "required": true, - "description": "Dependent Step Components", - "type": "list", - "entry_schema": { - "type": "string" + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "ComponentJythonExecutor": { + "operations": { + "process": { + "inputs": { + "instance-dependencies": { + "description": "Instance Names to Inject to Jython Script.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "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.DG" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph Node Type", - "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.Vnf" : { - "description" : "This is VNF Node Type", - "version" : "1.0.0", - "derived_from" : "tosca.nodes.Root" - }, - "tosca.nodes.component.Jython": { - "description": "This is Resource Assignment Jython Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" + "derived_from": "tosca.nodes.component.Jython" }, "component-netconf-executor": { "description": "This is Netconf Transaction Configuration Component API", @@ -64,17 +60,29 @@ "operations": { "process": { "inputs": { - "instance-dependencies": { - "description": "Instance Names to Inject to Jython Script.", + "script-type": { + "description": "Script type, kotlin type is supported", "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } + "type": "string", + "constraints": [ + { + "valid_values": [ + "kotlin", + "jython", + "internal" + ] + } + ], + "default": "internal" }, - "artifact-prefix-names": { - "required": false, - "description": "Template , Resource Assignment Artifact Prefix names", + "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" @@ -108,37 +116,43 @@ "type": "string" } }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, "interfaces": { "ResourceResolutionComponent": { "operations": { "process": { "inputs": { - "action-name": { - "description": "Recipe Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, "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 used to store the generated configuration, in the database along with the template-name", + "description": "Request Id, Unique Id for the request.", "required": true, "type": "string" }, "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, + "description": "Resource Id.", + "required": false, "type": "string" }, - "artifact-prefix-names": { + "action-name": { + "description": "Action Name of the process", "required": false, - "description": "Template , Resource Assignment Artifact Prefix names", - "type": "list", - "entry_schema": { - "type": "string" - } + "type": "string" } }, "outputs": { @@ -157,45 +171,128 @@ }, "derived_from": "tosca.nodes.Component" }, - "component-jython-executor": { - "description": "This is Jython Execution Component.", + "dg-generic": { + "description": "This is Generic Directed Graph Type", "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" + "properties": { + "content": { + "required": true, + "type": "string" + }, + "dependency-node-templates": { + "description": "Dependent Step Components NodeTemplate name.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } } }, - "interfaces": { - "ComponentJythonExecutor": { - "operations": { - "process": { - "inputs": { - "instance-dependencies": { - "required": true, - "description": "Instance Names to Inject to Jython Script.", - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "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.DG" + }, + "source-input": { + "description": "This is Input Resource Source Node Type", + "version": "1.0.0", + "properties": { + "key": { + "required": false, + "type": "string" + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" + }, + "source-rest": { + "description": "This is Rest Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": false, + "type": "string", + "constraints": [ + { + "valid_values": [ + "JSON" + ] + } + ], + "default": "JSON" + }, + "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.component.Jython" + "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.DG": { + "description": "This is Directed Graph Node Type", + "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.Vnf": { + "description": "This is VNF Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "tosca.nodes.component.Jython": { + "description": "This is Jython Component", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" }, "vnf-netconf-device": { "description": "This is VNF Device with Netconf Capability", @@ -215,7 +312,7 @@ "default": "sdnc-tacacs" }, "source": { - "required": true, + "required": false, "type": "string", "default": "npm" }, 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 d2d32e81e..ace1a9425 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 @@ -1,35 +1,41 @@ { + "hostname": { + "tags": "hostname", + "name": "hostname", + "property": { + "description": "hostname", + "type": "string" + }, + "updated-by": "Singal, Kapil ", + "sources": { + "input": { + "type": "source-input" + } + } + }, "service-instance-id": { - "name": "service-instance-id", "tags": "service-instance-id, tosca.datatypes.Root, data_type", - "updated-by": "Singal, Kapil ", + "name": "service-instance-id", "property": { "description": "To be provided", "type": "string" }, + "updated-by": "Singal, Kapil ", "sources": { "input": { "type": "source-input", "properties": {} - }, - "capability": { - "type": "source-capability", - "properties": { - "type": "JYTHON-COMPONENT", - "instance-name": "SampleRAProcessor", - "instance-dependencies": [] - } } } }, "vnf-id": { - "name": "vnf-id", "tags": "vnf-id", - "updated-by": "Singal, Kapil ", + "name": "vnf-id", "property": { "description": "vnf-id", "type": "string" }, + "updated-by": "Singal, Kapil ", "sources": { "input": { "type": "source-input", @@ -38,13 +44,13 @@ } }, "vnf_name": { - "name": "vnf_name", "tags": "vnf_name", - "updated-by": "Singal, Kapil ", + "name": "vnf_name", "property": { "description": "vnf_name", "type": "string" }, + "updated-by": "Singal, Kapil ", "sources": { "primary-config-data": { "type": "source-rest", diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py index 26c66b667..94cd72a48 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py @@ -15,6 +15,7 @@ import netconf_constant from common import ResolutionHelper from java.lang import Exception as JavaException +from netconfclient import NetconfClient from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \ NetconfComponentFunction @@ -31,17 +32,16 @@ class NetconfRpcExample(NetconfComponentFunction): payload = rr.resolve_and_generate_message_from_template_prefix("hostname") nc.connect() - response = nc.lock(message_id="lock-123") + response = nc.lock() if not response.isSuccess(): log.error(response.errorMessage) - nc.edit_config(message_id="edit-config-1", message_content=payload, - edit_default_peration="none") - # nc.validate(message_id="validate-123") - # nc.discard_change(message_id="discard-123") - nc.validate(message_id="validate-123") - nc.commit(message_id="commit-123") - nc.unlock(message_id="unlock-123") + nc.edit_config(message_content=payload, edit_default_peration="none") + nc.validate() + nc.discard_change() + nc.validate() + nc.commit() + nc.unlock() nc.disconnect() except JavaException, err: diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json deleted file mode 100644 index 1e02d6900..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Templates/hostname-mapping.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "name": "hostname", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "hostname", - "dictionary-source": "input", - "dependencies": [ - ] - } -] diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index b59a7384b..85b69b09d 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -18,17 +18,29 @@ "operations": { "process": { "inputs": { - "instance-dependencies": { + "script-type": { + "description": "Script type, kotlin type is supported", "required": true, - "description": "Instance Names to Inject to Jython Script.", - "type": "list", - "entry_schema": { - "type": "string" - } + "type": "string", + "default": "internal", + "constraints": [ + { + "valid_values": [ + "kotlin", + "jython", + "internal" + ] + } + ] }, - "artifact-prefix-names": { - "required": false, - "description": "Template , Resource Assignment Artifact Prefix names", + "script-class-reference": { + "description": "Kotlin Script class name or jython script name.", + "required": true, + "type": "string" + }, + "instance-dependencies": { + "required": true, + "description": "Instance names to inject to Jython or Kotlin Script.", "type": "list", "entry_schema": { "type": "string" diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json index d01660efc..7e3065ae2 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json @@ -17,31 +17,13 @@ "operations": { "process": { "inputs": { - "template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "template-version": { - "description": "Service Template Version.", - "required": true, - "type": "string" - }, "resource-type": { "description": "Request type.", - "required": true, + "required": false, "type": "string" }, - "template-names": { - "description": "Name of the artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, "artifact-prefix-names": { - "required": false, + "required": true, "description": "Template , Resource Assignment Artifact Prefix names", "type": "list", "entry_schema": { @@ -50,7 +32,7 @@ }, "request-id": { "description": "Request Id, Unique Id for the request.", - "required": false, + "required": true, "type": "string" }, "resource-id": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json index 2bdd7d574..4d9488cbc 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json +++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json @@ -29,22 +29,6 @@ "type": "string" } }, - "input-key-mapping": { - "description": "Context name to input parameters name mapping.", - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "output-key-mapping": { - "description": "Context name to output parameters name mapping.", - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, "key-dependencies": { "description": "Resource Resolution dependency dictionary names.", "required": true, diff --git a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json index c6f512dfb..dcc47b362 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json +++ b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json @@ -16,7 +16,7 @@ "default": "sdnc-tacacs" }, "source": { - "required": true, + "required": false, "type": "string", "default": "npm" }, diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/hostname.json b/components/model-catalog/resource-dictionary/starter-dictionary/hostname.json new file mode 100755 index 000000000..f60751edc --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/hostname.json @@ -0,0 +1,14 @@ +{ + "name": "hostname", + "tags": "hostname", + "updated-by" : "Singal, Kapil ", + "property": { + "description" : "hostname", + "type": "string" + }, + "sources": { + "input": { + "type": "source-input" + } + } +} diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py index 341aae738..dd7d2dc22 100644 --- a/components/scripts/python/ccsdk_netconf/netconfclient.py +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -1,6 +1,7 @@ from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \ CONFIG_DEFAULT_OPERATION_REPLACE + class NetconfClient: def __init__(self, log, component_function, requirement_name): @@ -19,54 +20,33 @@ class NetconfClient: self.netconf_session.connect() return - def lock(self, message_id, config_target=CONFIG_TARGET_CANDIDATE, - message_timeout=30): - device_response = self.netconf_rpc_client.lock(message_id, config_target, - message_timeout) + def lock(self, config_target=CONFIG_TARGET_CANDIDATE): + device_response = self.netconf_rpc_client.lock(config_target) return device_response - def get_config(self, message_id, filter="", - config_target=CONFIG_TARGET_RUNNING, message_timeout=30): - device_response = self.netconf_rpc_client.getConfig(message_id, filter, - config_target, - message_timeout) + def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING): + device_response = self.netconf_rpc_client.getConfig(filter, config_target) return device_response - def edit_config(self, message_id, message_content, lock=False, - config_target=CONFIG_TARGET_CANDIDATE, - edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE, - deleteConfig=False, validate=False, commit=False, discard_change=False, - unlock=False, message_timeout=30): - device_response = self.netconf_rpc_client.editConfig(message_id, - message_content, lock, + def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE, + edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE): + device_response = self.netconf_rpc_client.editConfig(message_content, config_target, - edit_default_peration, - deleteConfig, validate, - commit, discard_change, - unlock, - message_timeout) + edit_default_peration) return device_response - def commit(self, message_id, discard_change=True, - message_timeout=30): - device_response = self.netconf_rpc_client.commit(message_id, discard_change, - message_timeout) + def commit(self): + device_response = self.netconf_rpc_client.commit() return device_response - def unlock(self, message_id, config_target=CONFIG_TARGET_CANDIDATE, - message_timeout=30): - device_response = self.netconf_rpc_client.unLock(message_id, config_target, - message_timeout) + def unlock(self, config_target=CONFIG_TARGET_CANDIDATE): + device_response = self.netconf_rpc_client.unLock(config_target) return device_response - def validate(self, message_id, config_target=CONFIG_TARGET_CANDIDATE, - message_timeout=30): - device_response = self.netconf_rpc_client.validate(message_id, - config_target, - message_timeout) + def validate(self, config_target=CONFIG_TARGET_CANDIDATE): + device_response = self.netconf_rpc_client.validate(config_target) return device_response - def discard_change(self, message_id, message_timeout=30): - device_response = self.netconf_rpc_client.discardConfig(message_id, - message_timeout) + def discard_change(self): + device_response = self.netconf_rpc_client.discardConfig() return device_response -- cgit 1.2.3-korg From e0f3198bffd8c5f4945ce0bb91ef3024b5996bbc Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 18 Feb 2019 15:10:25 -0500 Subject: Add component function scripting service Change-Id: I7c5b49617823dd623566fb4be4d431012420e17c Issue-ID: CCSDK-959 Signed-off-by: Muthuramalingam, Brinda Santh --- .../baseconfiguration/Environments/source-rest.properties | 9 +++++++++ .../definition-type/starter-type/node_type/source-rest.json | 4 ++++ .../resource-dictionary/starter-dictionary/mdsal-source.json | 1 + components/parent/pom.xml | 1 + 4 files changed, 15 insertions(+) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-rest.properties diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-rest.properties b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-rest.properties new file mode 100644 index 000000000..37bad8d0a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-rest.properties @@ -0,0 +1,9 @@ +blueprintsprocessor.restclient.primary-config-data.type=basic-auth +blueprintsprocessor.restclient.primary-config-data.url=http://127.0.0.1:9111 +blueprintsprocessor.restclient.primary-config-data.userId=sampleuser +blueprintsprocessor.restclient.primary-config-data.token=sampletoken + +blueprintsprocessor.restclient.primary-config-data1.type=basic-auth +blueprintsprocessor.restclient.primary-config-data1.url=http://127.0.0.1:9111 +blueprintsprocessor.restclient.primary-config-data1.userId=sampleuser +blueprintsprocessor.restclient.primary-config-data1.token=sampletoken \ No newline at end of file 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 f8dd8b6fc..044983040 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,10 @@ } ] }, + "endpoint-selector": { + "required": false, + "type": "string" + }, "url-path": { "required": true, "type": "string" diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json index 67661ecd0..ee67b9256 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/mdsal-source.json @@ -11,6 +11,7 @@ "type": "source-rest", "properties": { "type": "JSON", + "endpoint-selector" : "", "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", "path": "/v4-assigned-ip-list/0/v4-ip-prefix", "input-key-mapping": { diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 761b0fad7..94a06a1fd 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -29,6 +29,7 @@ Components Parent pom + 1.8 2.1.2.RELEASE 5.1.4.RELEASE 1.3.20 -- cgit 1.2.3-korg From 18e18571bd0d5e7e58359ce35c315c5b2e341ae6 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 19 Feb 2019 10:02:00 -0500 Subject: Add support for commit confirmed capability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3608a6a62469d4b5dfc5fc69f610f9da186156c2 Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët --- components/scripts/python/ccsdk_netconf/netconfclient.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py index dd7d2dc22..d898ec009 100644 --- a/components/scripts/python/ccsdk_netconf/netconfclient.py +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -35,8 +35,14 @@ class NetconfClient: edit_default_peration) return device_response - def commit(self): - device_response = self.netconf_rpc_client.commit() + def commit(self, confirmed=False, confirm_timeout=60, persist="", + persist_id=""): + device_response = self.netconf_rpc_client.commit(confirmed, confirm_timeout, + persist, persist_id) + return device_response + + def cancel_commit(self, persist_id=""): + device_response = self.netconf_rpc_client.cancelCommit(persist_id) return device_response def unlock(self, config_target=CONFIG_TARGET_CANDIDATE): -- cgit 1.2.3-korg From f926e302a848923aeb07ee336ddaf335d4e99fa1 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 20 Feb 2019 11:34:23 -0500 Subject: Add dsl model definition Change-Id: Ic2332e32d142f231cc8a3a25e2528cde455da827 Issue-ID: CCSDK-1095 Signed-off-by: Muthuramalingam, Brinda Santh Signed-off-by: Balazinski --- .../baseconfiguration/Definitions/activation-blueprint.json | 9 +++++++++ 1 file changed, 9 insertions(+) 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 c21f4c9d0..138260fed 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 @@ -24,6 +24,15 @@ "file": "Definitions/policy_types.json" } ], + "dsl_definitions" : { + "dynamic-rest-source": { + "type" : "basic-type", + "url" : "http://localhost:8080", + "userId" : { + "get_input": "rest-user-name" + } + } + }, "topology_template": { "inputs": { "request-id": { -- cgit 1.2.3-korg From 5d9772fbec43dd9f5b8a7de6192e4b8c8fe71c40 Mon Sep 17 00:00:00 2001 From: Rodrigo Ottero Date: Thu, 28 Feb 2019 14:08:55 +0000 Subject: *WIP*: draft of a blueprint for configuring a PNF This is a still-in-development draft of a blueprint, intended to be used to configure PNFs. It has been put in review as requested, to make easier for the community to make comments on it. The design considers that a blueprint will be created for each possible PNF. In some files, there are questions about the structure or content. The- se questions are surrounded by HTML comment tags , even if the file itself is not HTML - the intent is just to clearly highlight the questions. All of them are preceded by the string "QUESTION", to facil- itate search. Change-Id: Ib3ed2afb80693429dc23b7ac73c5cbe49b3f5c9a Issue-ID: CCSDK-1107 Signed-off-by: Rodrigo Ottero --- .../Definitions/activation-blueprint.json | 228 +++++++++++++++++++++ .../Definitions/artifact_types.json | 28 +++ .../Definitions/data_types.json | 23 +++ .../Definitions/node_types.json | 168 +++++++++++++++ .../Definitions/policy_types.json | 3 + .../Definitions/relationship_types.json | 9 + .../Definitions/resources_definition_types.json | 16 ++ .../Plans/CONFIG_configAssign.xml | 19 ++ .../capability_restconf/Plans/CONFIG_configure.xml | 19 ++ .../Scripts/RestconfAssignConfig.kts | 1 + .../Scripts/RestconfConfigure.kts | 1 + .../capability_restconf/TOSCA-Metada/TOSCA.meta | 5 + .../Templates/config-assign-pnf-mapping.json | 16 ++ .../config-assign-restconf-configlet-template.vtl | 19 ++ .../Templates/configure-pnf-mapping.json | 38 ++++ .../configure-restconf-mount-template.vtl | 14 ++ .../configure-restconf-unmount-template.vtl | 1 + 17 files changed, 608 insertions(+) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json new file mode 100644 index 000000000..96ae88e59 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json @@ -0,0 +1,228 @@ + +{ + "tosca_definitions_version" : "controller_blueprint_1_0_0", + "metadata" : { + "template_author" : "Rodrigo Ottero", + "author-email" : "rodrigo.ottero@est.tech", + "user-groups" : "ADMIN, OPERATION", + "template_name" : "pnf 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" + } ], + "topology_template" : { + "inputs" : { + "serviceInstanceId" : { + "required" : true, + "type" : "string" + }, + "identifier" : { + "required" : true, + "type" : "string" + } + }, + "workflows" : { + "config-assign" : { + "steps" : { + "activate-process" : { + "description" : "Create a configlet", + "target" : "config-assign-process", + "activities" : [ { + "call_operation" : "" + } ] + } + }, + "inputs" : { + "config-assign-properties" : { + "description" : "Dynamic PropertyDefinition for workflow(config-assign).", + "required" : true, + "type" : "dt-config-assign-properties" + } + } + }, + "configure" : { + "steps" : { + "activate-process" : { + "description" : "Send a configlet to the pnf", + "target" : "configure-process", + "activities" : [ { + "call_operation" : "" + } ] + } + }, + "inputs" : { + "configure-properties" : { + "description" : "Dynamic PropertyDefinition for workflow(configure).", + "required" : true, + "type" : "dt-configure-properties" + } + } + } + }, + "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-restconf-executor", + "requirements" : { + "restconf-connection" : { + "capability" : "restconf", + "node" : "sample-restconf-server", + "relationship" : "tosca.relationships.ConnectsTo" + } + }, + "interfaces" : { + "ComponentRestconfExecutor" : { + "operations" : { + "process" : { + "implementation" : { + "primary" : "component-script" + }, + "inputs" : { + "script-type" : "kotlin", + "script-class-reference" : "Scripts/kotlin/RestconfAssignConfig.kts", + "instance-dependencies" : [ ], + "artifact-prefix-names": [ + "config-assign" + ] + }, + "outputs" : { + "response-data" : "", + "status" : "" + } + } + } + } + }, + "artifacts" : { + "config-assign-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/config-assign-restconf-configlet-template.vtl" + }, + "config-assign-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/config-assign-pnf-mapping.json" + }, + "component-script" : { + "type" : "artifact-script-kotlin", + "file" : "Scripts/kotlin/RestconfAssignConfig.py" + } + } + }, + "configure-process" : { + "type" : "dg-generic", + "properties" : { + "content" : { + "get_artifact" : [ "SELF", "dg-configure-process" ] + }, + "dependency-node-templates" : [ "configure" ] + }, + "artifacts" : { + "dg-config-assign-process" : { + "type" : "artifact-directed-graph", + "file" : "Plans/CONFIG_configure.xml" + } + } + }, + "configure" : { + "type" : "component-restconf-executor", + "requirements" : { + "restconf-connection" : { + "capability" : "restconf", + "node" : "sample-restconf-server", + "relationship" : "tosca.relationships.ConnectsTo" + } + }, + "interfaces" : { + "ComponentRestconfExecutor" : { + "operations" : { + "process" : { + "implementation" : { + "primary" : "component-script" + }, + "inputs" : { + "script-type" : "kotlin", + "script-class-reference" : "Scripts/kotlin/RestconfConfigure.kts", + "instance-dependencies" : [ ], + "artifact-prefix-names": [ + "configure-restconf-mount", "configure-restconf-unmount" + ] + }, + "outputs" : { + "response-data" : "", + "status" : "" + } + } + } + } + }, + "artifacts" : { + "configure-mount-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/configure-restconf-mount-template.vtl" + }, + "configure-unmount-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/configure-restconf-unmount-template.vtl" + }, + "configure-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/configure-pnf-mapping.json" + }, + "component-script" : { + "type" : "artifact-script-kotlin", + "file" : "Scripts/kotlin/RestconfConfigure.py" + } + } + }, + "sample-restconf-device" : { + "type" : "pnf-netconf-device", + "capabilities" : { + "restconf" : { + "properties" : { + "login-key" : { + "get_input" : "password" + }, + "login-account" : { + "get_input" : "username" + }, + "target-ip-address" : { + "get_input" : "ip" + }, + "port-number" : 830, + "connection-time-out" : 5 + } + } + } + } + } + } +} diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json new file mode 100644 index 000000000..aa5295e44 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/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/test-blueprint/capability_restconf/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json new file mode 100644 index 000000000..d9153f3f0 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json @@ -0,0 +1,23 @@ +{ + "data_types" : { + "dt-assign-activate-properties" : { + "description" : "Dynamic DataType definition for workflow(assign-activate).", + "version" : "1.0.0", + "properties" : { + "hostname" : { + "type" : "string" + }, + "ip": { + "type": "string" + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" + } + }, + "derived_from" : "tosca.datatypes.Dynamic" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json new file mode 100644 index 000000000..c8e3e6a93 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json @@ -0,0 +1,168 @@ +{ + "node_types" : { + "component-restconf-executor" : { + "description" : "This is Restconf Configuration Component API", + "version" : "1.0.0", + "capabilities" : { + "component-node" : { + "type" : "tosca.capabilities.Node" + } + }, + "requirements" : { + "restconf-connection" : { + "capability" : "restconf", + "node" : "pnf-restconf-device", + "relationship" : "tosca.relationships.ConnectsTo" + } + }, + "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" + } + } + }, + "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", + "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.DG" + }, + "source-input" : { + "description" : "This is Input Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "key" : { + "required" : false, + "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.DG" : { + "description" : "This is Directed Graph Node Type", + "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.Vnf" : { + "description" : "This is VNF Node Type", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "tosca.nodes.Pnf": { + "description": "This is the PNF Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + }, + "pnf-restconf-device" : { + "description" : "This is a PNF Device with Restconf Capability", + "version" : "1.0.0", + "capabilities" : { + "netconf" : { + "type" : "tosca.capabilities.Restconf", + "properties" : { + "login-key" : { + "required" : true, + "type" : "string", + "default" : "sdnc" + }, + "login-account" : { + "required" : true, + "type" : "string", + "default" : "sdnc-tacacs" + }, + "source" : { + "required" : false, + "type" : "string", + "default" : "npm" + }, + "target-ip-address" : { + "required" : true, + "type" : "string" + }, + "port-number" : { + "required" : true, + "type" : "integer", + "default" : 830 + }, + "connection-time-out" : { + "required" : false, + "type" : "integer", + "default" : 30 + } + } + } + }, + "derived_from" : "tosca.nodes.Pnf" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json new file mode 100644 index 000000000..1e44cc70a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json @@ -0,0 +1,3 @@ +{ + "policy_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json new file mode 100644 index 000000000..027bfc0fc --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json @@ -0,0 +1,9 @@ +{ + "relationship_types" : { + "tosca.relationships.ConnectsTo" : { + "description" : "Relationship tosca.relationships.ConnectsTo", + "version" : "1.0.0", + "derived_from" : "tosca.relationships.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json new file mode 100644 index 000000000..b77f451ad --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json @@ -0,0 +1,16 @@ +{ + "hostname" : { + "tags" : "hostname", + "name" : "hostname", + "property" : { + "description" : "hostname", + "type" : "string" + }, + "updated-by" : "Singal, Kapil ", + "sources" : { + "input" : { + "type" : "source-input" + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml new file mode 100644 index 000000000..417f72de9 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml new file mode 100644 index 000000000..94fe6dde0 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts new file mode 100644 index 000000000..a0990367e --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts @@ -0,0 +1 @@ +TBD diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts new file mode 100644 index 000000000..a0990367e --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts @@ -0,0 +1 @@ +TBD diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta new file mode 100644 index 000000000..6ac9caf57 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta @@ -0,0 +1,5 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Rodrigo Ottero +Entry-Definitions: Definitions/activation-blueprint.json +Template-Tags: activation-blueprint diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json new file mode 100644 index 000000000..85533abc5 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json @@ -0,0 +1,16 @@ + +[ + { + "name": "odl_host", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "odl_host", + "dictionary-source": "capability", + "dependencies": [ + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl new file mode 100644 index 000000000..e3d7a6716 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl @@ -0,0 +1,19 @@ + +example-patch +Example patch + + edit1 + create + /car-entry + + + 0 + + + + + edit2 + delete + /car-entry/0 + + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json new file mode 100644 index 000000000..123680c0c --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json @@ -0,0 +1,38 @@ + +[ + { + "name": "pnf_id", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "pnf_id", + "dictionary-source": "capability", + "dependencies": [ + ] + }, + { + "name": "pnf_ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "pnf_ip", + "dictionary-source": "capability", + "dependencies": [ + ] + }, + { + "name": "pnf_ip_port", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "pnf_ip_port", + "dictionary-source": "capability", + "dependencies": [ + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl new file mode 100644 index 000000000..17f7a3679 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl @@ -0,0 +1,14 @@ + + $pnf_id + + ODL-private-key + netconf + + $pnf_ip + $pnf_ip_port + false + + TLS + + 2 + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl new file mode 100644 index 000000000..a0990367e --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl @@ -0,0 +1 @@ +TBD -- cgit 1.2.3-korg From 9c08b516cca8a42560a3302eaf663d3c248c4a53 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 25 Feb 2019 16:03:16 -0500 Subject: Get DSL Property in Resource Resolution Change-Id: I768c2515bc4b0eaa829213ac4d045628ca960adb Issue-ID: CCSDK-1106 Signed-off-by: Muthuramalingam, Brinda Santh --- .../starter-type/node_type/source-capability.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json index 4d9488cbc..e0c440649 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json +++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json @@ -2,22 +2,22 @@ "description": "This is Component Resource Source Node Type", "version": "1.0.0", "properties": { - "type": { + "script-type": { "required": true, "type": "string", - "default": "KOTLIN-COMPONENT", + "default": "kotlin", "constraints": [ { "valid_values": [ - "KOTLIN-COMPONENT", - "JAVA-COMPONENT", - "JYTHON-COMPONENT" + "kotlin", + "internal", + "jython" ] } ] }, - "instance-name": { - "description": "Capability component instance reference name for JAVA-COMPONENT, Script Class name for KOTLIN-COMPONENT.", + "script-class-reference": { + "description": "Capability reference name for internal and kotlin, for jython script file path", "required": true, "type": "string" }, -- cgit 1.2.3-korg From e950b19db14ee325416f8e73420d682d07e5e6cf Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 28 Feb 2019 08:59:20 -0500 Subject: Adjust python script for resource-assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie96b4dc99c4da461a5fe7dfb424fdec6c221f9e0 Issue-ID: CCSDK-1091 Signed-off-by: Alexis de Talhouët --- .../Scripts/python/SampleRAProcessor.py | 22 ++------- .../ccsdk_blueprints/abstract_ra_processor.py | 56 +++++++--------------- .../sample_ra_processor_function.py | 10 ++-- 3 files changed, 26 insertions(+), 62 deletions(-) diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py index 30b9ff951..acf12b333 100755 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py @@ -7,23 +7,11 @@ class SampleRAProcessor(AbstractRAProcessor): def __init__(self): AbstractRAProcessor.__init__(self) - def process(self, execution_request): - - AbstractRAProcessor.process(self, execution_request) - print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH - if self.ra_valid is True: - value = self.resolve_values_script(execution_request, self.value_to_resolve) - self.set_resource_data_value(execution_request, value) - else: - raise BluePrintProcessorException("Error on resource assignment. Message = " + self.error_message) + def process(self, resource_assignment): + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + self.set_resource_data_value(resource_assignment, "") return None - def recover(self, runtime_exception, execution_request): - AbstractRAProcessor.recover(self, runtime_exception, execution_request) - print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH + def recover(self, runtime_exception, resource_assignment): + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None - - def resolve_values_script(self, execution_request, value_to_resolve): - # TODO : DO business logic here - print "Resolve value for " + value_to_resolve + " here..." - return "test_python" diff --git a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py index 2cacaf526..6489b1e73 100644 --- a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py +++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py @@ -1,49 +1,29 @@ -from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor -from blueprint_constants import * -from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import ResourceAssignmentUtils -from org.onap.ccsdk.apps.controllerblueprints.core import BluePrintProcessorException -from java.lang import Exception +from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import \ + ResourceAssignmentProcessor +from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import \ + ResourceAssignmentUtils +from org.onap.ccsdk.apps.controllerblueprints.core import \ + BluePrintProcessorException class AbstractRAProcessor(ResourceAssignmentProcessor): - def __init__(self): - ResourceAssignmentProcessor.__init__(self) - self.status = PROPERTY_BLUEPRINT_STATUS_SUCCESS - self.error_message = None - self.ra_valid = False - self.value_to_resolve = None - - def process(self, execution_request): - print "Processing calling from parent..." - try: - self.ra_valid = self.validate(execution_request) - self.value_to_resolve = execution_request.name - except Exception, e: - self.status = PROPERTY_BLUEPRINT_STATUS_FAILURE - self.error_message = "Get Running python scripting Failure :" + e.getMessage() + def process(self, resource_assignment): + print "Processing.." + return None - def recover(self, runtime_exception, execution_request): - print "Recovering calling from parent.." + def recover(self, runtime_exception, resource_assignment): + print "Recovering.." return None - def set_resource_data_value(self, execution_request, value): + def set_resource_data_value(self, resource_assignment, value): try: if value is not None: - ResourceAssignmentUtils.Companion.setResourceDataValue(execution_request, self.raRuntimeService, value) + ResourceAssignmentUtils.Companion.setResourceDataValue( + resource_assignment, self.raRuntimeService, value) else: - ResourceAssignmentUtils.Companion.setFailedResourceDataValue(execution_request, "Fail to resole value") + ResourceAssignmentUtils.Companion.setFailedResourceDataValue( + resource_assignment, "Fail to resolve value") except BluePrintProcessorException, err: - raise BluePrintProcessorException("Error on resource assignment. Message = " + err.message) - - return None - - @staticmethod - def validate(ra): - if ra.name is None or ra.name is None: - raise Exception("Failed getting value for template key (" + ra.name + ") and " + - "dictionary key (" + ra.dictionaryName + - ") of type (" + ra.type + ")") - else: - pass - return True + raise BluePrintProcessorException( + "Error on resource assignment. Message = " + err.message) diff --git a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py index 6ec5d82ab..fa821082e 100644 --- a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py +++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py @@ -4,15 +4,11 @@ from blueprint_constants import * class SampleRAProcessorFunction(AbstractRAProcessor): - def __init__(self): - AbstractRAProcessor.__init__(self) - - def process(self, execution_request): - AbstractRAProcessor.process(self, execution_request) + def process(self, resource_assignment): print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + self.set_resource_data_value(resource_assignment, "") return None - def recover(self, runtime_exception, execution_request): - AbstractRAProcessor.recover(self, runtime_exception, execution_request) + def recover(self, runtime_exception, resource_assignment): print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None -- cgit 1.2.3-korg From 2028db8399fd7afa55cb129beef501994753cb63 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 4 Mar 2019 10:22:04 -0500 Subject: Define EventType contract for gRPC message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic8bde56d13f774120c8d64a56993ade71e7b4612 Issue-ID: CCSDK-1118 Signed-off-by: Alexis de Talhouët --- .../model-catalog/proto-definition/proto/BluePrintCommon.proto | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto index 0f17783aa..de92bdc1c 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto @@ -26,6 +26,13 @@ message Status { int32 code = 1; string errorMessage = 2; string message = 3; - string eventType = 4; + EventType eventType = 4; string timestamp = 5; +} + +enum EventType { + EVENT_COMPONENT_FAILURE = 0; + EVENT_COMPONENT_PROCESSING = 1; + EVENT_COMPONENT_NOTIFICATION = 2; + EVENT_COMPONENT_EXECUTED = 3; } \ No newline at end of file -- cgit 1.2.3-korg From d882d5ea5199cca12c246c1a184a8358892c7186 Mon Sep 17 00:00:00 2001 From: vinal patel Date: Wed, 20 Feb 2019 16:02:44 -0500 Subject: Ressource resolution using configurable database Change-Id: I8589e4db45ba3d5bcb906f25bcc76b5136159608 Issue-ID: CCSDK-1092 Signed-off-by: vinal patel --- .../Definitions/activation-blueprint.json | 11 +++++++++++ .../Definitions/resources_definition_types.json | 13 +++++++++++++ .../Environments/source-db.properties | 1 + .../starter-dictionary/service-instance-id.json | 22 ++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-db.properties 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 138260fed..6025dbd6d 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 @@ -31,6 +31,17 @@ "userId" : { "get_input": "rest-user-name" } + }, + "dynamic-db-source": { + "type" : "maria-db", + "url" : "jdbc:mysql://localhost:3306/sdnctl", + "username" : "sdnctl", + "password" : { + "get_attribute": [ + "BPP", + "dynamic-db-source.password" + ] + } } }, "topology_template": { 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 ace1a9425..eaf45b35f 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 @@ -25,6 +25,19 @@ "input": { "type": "source-input", "properties": {} + }, + "primary-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\"", + "input-key-mapping": { + }, + "output-key-mapping": { + "service-instance-id": "artifact_name" + }, + "key-dependencies" : [] + } } } }, diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-db.properties b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-db.properties new file mode 100644 index 000000000..49a7eb47b --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Environments/source-db.properties @@ -0,0 +1 @@ +dynamic-db-source.password=sdnctl \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json index 37b98687c..cb9704350 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json @@ -10,6 +10,28 @@ "input" : { "type" : "source-input", "properties" : { } + }, + "any-db": { + "type": "source-primary-db", + "properties": { + "query": "SELECT artifact_name FROM BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", + "input-key-mapping": { + }, + "output-key-mapping": { + "service-instance-id": "artifact_name" + } + } + }, + "primary-db": { + "type": "source-primary-db", + "properties": { + "query": "SELECT artifact_name FROM BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"", + "input-key-mapping": { + }, + "output-key-mapping": { + "service-instance-id": "artifact_name" + } + } } } } \ No newline at end of file -- cgit 1.2.3-korg From 38e4e9267b7339c02767a8f2b38af85d8316ef1c Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 7 Mar 2019 11:23:17 -0500 Subject: Add support for resource-resolution storage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0113191075804f6b77ce54c741bf0a1ccd356c77 Issue-ID: CCSDK-338 Signed-off-by: Alexis de Talhouët --- .../starter-type/node_type/component-netconf-executor.json | 5 +++++ .../starter-type/node_type/component-resource-resolution.json | 10 ++++++++++ components/scripts/python/ccsdk_netconf/common.py | 3 +++ 3 files changed, 18 insertions(+) diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index 85b69b09d..e5cb4cba0 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -33,6 +33,11 @@ } ] }, + "dynamic-properties": { + "description": "Resolvable dynamic property.", + "required": false, + "type": "string" + }, "script-class-reference": { "description": "Kotlin Script class name or jython script name.", "required": true, diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json index 7e3065ae2..5dbef4dcc 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json @@ -17,6 +17,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, diff --git a/components/scripts/python/ccsdk_netconf/common.py b/components/scripts/python/ccsdk_netconf/common.py index 25244b13a..f161e29ff 100644 --- a/components/scripts/python/ccsdk_netconf/common.py +++ b/components/scripts/python/ccsdk_netconf/common.py @@ -23,3 +23,6 @@ class ResolutionHelper: def resolve_and_generate_message(self, artifact_mapping, artifact_template): return self.component_function.resolveAndGenerateMessage(artifact_mapping, artifact_template) + + def retrieve_resolved_template_from_database(self, key, artifact_template): + return self.component_function.resolveFromDatabase(key, artifact_template) -- cgit 1.2.3-korg From 8fb0ac2772263d922841661f50fee1ae821008a5 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 27 Feb 2019 20:16:47 -0500 Subject: Add blueprint runtime validator Change-Id: I9e2aa1aec392fc4191d547115fa90e8811f0f9e9 Issue-ID: CCSDK-1110 Signed-off-by: Muthuramalingam, Brinda Santh --- .../baseconfiguration/Definitions/node_types.json | 52 ++++++++++++++++++++++ .../starter-type/node_type/source-primary-db.json | 4 ++ 2 files changed, 56 insertions(+) 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 3912a472d..b2ba348a4 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 @@ -208,6 +208,54 @@ }, "derived_from": "tosca.nodes.ResourceSource" }, + "source-primary-db": { + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "query": { + "required": true, + "type": "string" + }, + "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" + }, "source-rest": { "description": "This is Rest Resource Source Node Type", "version": "1.0.0", @@ -224,6 +272,10 @@ ], "default": "JSON" }, + "endpoint-selector": { + "required": false, + "type": "string" + }, "url-path": { "required": true, "type": "string" diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json b/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json index 661a9503b..702748f8a 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json +++ b/components/model-catalog/definition-type/starter-type/node_type/source-primary-db.json @@ -14,6 +14,10 @@ } ] }, + "endpoint-selector": { + "required": false, + "type": "string" + }, "query": { "required": true, "type": "string" -- cgit 1.2.3-korg From 1f6fd9370efaa9c24b95a50ffdbd59d3409a9ea0 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 27 Feb 2019 20:47:17 -0500 Subject: Upgrade spring and kotlin versions Change-Id: Ie02db28a857f6aa53eed0d578407c09fb57298a0 Issue-ID: CCSDK-1111 Signed-off-by: Muthuramalingam, Brinda Santh --- components/parent/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 94a06a1fd..1d633efe6 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -30,10 +30,10 @@ pom 1.8 - 2.1.2.RELEASE - 5.1.4.RELEASE - 1.3.20 - 1.3.20 + 2.1.3.RELEASE + 5.1.5.RELEASE + 1.3.21 + 1.3.21 1.1.1 1.18.0 3.6.1 -- cgit 1.2.3-korg From a1c4477bfe00531af77fb71e8a2c6066b165ae55 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 8 Mar 2019 16:57:08 -0500 Subject: Add JSON type validation and enrichment Change-Id: I479b8214c7979dd5bc28acac68f747f06f3f231e Issue-ID: CCSDK-1134 Signed-off-by: Muthuramalingam, Brinda Santh --- .../Definitions/activation-blueprint.json | 23 +++++++++++++--------- .../baseconfiguration/Definitions/node_types.json | 15 ++++++++++++++ .../node_type/component-jython-executor.json | 5 +++++ .../node_type/component-netconf-executor.json | 5 +++++ .../node_type/component-resource-resolution.json | 5 +++++ .../node_type/component-restconf-executor.json | 5 +++++ 6 files changed, 49 insertions(+), 9 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 6025dbd6d..7a9239819 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 @@ -24,19 +24,23 @@ "file": "Definitions/policy_types.json" } ], - "dsl_definitions" : { + "dsl_definitions": { + "dynamic-netconf-properties": { + "device-name": "netconf device", + "host-name": "sample-host" + }, "dynamic-rest-source": { - "type" : "basic-type", - "url" : "http://localhost:8080", - "userId" : { + "type": "basic-type", + "url": "http://localhost:8080", + "userId": { "get_input": "rest-user-name" } }, "dynamic-db-source": { - "type" : "maria-db", - "url" : "jdbc:mysql://localhost:3306/sdnctl", - "username" : "sdnctl", - "password" : { + "type": "maria-db", + "url": "jdbc:mysql://localhost:3306/sdnctl", + "username": "sdnctl", + "password": { "get_attribute": [ "BPP", "dynamic-db-source.password" @@ -241,7 +245,8 @@ "script-type": "jython", "script-class-reference": "Scripts/python/NetconfRpcExample.py", "instance-dependencies": [ - ] + ], + "dynamic-properties": "*dynamic-netconf-properties" }, "outputs": { "response-data": "", 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 b2ba348a4..8f6c44f94 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 @@ -20,6 +20,11 @@ "entry_schema": { "type": "string" } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" } }, "outputs": { @@ -87,6 +92,11 @@ "entry_schema": { "type": "string" } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" } }, "outputs": { @@ -153,6 +163,11 @@ "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": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json index af8aae12e..5a024a7d6 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-jython-executor.json @@ -18,6 +18,11 @@ "entry_schema": { "type": "string" } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" } }, "outputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index e5cb4cba0..7e429c011 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -50,6 +50,11 @@ "entry_schema": { "type": "string" } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" } }, "outputs": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json index 5dbef4dcc..f437a79a9 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-resolution.json @@ -54,6 +54,11 @@ "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": { diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json index 192ed2566..cb28a4a10 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-restconf-executor.json @@ -38,6 +38,11 @@ "entry_schema": { "type": "string" } + }, + "dynamic-properties": { + "description": "Dynamic Json Content or DSL Json reference.", + "required": false, + "type": "json" } }, "outputs": { -- cgit 1.2.3-korg From 0df592839717bd316ee5d9e866418072ff543cd8 Mon Sep 17 00:00:00 2001 From: ottero Date: Mon, 11 Mar 2019 14:03:09 +0000 Subject: Blueprint for configuring a PNF This is the first version of a blueprint, intended to be used to configure PNFs. The design considers that a blueprint will be created for each possible PNF. Change-Id: I4994149441257eb417b6d5f611e12cd81595177f Issue-ID: CCSDK-1107 Signed-off-by: ottero --- .../Definitions/activation-blueprint.json | 73 +++++-------------- .../Definitions/data_types.json | 25 +++---- .../Definitions/node_types.json | 83 +--------------------- .../Definitions/relationship_types.json | 8 +-- .../Definitions/resources_definition_types.json | 17 +---- .../Plans/CONFIG_configAssign.xml | 4 -- .../capability_restconf/Plans/CONFIG_configure.xml | 4 -- .../Scripts/RestconfAssignConfig.kts | 1 - .../Scripts/RestconfConfigure.kts | 1 - .../Scripts/python/RestconfAssignConfig.py | 38 ++++++++++ .../Scripts/python/RestconfConfigure.py | 38 ++++++++++ .../capability_restconf/TOSCA-Metada/TOSCA.meta | 5 -- .../capability_restconf/TOSCA-Metadata/TOSCA.meta | 5 ++ .../Templates/config-assign-pnf-mapping.json | 15 +--- .../Templates/configure-pnf-mapping.json | 37 +--------- .../configure-restconf-mount-template.vtl | 8 +-- 16 files changed, 115 insertions(+), 247 deletions(-) delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metadata/TOSCA.meta diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json index 96ae88e59..90b2e3ab0 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json @@ -1,16 +1,10 @@ - { "tosca_definitions_version" : "controller_blueprint_1_0_0", "metadata" : { "template_author" : "Rodrigo Ottero", "author-email" : "rodrigo.ottero@est.tech", "user-groups" : "ADMIN, OPERATION", - "template_name" : "pnf restconf", + "template_name" : "configuration_over_restconf", "template_version" : "1.0.0", "template_tags" : "pnf, restconf, config, configuration" }, @@ -90,15 +84,10 @@ } } }, + + "config-assign" : { "type" : "component-restconf-executor", - "requirements" : { - "restconf-connection" : { - "capability" : "restconf", - "node" : "sample-restconf-server", - "relationship" : "tosca.relationships.ConnectsTo" - } - }, "interfaces" : { "ComponentRestconfExecutor" : { "operations" : { @@ -107,12 +96,9 @@ "primary" : "component-script" }, "inputs" : { - "script-type" : "kotlin", - "script-class-reference" : "Scripts/kotlin/RestconfAssignConfig.kts", - "instance-dependencies" : [ ], - "artifact-prefix-names": [ - "config-assign" - ] + "script-type" : "jython", + "script-class-reference" : "Scripts/python/RestconfAssignConfig.py", + "instance-dependencies" : [ ] }, "outputs" : { "response-data" : "", @@ -132,11 +118,14 @@ "file" : "Templates/config-assign-pnf-mapping.json" }, "component-script" : { - "type" : "artifact-script-kotlin", - "file" : "Scripts/kotlin/RestconfAssignConfig.py" + "type" : "artifact-script-jython", + "file" : "Scripts/python/RestconfAssignConfig.py" } } }, + + + "configure-process" : { "type" : "dg-generic", "properties" : { @@ -154,13 +143,6 @@ }, "configure" : { "type" : "component-restconf-executor", - "requirements" : { - "restconf-connection" : { - "capability" : "restconf", - "node" : "sample-restconf-server", - "relationship" : "tosca.relationships.ConnectsTo" - } - }, "interfaces" : { "ComponentRestconfExecutor" : { "operations" : { @@ -169,12 +151,9 @@ "primary" : "component-script" }, "inputs" : { - "script-type" : "kotlin", - "script-class-reference" : "Scripts/kotlin/RestconfConfigure.kts", - "instance-dependencies" : [ ], - "artifact-prefix-names": [ - "configure-restconf-mount", "configure-restconf-unmount" - ] + "script-type" : "jython", + "script-class-reference" : "Scripts/python/RestconfConfigure.py", + "instance-dependencies" : [ ] }, "outputs" : { "response-data" : "", @@ -198,28 +177,8 @@ "file" : "Templates/configure-pnf-mapping.json" }, "component-script" : { - "type" : "artifact-script-kotlin", - "file" : "Scripts/kotlin/RestconfConfigure.py" - } - } - }, - "sample-restconf-device" : { - "type" : "pnf-netconf-device", - "capabilities" : { - "restconf" : { - "properties" : { - "login-key" : { - "get_input" : "password" - }, - "login-account" : { - "get_input" : "username" - }, - "target-ip-address" : { - "get_input" : "ip" - }, - "port-number" : 830, - "connection-time-out" : 5 - } + "type" : "artifact-script-jython", + "file" : "Scripts/python/RestconfConfigure.py" } } } diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json index d9153f3f0..9f35eef88 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json @@ -1,22 +1,15 @@ { "data_types" : { - "dt-assign-activate-properties" : { - "description" : "Dynamic DataType definition for workflow(assign-activate).", + "dt-config-assign-properties" : { + "description" : "Dynamic DataType definition for workflow(config-assign).", "version" : "1.0.0", - "properties" : { - "hostname" : { - "type" : "string" - }, - "ip": { - "type": "string" - }, - "username": { - "type": "string" - }, - "password": { - "type": "string" - } - }, + "properties" : { }, + "derived_from" : "tosca.datatypes.Dynamic" + }, + "dt-configure-properties" : { + "description" : "Dynamic DataType definition for workflow(configure).", + "version" : "1.0.0", + "properties" : { }, "derived_from" : "tosca.datatypes.Dynamic" } } diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json index c8e3e6a93..be3bd319a 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json @@ -1,20 +1,13 @@ { "node_types" : { "component-restconf-executor" : { - "description" : "This is Restconf Configuration Component API", + "description" : "This is Restconf Transaction Configuration Component API", "version" : "1.0.0", "capabilities" : { "component-node" : { "type" : "tosca.capabilities.Node" } }, - "requirements" : { - "restconf-connection" : { - "capability" : "restconf", - "node" : "pnf-restconf-device", - "relationship" : "tosca.relationships.ConnectsTo" - } - }, "interfaces" : { "ComponentRestconfExecutor" : { "operations" : { @@ -80,24 +73,6 @@ }, "derived_from" : "tosca.nodes.DG" }, - "source-input" : { - "description" : "This is Input Resource Source Node Type", - "version" : "1.0.0", - "properties" : { - "key" : { - "required" : false, - "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", @@ -107,62 +82,6 @@ "description" : "This is Directed Graph Node Type", "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.Vnf" : { - "description" : "This is VNF Node Type", - "version" : "1.0.0", - "derived_from" : "tosca.nodes.Root" - }, - "tosca.nodes.Pnf": { - "description": "This is the PNF Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "pnf-restconf-device" : { - "description" : "This is a PNF Device with Restconf Capability", - "version" : "1.0.0", - "capabilities" : { - "netconf" : { - "type" : "tosca.capabilities.Restconf", - "properties" : { - "login-key" : { - "required" : true, - "type" : "string", - "default" : "sdnc" - }, - "login-account" : { - "required" : true, - "type" : "string", - "default" : "sdnc-tacacs" - }, - "source" : { - "required" : false, - "type" : "string", - "default" : "npm" - }, - "target-ip-address" : { - "required" : true, - "type" : "string" - }, - "port-number" : { - "required" : true, - "type" : "integer", - "default" : 830 - }, - "connection-time-out" : { - "required" : false, - "type" : "integer", - "default" : 30 - } - } - } - }, - "derived_from" : "tosca.nodes.Pnf" } } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json index 027bfc0fc..4ddd7a57c 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json @@ -1,9 +1,3 @@ { - "relationship_types" : { - "tosca.relationships.ConnectsTo" : { - "description" : "Relationship tosca.relationships.ConnectsTo", - "version" : "1.0.0", - "derived_from" : "tosca.relationships.Root" - } - } + "relationship_types" : { } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json index b77f451ad..6f31cf5a2 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json @@ -1,16 +1 @@ -{ - "hostname" : { - "tags" : "hostname", - "name" : "hostname", - "property" : { - "description" : "hostname", - "type" : "string" - }, - "updated-by" : "Singal, Kapil ", - "sources" : { - "input" : { - "type" : "source-input" - } - } - } -} \ No newline at end of file +{ } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml index 417f72de9..220cba9f7 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml @@ -1,7 +1,3 @@ - - diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml index 94fe6dde0..c48ffbed4 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml @@ -1,7 +1,3 @@ - - diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts deleted file mode 100644 index a0990367e..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts +++ /dev/null @@ -1 +0,0 @@ -TBD diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts deleted file mode 100644 index a0990367e..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts +++ /dev/null @@ -1 +0,0 @@ -TBD diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py new file mode 100644 index 000000000..36dd32ffc --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py @@ -0,0 +1,38 @@ +# ============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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + + +from org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor import \ + RestconfComponentFunction + + +class RestconfAssignConfig(RestconfComponentFunction): + + + def process(self, execution_request): + # create instances of the needed objects + # retrieve any needed information not present on the request, like pnf ip + # create the configlet + # persist the configlet + # end + print("process", execution_request) + + + def recover(self, runtime_exception, execution_request): + print("recover") + return None \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py new file mode 100644 index 000000000..c584baa9b --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py @@ -0,0 +1,38 @@ +# ============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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + + +from org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor import \ + RestconfComponentFunction + + +class RestconfConfigure(RestconfComponentFunction): + + + def process(self, execution_request): + # create instances of the needed objects + # retrieve any needed information not present on the request, like pnf ip + # retrieve the configlet + # send the configlet + # end + print("process", execution_request) + + + def recover(self, runtime_exception, execution_request): + print("recover") + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta deleted file mode 100644 index 6ac9caf57..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta +++ /dev/null @@ -1,5 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: Rodrigo Ottero -Entry-Definitions: Definitions/activation-blueprint.json -Template-Tags: activation-blueprint diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..6ac9caf57 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,5 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Rodrigo Ottero +Entry-Definitions: Definitions/activation-blueprint.json +Template-Tags: activation-blueprint diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json index 85533abc5..41b42e677 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json @@ -1,16 +1,3 @@ - [ - { - "name": "odl_host", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "odl_host", - "dictionary-source": "capability", - "dependencies": [ - ] - } + ] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json index 123680c0c..41b42e677 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json @@ -1,38 +1,3 @@ - [ - { - "name": "pnf_id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "pnf_id", - "dictionary-source": "capability", - "dependencies": [ - ] - }, - { - "name": "pnf_ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "pnf_ip", - "dictionary-source": "capability", - "dependencies": [ - ] - }, - { - "name": "pnf_ip_port", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "pnf_ip_port", - "dictionary-source": "capability", - "dependencies": [ - ] - } + ] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl index 17f7a3679..a899aa45c 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl @@ -1,14 +1,14 @@ - $pnf_id + $pnf-id ODL-private-key netconf - $pnf_ip - $pnf_ip_port + $pnf-ip + 6513 false TLS - 2 + 5 -- cgit 1.2.3-korg From 9e6da2d51f8c45aa3fdd1d3a5c535bd98119e8c5 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 11 Mar 2019 11:41:37 -0400 Subject: Refractor processor core module name Change-Id: Ic4a40d6cbc5e53e79ddc36bea529fe16f6210a26 Issue-ID: CCSDK-1136 Signed-off-by: Muthuramalingam, Brinda Santh --- .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 ---------------------- .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 4 +- 2 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn deleted file mode 100644 index 89ae342f8..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn +++ /dev/null @@ -1,66 +0,0 @@ - - - - - SequenceFlow_0l0dq58 - - - SequenceFlow_1ay0k6p - - - - - - - - - - SequenceFlow_0l0dq58 - SequenceFlow_1ay0k6p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta index 9066e4845..8f1df9f2a 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta @@ -1,8 +1,6 @@ TOSCA-Meta-File-Version: 1.0.0 CSAR-Version: 1.0 -Created-By: Brinda Santh M +Created-By: Brinda Santh Entry-Definitions: Definitions/activation-blueprint.json Template-Tags: Brinda Santh, activation-blueprint -Name: Plans/ActivateProcess.bpmn -Content-Type: application/vnd.oasis.bpmn -- cgit 1.2.3-korg From 51da489d08f63d3ac8f176609d442bcf7f7a04bd Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Fri, 8 Mar 2019 13:41:18 -0500 Subject: Enhance / fix REST resource resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - provide sync web client - add support for VERB - add support for payload - fix URI resolution from input-key-mapping Change-Id: Id4f1973a15778ad4f2ab0f7e2a4b2c61054a234d Issue-ID: CCSDK-1131 Signed-off-by: Alexis de Talhouët --- .../starter-type/node_type/source-rest.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 044983040..b28e9341d 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,23 @@ } ] }, + "verb": { + "required": false, + "type": "string", + "default": "GET", + "constraints": [ + { + "valid_values": [ + "GET", "POST", "DELETE", "PUT" + ] + } + ] + }, + "payload": { + "required": false, + "type": "string", + "default": "" + }, "endpoint-selector": { "required": false, "type": "string" -- cgit 1.2.3-korg From 1a19d33abd1c6afda3b064da022bb77ddf13d5cf Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 11 Mar 2019 22:22:30 -0400 Subject: Add support to invoke device specific RPC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia003ed669cc88a4c24a495e79db620b5034bc3ca Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët --- components/scripts/python/ccsdk_netconf/netconfclient.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py index d898ec009..e263ba8f7 100644 --- a/components/scripts/python/ccsdk_netconf/netconfclient.py +++ b/components/scripts/python/ccsdk_netconf/netconfclient.py @@ -41,6 +41,10 @@ class NetconfClient: persist, persist_id) return device_response + def invoke_rpc(self, rpc): + device_response = self.netconf_rpc_client.invokeRpc(rpc) + return device_response + def cancel_commit(self, persist_id=""): device_response = self.netconf_rpc_client.cancelCommit(persist_id) return device_response -- cgit 1.2.3-korg From 1746f00c7134f0bba8cfd2b4a00030b07f231ed1 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 12 Mar 2019 16:49:54 -0400 Subject: Add intial test CBA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If7c18e8ad472cebc3e36858fcb0cdf4c7ef6d52d Issue-ID: CCSDK-1149 Signed-off-by: Alexis de Talhouët --- .../golden/Definitions/activation-blueprint.json | 333 +++++++++++++++++ .../golden/Definitions/artifact_types.json | 22 ++ .../golden/Definitions/data_types.json | 106 ++++++ .../golden/Definitions/node_types.json | 413 +++++++++++++++++++++ .../golden/Definitions/policy_types.json | 3 + .../golden/Definitions/relationship_types.json | 9 + .../Definitions/resources_definition_types.json | 148 ++++++++ .../test-blueprint/golden/Plans/ConfigDeploy.xml | 15 + .../golden/Plans/ResourceAssignment.xml | 22 ++ .../test-blueprint/golden/Plans/Rollback.xml | 15 + .../blueprint-model/test-blueprint/golden/README | 134 +++++++ .../golden/Scripts/python/DescriptionExample.py | 46 +++ .../golden/Scripts/python/NetconfRpcExample.py | 61 +++ .../golden/Scripts/python/Rollback.py | 47 +++ .../golden/Scripts/python/__init__.py | 0 .../golden/TOSCA-Metadata/TOSCA.meta | 6 + .../golden/Templates/hostname-mapping.json | 13 + .../golden/Templates/hostname-template.vtl | 7 + .../Templates/junos-rollback-RPC-mapping.json | 1 + .../Templates/junos-rollback-RPC-template.vtl | 3 + .../golden/Templates/vf-module-1-mapping.json | 64 ++++ .../golden/Templates/vf-module-1-template.vtl | 4 + .../golden/Templates/vfw-interface-mapping.json | 88 +++++ .../golden/Templates/vfw-interface-template.vtl | 18 + .../starter-type/data_type/dt-netbox-ip.json | 15 + .../test-dictionary/create_netbox_ip.json | 29 ++ .../test-dictionary/delete_netbox_ip.json | 30 ++ .../test-dictionary/hostname.json | 14 + .../test-dictionary/interface-description.json | 21 ++ .../test-dictionary/interface-name.json | 15 + .../test-dictionary/prefix-id.json | 16 + .../test-dictionary/unit-number.json | 14 + .../test-dictionary/vf-module-number.json | 16 + .../test-dictionary/vf-module-type.json | 27 ++ 34 files changed, 1775 insertions(+) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/artifact_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/policy_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/relationship_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/README create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-template.vtl create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-template.vtl create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-template.vtl create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-template.vtl create mode 100644 components/model-catalog/definition-type/starter-type/data_type/dt-netbox-ip.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/create_netbox_ip.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/delete_netbox_ip.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/hostname.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/interface-description.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/interface-name.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/prefix-id.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/unit-number.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/vf-module-number.json create mode 100644 components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json 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 new file mode 100644 index 000000000..b6464f3c8 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json @@ -0,0 +1,333 @@ +{ + "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/artifact_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/artifact_types.json new file mode 100644 index 000000000..6ec3b4105 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/artifact_types.json @@ -0,0 +1,22 @@ +{ + "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-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/test-blueprint/golden/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json new file mode 100644 index 000000000..d60e6f00c --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json @@ -0,0 +1,106 @@ +{ + "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" + } + }, + "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.Root" + }, + "dt-resource-assignment-properties" : { + "description" : "Dynamic DataType definition for workflow(resource-assignment).", + "version" : "1.0.0", + "properties" : { + "hostname" : { + "type" : "string" + }, + "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" + }, + "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" + } + }, + "derived_from" : "tosca.datatypes.Dynamic" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json new file mode 100644 index 000000000..b05869217 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json @@ -0,0 +1,413 @@ +{ + "node_types" : { + "component-netconf-executor" : { + "description" : "This is Netconf Transaction Configuration Component API", + "version" : "1.0.0", + "capabilities" : { + "component-node" : { + "type" : "tosca.capabilities.Node" + } + }, + "requirements" : { + "netconf-connection" : { + "capability" : "netconf", + "node" : "vnf-netconf-device", + "relationship" : "tosca.relationships.ConnectsTo" + } + }, + "interfaces" : { + "ComponentNetconfExecutor" : { + "operations" : { + "process" : { + "inputs" : { + "script-type" : { + "description" : "Script type, kotlin type is supported", + "required" : true, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "kotlin", "jython", "internal" ] + } ], + "default" : "internal" + }, + "dynamic-properties" : { + "description" : "Dynamic Json Content or DSL Json reference.", + "required" : false, + "type" : "json" + }, + "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" + } + } + }, + "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" + }, + "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" + }, + "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" + }, + "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.DG" + }, + "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-default" : { + "description" : "This is Default Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "key" : { + "required" : false, + "type" : "string" + }, + "key-dependencies" : { + "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", + "properties" : { + "key" : { + "required" : false, + "type" : "string" + }, + "key-dependencies" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "derived_from" : "tosca.nodes.ResourceSource" + }, + "source-primary-db" : { + "description" : "This is Database Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "type" : { + "required" : true, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "SQL", "PLSQL" ] + } ] + }, + "endpoint-selector" : { + "required" : false, + "type" : "string" + }, + "query" : { + "required" : true, + "type" : "string" + }, + "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" + }, + "source-rest" : { + "description" : "This is Rest Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "type" : { + "required" : false, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON" ] + } ], + "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" + }, + "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.DG" : { + "description" : "This is Directed Graph Node Type", + "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.Vnf" : { + "description" : "This is VNF Node Type", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "vnf-netconf-device" : { + "description" : "This is VNF Device with Netconf Capability", + "version" : "1.0.0", + "capabilities" : { + "netconf" : { + "type" : "tosca.capabilities.Netconf", + "properties" : { + "login-key" : { + "required" : true, + "type" : "string", + "default" : "sdnc" + }, + "login-account" : { + "required" : true, + "type" : "string", + "default" : "sdnc-tacacs" + }, + "source" : { + "required" : false, + "type" : "string", + "default" : "npm" + }, + "target-ip-address" : { + "required" : true, + "type" : "string" + }, + "port-number" : { + "required" : true, + "type" : "integer", + "default" : 830 + }, + "connection-time-out" : { + "required" : false, + "type" : "integer", + "default" : 30 + } + } + } + }, + "derived_from" : "tosca.nodes.Vnf" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/policy_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/policy_types.json new file mode 100644 index 000000000..1e44cc70a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/policy_types.json @@ -0,0 +1,3 @@ +{ + "policy_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/relationship_types.json new file mode 100644 index 000000000..027bfc0fc --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/relationship_types.json @@ -0,0 +1,9 @@ +{ + "relationship_types" : { + "tosca.relationships.ConnectsTo" : { + "description" : "Relationship tosca.relationships.ConnectsTo", + "version" : "1.0.0", + "derived_from" : "tosca.relationships.Root" + } + } +} \ 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 new file mode 100644 index 000000000..446a8a681 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json @@ -0,0 +1,148 @@ +{ + "create_netbox_ip" : { + "tags" : "oam-local-ipv4-address", + "name" : "create_netbox_ip", + "property" : { + "description" : "netbox ip", + "type" : "dt-netbox-ip" + }, + "updated-by" : "adetalhouet", + "sources" : { + "primary-config-data" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "verb" : "POST", + "endpoint-selector" : "ipam-1", + "url-path" : "/api/ipam/prefixes/$prefix-id/available-ips/", + "path" : "", + "input-key-mapping" : { + "prefix-id" : "prefix-id" + }, + "output-key-mapping" : { + "address" : "address", + "id" : "id" + }, + "key-dependencies" : [ "prefix-id" ] + } + } + } + }, + "hostname" : { + "tags" : "hostname", + "name" : "hostname", + "property" : { + "description" : "hostname", + "type" : "string" + }, + "updated-by" : "adetalhouet", + "sources" : { + "input" : { + "type" : "source-input" + } + } + }, + "interface-description" : { + "tags" : "interface-description", + "name" : "interface-description", + "property" : { + "description" : "interface-description", + "type" : "string" + }, + "updated-by" : "adetalhouet", + "sources" : { + "capability" : { + "type" : "source-capability", + "properties" : { + "script-type" : "jython", + "script-class-reference" : "DescriptionExample", + "instance-dependencies" : [ ] + } + } + } + }, + "interface-name" : { + "tags" : "interface-name", + "name" : "interface-name", + "property" : { + "description" : "interface-name", + "type" : "string" + }, + "updated-by" : "adetalhouet", + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } + }, + "prefix-id" : { + "tags" : "prefix-id", + "name" : "prefix-id", + "property" : { + "description" : "prefix-id", + "type" : "integer" + }, + "updated-by" : "adetalhouet", + "sources" : { + "default" : { + "type" : "source-default", + "properties" : { } + } + } + }, + "unit-number" : { + "tags" : "unit-number", + "name" : "unit-number", + "property" : { + "description" : "unit-number", + "type" : "string" + }, + "updated-by" : "adetalhouet", + "sources" : { + "input" : { + "type" : "source-input" + } + } + }, + "vf-module-number" : { + "tags" : "vf-module-number", + "name" : "vf-module-number", + "property" : { + "description" : "vf-module-number", + "type" : "string" + }, + "updated-by" : "adetalhouet", + "sources" : { + "default" : { + "type" : "source-default", + "properties" : { } + } + } + }, + "vf-module-type" : { + "tags" : "vf-module-type", + "name" : "vf-module-type", + "property" : { + "description" : "vf-module-type", + "type" : "string" + }, + "updated-by" : "adetalhouet", + "sources" : { + "primary-db" : { + "type" : "source-primary-db", + "properties" : { + "type" : "SQL", + "query" : "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid", + "input-key-mapping" : { + "vfmoduleid" : "vf-module-number" + }, + "output-key-mapping" : { + "vf-module-type" : "value" + }, + "key-dependencies" : [ "vf-module-number" ] + } + } + } + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..ec154a15b --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..15872e524 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..c1231d7a5 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 000000000..06f91123e --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/README @@ -0,0 +1,134 @@ + +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 + + resources + + Bellow a table of the resource used within this example, and how this resource + are resolved. + The resources are used in the context of device configuration. These shouldn't be + confused with SDC model resources. + + name | resolve through + ------------------------------------------------------ + prefix-id | default + vfw_interface_ip | rest (through Netbox) + hostname | input + vf-module-number | default + vf-module-type | database + unit-number | input + interface-name | input + interface-description | capability (python script) + + 3 workflow + + resource-assignment (dry-run) + + 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 + + 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. + + Here is the request payload: + + 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" + } + } + } + + Output: + + { + "resource-assignment-params": { + "hostname": "\n\n \n \n demo123\n \n\n", + "vf-module-1": "\n This is the Virtual Firewall entity\n 10.10.10.39/24\n" + }, + "status": "success" + } + + 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. + 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. + + Here is the request payload: + + resolution-key: To identify the configlet saved in the DB in previous step + username: NETCONF device user + password: NETCONF device password + ip: NETCONF device ip + 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", + "ip": "10.198.1.35", + "config-deploy-properties": { + "interface-name": "ge-0/0/7", + unit-number": "0" + } + } + + Output: + + No specific output beside success or failure. + + rollback + + This action will rollback the last committed config on the device, using NETCONF and device + 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. + + Here is the request payload: + + username: NETCONF device user + password: NETCONF device password + ip: NETCONF device ip + + { + "username": "pass", + "password": "user", + "ip": "10.10.10.10" + } + + 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. + + https://www.getpostman.com/collections/4d199ff02a735bd3e680 \ No newline at end of file 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 new file mode 100644 index 000000000..fce7c3249 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py @@ -0,0 +1,46 @@ +# Copyright (c) 2019 Bell Canada. +# +# 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. + +from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * +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" + + # 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 "NoOp" + return None 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/NetconfRpcExample.py new file mode 100644 index 000000000..ed22989fb --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py @@ -0,0 +1,61 @@ +# Copyright (c) 2019 Bell Canada. +# +# 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 netconf_constant +from common import ResolutionHelper +from java.lang import Exception as JavaException +from netconfclient import NetconfClient +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \ + NetconfComponentFunction + + +class NetconfRpcExample(NetconfComponentFunction): + + def process(self, execution_request): + try: + log = globals()[netconf_constant.SERVICE_LOG] + print(globals()) + + nc = NetconfClient(log, self, "netconf-connection") + rr = ResolutionHelper(self) + + # Get meshed template from DB + resolution_key = self.getDynamicProperties("resolution-key").asText() + artifact_name = "hostname" + payloadHostname = rr.retrieve_resolved_template_from_database(resolution_key, artifact_name) + + # resolve param and mesh template + payloadInterface = rr.resolve_and_generate_message_from_template_prefix("vfw-interface") + + nc.connect() + nc.lock() + #if not response.isSuccess(): + # og.error(response.errorMessage) + nc.discard_change() + nc.edit_config(message_content=payloadInterface, edit_default_peration="none") + nc.edit_config(message_content=payloadHostname, edit_default_peration="none") + nc.validate() + nc.commit() + #nc.commit(confirmed = True, confirm_timeout=15) + 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 "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + 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 new file mode 100644 index 000000000..73419d716 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py @@ -0,0 +1,47 @@ +# Copyright (c) 2019 Bell Canada. +# +# 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 netconf_constant +from common import ResolutionHelper +from java.lang import Exception as JavaException +from netconfclient import NetconfClient +from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \ + NetconfComponentFunction + + +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) + + # 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() + + 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 "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py new file mode 100644 index 000000000..e69de29bb 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 new file mode 100644 index 000000000..065eda192 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta @@ -0,0 +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 +Template-Tags: test +Content-Type: application/vnd.oasis.bpmn diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-mapping.json new file mode 100644 index 000000000..1e02d6900 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-mapping.json @@ -0,0 +1,13 @@ +[ + { + "name": "hostname", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "hostname", + "dictionary-source": "input", + "dependencies": [ + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-template.vtl new file mode 100644 index 000000000..1e80b6d1c --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-template.vtl @@ -0,0 +1,7 @@ + + + + + $hostname + + diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-mapping.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-mapping.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-template.vtl new file mode 100644 index 000000000..655a2b1c8 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-template.vtl @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json new file mode 100644 index 000000000..eba259e33 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json @@ -0,0 +1,64 @@ +[ + { + "name": "interface-description", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "interface-description", + "dictionary-source": "capability", + "dependencies": [ + "vf-module-type" + ] + }, + { + "name": "vf-module-type", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vf-module-type", + "dictionary-source": "primary-db", + "dependencies": [ + "vf-module-number" + ] + }, + { + "name": "vf-module-number", + "input-param": true, + "property": { + "type": "string", + "default": "3" + }, + "dictionary-name": "vf-module-number", + "dictionary-source": "default", + "dependencies": [ + + ] + }, + { + "name": "prefix-id", + "input-param": true, + "property": { + "type": "integer", + "default": 11 + }, + "dictionary-name": "prefix-id", + "dictionary-source": "default", + "dependencies": [ + + ] + }, + { + "name": "vfw_interface_ip", + "input-param": true, + "property": { + "type": "dt-netbox-ip" + }, + "dictionary-name": "create_netbox_ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "prefix-id" + ] + } +] \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-template.vtl new file mode 100644 index 000000000..9ba34a057 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-template.vtl @@ -0,0 +1,4 @@ + + $interface-description + $vfw_interface_ip.address + \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json new file mode 100644 index 000000000..149d3eb20 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json @@ -0,0 +1,88 @@ +[ + { + "name": "interface-description", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "interface-description", + "dictionary-source": "capability", + "dependencies": [ + "vf-module-type" + ] + }, + { + "name": "interface-name", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "interface-name", + "dictionary-source": "input", + "dependencies": [ + + ] + }, + { + "name": "unit-number", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "unit-number", + "dictionary-source": "input", + "dependencies": [ + + ] + }, + { + "name": "prefix-id", + "input-param": true, + "property": { + "type": "string", + "default": "11" + }, + "dictionary-name": "prefix-id", + "dictionary-source": "default", + "dependencies": [ + + ] + }, + { + "name": "vf-module-type", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "vf-module-type", + "dictionary-source": "primary-db", + "dependencies": [ + "vf-module-number" + ] + }, + { + "name": "vf-module-number", + "input-param": true, + "property": { + "type": "string", + "default": "3" + }, + "dictionary-name": "vf-module-number", + "dictionary-source": "default", + "dependencies": [ + + ] + }, + { + "name": "vfw_interface_ip", + "input-param": true, + "property": { + "type": "dt-netbox-ip" + }, + "dictionary-name": "create_netbox_ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "prefix-id" + ] + } +] \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-template.vtl new file mode 100644 index 000000000..3223535e5 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-template.vtl @@ -0,0 +1,18 @@ + + + + $interface-name + + $unit-number + $interface-description + + +
+ $vfw_interface_ip.address +
+
+
+
+
+
+
\ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/data_type/dt-netbox-ip.json b/components/model-catalog/definition-type/starter-type/data_type/dt-netbox-ip.json new file mode 100644 index 000000000..81c908d62 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/data_type/dt-netbox-ip.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0", + "description": "This is Netbox IP Data Type", + "properties": { + "address": { + "required": true, + "type": "string" + }, + "id": { + "required": true, + "type": "integer" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/create_netbox_ip.json b/components/model-catalog/resource-dictionary/test-dictionary/create_netbox_ip.json new file mode 100644 index 000000000..297a8ef87 --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/create_netbox_ip.json @@ -0,0 +1,29 @@ +{ + "tags" : "oam-local-ipv4-address", + "name" : "create_netbox_ip", + "property" : { + "description" : "netbox ip", + "type" : "dt-netbox-ip" + }, + "updated-by" : "adetalhouet", + "sources" : { + "primary-config-data" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "verb" : "POST", + "endpoint-selector" : "ipam-1", + "url-path" : "/api/ipam/prefixes/$prefix-id/available-ips/", + "path" : "", + "input-key-mapping" : { + "prefix-id" : "prefix-id" + }, + "output-key-mapping" : { + "address" : "address", + "id" : "id" + }, + "key-dependencies" : [ "prefix-id" ] + } + } + } + } \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/delete_netbox_ip.json b/components/model-catalog/resource-dictionary/test-dictionary/delete_netbox_ip.json new file mode 100644 index 000000000..35a8a351c --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/delete_netbox_ip.json @@ -0,0 +1,30 @@ +{ + "tags": "oam-local-ipv4-address", + "name": "delete_netbox_ip", + "property": { + "description": "delete netbox ip", + "type": "string" + }, + "updated-by": "adetalhouet", + "sources": { + "primary-config-data": { + "type": "source-rest", + "properties": { + "type": "JSON", + "verb": "DELETE", + "endpoint-selector": "ipam-1", + "url-path": "/api/ipam/ip-addresses/$ip-address-id", + "path": "/address", + "input-key-mapping": { + "ip-address-id": "ip-address-id" + }, + "output-key-mapping": { + + }, + "key-dependencies": [ + "ip-address-id" + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/hostname.json b/components/model-catalog/resource-dictionary/test-dictionary/hostname.json new file mode 100644 index 000000000..025cce336 --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/hostname.json @@ -0,0 +1,14 @@ +{ + "tags": "hostname", + "name": "hostname", + "property": { + "description": "hostname", + "type": "string" + }, + "updated-by": "adetalhouet", + "sources": { + "input": { + "type": "source-input" + } + } + } \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/interface-description.json b/components/model-catalog/resource-dictionary/test-dictionary/interface-description.json new file mode 100644 index 000000000..d13bfc44b --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/interface-description.json @@ -0,0 +1,21 @@ +{ + "tags": "interface-description", + "name": "interface-description", + "property": { + "description": "interface-description", + "type": "string" + }, + "updated-by": "adetalhouet", + "sources": { + "capability": { + "type": "source-capability", + "properties": { + "script-type": "jython", + "script-class-reference": "DescriptionExample", + "instance-dependencies": [ + + ] + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/interface-name.json b/components/model-catalog/resource-dictionary/test-dictionary/interface-name.json new file mode 100644 index 000000000..53a11ed70 --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/interface-name.json @@ -0,0 +1,15 @@ +{ + "name" : "interface-name", + "tags" : "interface-name", + "updated-by" : "adetalhouet", + "property" : { + "description" : "interface-name", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/prefix-id.json b/components/model-catalog/resource-dictionary/test-dictionary/prefix-id.json new file mode 100644 index 000000000..e515eca55 --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/prefix-id.json @@ -0,0 +1,16 @@ +{ + "tags": "prefix-id", + "name": "prefix-id", + "property" :{ + "description": "prefix-id", + "type": "integer" + }, + "updated-by": "adetalhouet", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/unit-number.json b/components/model-catalog/resource-dictionary/test-dictionary/unit-number.json new file mode 100644 index 000000000..333fd78eb --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/unit-number.json @@ -0,0 +1,14 @@ +{ + "tags": "unit-number", + "name": "unit-number", + "property": { + "description": "unit-number", + "type": "string" + }, + "updated-by": "adetalhouet", + "sources": { + "input": { + "type": "source-input" + } + } + } \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/vf-module-number.json b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-number.json new file mode 100644 index 000000000..cdd40f669 --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-number.json @@ -0,0 +1,16 @@ +{ + "tags": "vf-module-number", + "name": "vf-module-number", + "property" :{ + "description": "vf-module-number", + "type": "string" + }, + "updated-by": "adetalhouet", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json new file mode 100644 index 000000000..b06057c45 --- /dev/null +++ b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json @@ -0,0 +1,27 @@ +{ + "name": "vf-module-type", + "tags": "vf-module-type", + "property": { + "description": "vf-module-type", + "type": "string" + }, + "updated-by": "adetalhouet", + "sources": { + "primary-db": { + "type": "source-primary-db", + "properties": { + "type": "SQL", + "query": "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid", + "input-key-mapping": { + "vfmoduleid": "vf-module-number" + }, + "output-key-mapping": { + "vf-module-type": "value" + }, + "key-dependencies": [ + "vf-module-number" + ] + } + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From bffb79d389970b1fb96ea6ee6f0414c460691d5f Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Fri, 22 Feb 2019 16:22:59 -0500 Subject: Python lib for RA and component executor Change-Id: Iacec0dbbd3e7c1dc955ac913f346365732248f05 Issue-ID: CCSDK-1091 Signed-off-by: Steve Alphonse Siani --- .../capability_python/Definitions/activation-blueprint.json | 2 +- .../starter-dictionary/service-instance-id.json | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json index 168732c1d..b02397e85 100755 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Definitions/activation-blueprint.json @@ -119,7 +119,7 @@ "artifacts" : { "component-script" : { "type" : "artifact-script-jython", - "file" : "Scripts/SamplePythonComponentNode.py" + "file" : "Scripts/python/SamplePythonComponentNode.py" } } } diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json index cb9704350..737c7577b 100755 --- a/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/service-instance-id.json @@ -32,6 +32,14 @@ "service-instance-id": "artifact_name" } } + }, + "capability": { + "type": "source-capability", + "properties": { + "script-type": "jython", + "script-class-reference": "SampleRAProcessor", + "instance-dependencies": [] + } } } } \ No newline at end of file -- cgit 1.2.3-korg From 6afa8a4b2ef4f6fa01e3858ed192bf99bea18778 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 14 Mar 2019 13:55:01 -0400 Subject: Prepare for release 0.4.1 Prepare to create release version 0.4.1 by using released version of parent pom Change-Id: Icf8432e14626a55b916b6f4d4a8992b79c29eff7 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- components/model-catalog/proto-definition/pom.xml | 5 ++--- components/parent/pom.xml | 3 +-- components/pom.xml | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml index 4680f6291..35fc9a9a1 100644 --- a/components/model-catalog/proto-definition/pom.xml +++ b/components/model-catalog/proto-definition/pom.xml @@ -15,8 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps @@ -84,4 +83,4 @@ - \ No newline at end of file + diff --git a/components/parent/pom.xml b/components/parent/pom.xml index 1d633efe6..dd74622dd 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -16,8 +16,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps diff --git a/components/pom.xml b/components/pom.xml index c18e968fe..1915fecf7 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -15,8 +15,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + org.onap.ccsdk.apps ccsdk-apps -- cgit 1.2.3-korg From c4f36ee4781ab90d343a0fe9d4f75da6ad8d970c Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 15 Mar 2019 17:07:19 -0400 Subject: Add workflow node template enrichment Change-Id: I15c2db6ab81bae2176d1606157f13416c1fac660 Issue-ID: CCSDK-1168 Signed-off-by: Muthuramalingam, Brinda Santh --- .../Definitions/artifact_types.json | 3 + .../Definitions/component_invoke.json | 88 ++++++++++++++++++++++ .../component_invoke/Definitions/data_types.json | 3 + .../component_invoke/Definitions/node_types.json | 54 +++++++++++++ .../component_invoke/Definitions/policy_types.json | 3 + .../Definitions/relationship_types.json | 3 + .../Definitions/resources_definition_types.json | 1 + .../component_invoke/TOSCA-Metadata/TOSCA.meta | 5 ++ .../node_type/component-netconf-executor.json | 5 -- .../node_type/component-sample-executor.json | 45 +++++++++++ 10 files changed, 205 insertions(+), 5 deletions(-) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/artifact_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/data_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/node_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/policy_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/relationship_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/resources_definition_types.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/component_invoke/TOSCA-Metadata/TOSCA.meta create mode 100644 components/model-catalog/definition-type/starter-type/node_type/component-sample-executor.json diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/artifact_types.json new file mode 100644 index 000000000..eadc848be --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/artifact_types.json @@ -0,0 +1,3 @@ +{ + "artifact_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json new file mode 100644 index 000000000..eeb9815fa --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json @@ -0,0 +1,88 @@ +{ + "tosca_definitions_version": "controller_blueprint_1_0_0", + "metadata": { + "template_author": "Brinda Santh ", + "template_name": "component_invoke", + "template_version": "1.0.0", + "template_tags": "brinda, component_invoke" + }, + "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" + } + ], + "topology_template": { + "workflows": { + "component-invoke": { + "steps": { + "activate-process": { + "description": "Sample Component Invocation flow", + "target": "sample-component", + "activities": [ + { + "call_operation": "sample-component" + } + ] + } + }, + "inputs": { + "request-id": { + "required": true, + "type": "string" + }, + "action-name": { + "required": true, + "type": "string" + }, + "scope-type": { + "required": true, + "type": "string" + }, + "hostname": { + "required": true, + "type": "string" + } + } + } + }, + "node_templates": { + "sample-component": { + "type": "component-sample-executor", + "interfaces": { + "ComponentSampleExecutor": { + "operations": { + "process": { + "inputs": { + "sample-property": "sample-value", + "sample-list-property": [ + "json-parser-service" + ], + "dynamic-properties": { + "prop1": "prop1-value", + "prop2": "prop2-value" + } + }, + "outputs": { + "response-data": "", + "status": "" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/data_types.json new file mode 100644 index 000000000..8c304c40b --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/data_types.json @@ -0,0 +1,3 @@ +{ + "data_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/node_types.json new file mode 100644 index 000000000..1e02cef4a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/node_types.json @@ -0,0 +1,54 @@ +{ + "node_types": { + "component-sample-executor": { + "description": "This is Sample Component API", + "version": "1.0.0", + "interfaces": { + "ComponentSampleExecutor": { + "operations": { + "process": { + "inputs": { + "sample-property": { + "description": "Sample Property.", + "required": true, + "type": "string" + }, + "sample-list-property": { + "description": "Dependent Step Components NodeTemplate name.", + "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" + }, + "tosca.nodes.Component": { + "description": "This is default Component Node", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/policy_types.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/policy_types.json new file mode 100644 index 000000000..1e44cc70a --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/policy_types.json @@ -0,0 +1,3 @@ +{ + "policy_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/relationship_types.json new file mode 100644 index 000000000..4ddd7a57c --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/relationship_types.json @@ -0,0 +1,3 @@ +{ + "relationship_types" : { } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/resources_definition_types.json new file mode 100644 index 000000000..6f31cf5a2 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/resources_definition_types.json @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/TOSCA-Metadata/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 000000000..a7c130a23 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,5 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Brinda Santh +Entry-Definitions: Definitions/component_invoke.json +Template-Tags: Brinda Santh, component_invoke \ No newline at end of file diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json index 7e429c011..3233d2121 100644 --- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json +++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json @@ -33,11 +33,6 @@ } ] }, - "dynamic-properties": { - "description": "Resolvable dynamic property.", - "required": false, - "type": "string" - }, "script-class-reference": { "description": "Kotlin Script class name or jython script name.", "required": true, diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-sample-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-sample-executor.json new file mode 100644 index 000000000..68b3ebde2 --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/component-sample-executor.json @@ -0,0 +1,45 @@ +{ + "description": "This is Sample Component API", + "version": "1.0.0", + "interfaces": { + "ComponentSampleExecutor": { + "operations": { + "process": { + "inputs": { + "sample-property": { + "description": "Sample Property.", + "required": true, + "type": "string" + }, + "sample-list-property": { + "required": true, + "description": "Dependent Step Components NodeTemplate name.", + "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" +} \ No newline at end of file -- cgit 1.2.3-korg From 3ac0d20b08dd8c31ff85ad3ca5c53df11b6d96e4 Mon Sep 17 00:00:00 2001 From: ottero Date: Sun, 17 Mar 2019 19:38:32 +0000 Subject: Adding custom headers capability to REST client For YANG PATCH requests to ODL to work, they need to have a Content- type header of application/yang.patch+json and should not have Accept as application/json Current REST client inserts a default header to the requests with this content: Content-Type: application/json Accept: application/json The solution was to add the possibility of sending custom headers alon- gside the other parameters. Change-Id: I2cf0cd2ef7b87f4f5a246d427dffafe266cb33f7 Issue-ID: CCSDK-926 Signed-off-by: ottero --- .../Definitions/activation-blueprint.json | 115 +++++++++++---------- .../Definitions/config-assign-pnf-mapping.json | 13 +++ .../Definitions/config-deploy-pnf-mapping.json | 13 +++ .../Definitions/data_types.json | 16 ++- .../Definitions/node_types.json | 107 +++++++++++++++++++ .../Definitions/resources_definition_types.json | 18 +++- .../Plans/CONFIG_configDeploy.xml | 15 +++ .../capability_restconf/Plans/CONFIG_configure.xml | 15 --- .../Scripts/python/RestconfAssignConfig.py | 38 ------- .../Scripts/python/RestconfConfigDeploy.py | 112 ++++++++++++++++++++ .../Scripts/python/RestconfConfigure.py | 38 ------- .../Templates/config-assign-pnf-mapping.json | 3 - .../config-assign-restconf-configlet-template.vtl | 56 ++++++---- .../config-deploy-restconf-mount-template.vtl | 14 +++ .../Templates/configure-pnf-mapping.json | 3 - .../configure-restconf-mount-template.vtl | 14 --- .../configure-restconf-unmount-template.vtl | 1 - .../starter-dictionary/entity.json | 15 +++ .../starter-dictionary/pnf-id.json | 15 +++ .../starter-dictionary/pnf-name.json | 15 +++ 20 files changed, 448 insertions(+), 188 deletions(-) create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-assign-pnf-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-deploy-pnf-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configDeploy.xml delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json create mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-deploy-restconf-mount-template.vtl delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl delete mode 100644 components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/entity.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/pnf-id.json create mode 100755 components/model-catalog/resource-dictionary/starter-dictionary/pnf-name.json diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json index 90b2e3ab0..628a7d04d 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json @@ -19,17 +19,20 @@ }, { "file" : "Definitions/policy_types.json" } ], - "topology_template" : { - "inputs" : { - "serviceInstanceId" : { - "required" : true, - "type" : "string" - }, - "identifier" : { - "required" : true, - "type" : "string" + "dsl_definitions" : { + "config-assign-properties" : { + "resolution-key" : { + "get_input" : "resolution-key" } }, + "config-deploy-properties" : { + "resolution-key" : { + "get_input" : "resolution-key" + } + } + + }, + "topology_template" : { "workflows" : { "config-assign" : { "steps" : { @@ -42,6 +45,21 @@ } }, "inputs" : { + "resolution-key" : { + "required" : true, + "type" : "string" + }, + "artifact-name" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + }, + "store-result" : { + "required" : true, + "type" : "boolean" + }, "config-assign-properties" : { "description" : "Dynamic PropertyDefinition for workflow(config-assign).", "required" : true, @@ -49,21 +67,25 @@ } } }, - "configure" : { + "config-deploy" : { "steps" : { "activate-process" : { "description" : "Send a configlet to the pnf", - "target" : "configure-process", + "target" : "config-deploy-process", "activities" : [ { "call_operation" : "" } ] } }, "inputs" : { - "configure-properties" : { - "description" : "Dynamic PropertyDefinition for workflow(configure).", + "resolution-key" : { + "required" : true, + "type" : "string" + }, + "config-deploy-properties" : { + "description" : "Dynamic PropertyDefinition for workflow(config-deploy).", "required" : true, - "type" : "dt-configure-properties" + "type" : "dt-config-deploy-properties" } } } @@ -84,25 +106,24 @@ } } }, - - "config-assign" : { - "type" : "component-restconf-executor", + "type" : "component-resource-resolution", "interfaces" : { - "ComponentRestconfExecutor" : { + "ResourceResolutionComponent" : { "operations" : { "process" : { - "implementation" : { - "primary" : "component-script" - }, "inputs" : { - "script-type" : "jython", - "script-class-reference" : "Scripts/python/RestconfAssignConfig.py", - "instance-dependencies" : [ ] + "resolution-key" : { + "get_input" : "resolution-key" + }, + "store-result" : true, + "artifact-prefix-names" : ["config-assign"] }, "outputs" : { - "response-data" : "", - "status" : "" + "resource-assignment-params" : { + "get_attribute" : [ "SELF", "assignment-params" ] + }, + "status" : "success" } } } @@ -115,33 +136,26 @@ }, "config-assign-mapping" : { "type" : "artifact-mapping-resource", - "file" : "Templates/config-assign-pnf-mapping.json" - }, - "component-script" : { - "type" : "artifact-script-jython", - "file" : "Scripts/python/RestconfAssignConfig.py" + "file" : "Definitions/config-assign-pnf-mapping.json" } } }, - - - - "configure-process" : { + "config-deploy-process" : { "type" : "dg-generic", "properties" : { "content" : { - "get_artifact" : [ "SELF", "dg-configure-process" ] + "get_artifact" : [ "SELF", "dg-config-deploy-process" ] }, - "dependency-node-templates" : [ "configure" ] + "dependency-node-templates" : [ "config-deploy" ] }, "artifacts" : { "dg-config-assign-process" : { "type" : "artifact-directed-graph", - "file" : "Plans/CONFIG_configure.xml" + "file" : "Plans/CONFIG_configDeploy.xml" } } }, - "configure" : { + "config-deploy" : { "type" : "component-restconf-executor", "interfaces" : { "ComponentRestconfExecutor" : { @@ -152,36 +166,33 @@ }, "inputs" : { "script-type" : "jython", - "script-class-reference" : "Scripts/python/RestconfConfigure.py", - "instance-dependencies" : [ ] + "script-class-reference" : "Scripts/python/RestconfConfigDeploy.py", + "instance-dependencies" : [ ], + "dynamic-properties" : "*config-deploy-properties" }, "outputs" : { "response-data" : "", - "status" : "" + "status" : "success" } } } } }, "artifacts" : { - "configure-mount-template" : { - "type" : "artifact-template-velocity", - "file" : "Templates/configure-restconf-mount-template.vtl" - }, - "configure-unmount-template" : { + "config-deploy-template" : { "type" : "artifact-template-velocity", - "file" : "Templates/configure-restconf-unmount-template.vtl" + "file" : "Templates/config-deploy-restconf-mount-template.vtl" }, - "configure-mapping" : { + "config-deploy-mapping" : { "type" : "artifact-mapping-resource", - "file" : "Templates/configure-pnf-mapping.json" + "file" : "Definitions/config-deploy-pnf-mapping.json" }, "component-script" : { "type" : "artifact-script-jython", - "file" : "Scripts/python/RestconfConfigure.py" + "file" : "Scripts/python/RestconfConfigDeploy.py" } } } } } -} +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-assign-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-assign-pnf-mapping.json new file mode 100644 index 000000000..fc8e1bf64 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-assign-pnf-mapping.json @@ -0,0 +1,13 @@ +[ + { + "name": "entity", + "input-param": true, + "property": { + "type": "json" + }, + "dictionary-name": "entity", + "dictionary-source": "input", + "dependencies": [ + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-deploy-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-deploy-pnf-mapping.json new file mode 100644 index 000000000..fc8e1bf64 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/config-deploy-pnf-mapping.json @@ -0,0 +1,13 @@ +[ + { + "name": "entity", + "input-param": true, + "property": { + "type": "json" + }, + "dictionary-name": "entity", + "dictionary-source": "input", + "dependencies": [ + ] + } +] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json index 9f35eef88..e5aa763ba 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json @@ -3,13 +3,21 @@ "dt-config-assign-properties" : { "description" : "Dynamic DataType definition for workflow(config-assign).", "version" : "1.0.0", - "properties" : { }, + "properties" : { + "entity" : { + "type" : "json" + } + }, "derived_from" : "tosca.datatypes.Dynamic" }, - "dt-configure-properties" : { - "description" : "Dynamic DataType definition for workflow(configure).", + "dt-config-deploy-properties" : { + "description" : "Dynamic DataType definition for workflow(config-deploy).", "version" : "1.0.0", - "properties" : { }, + "properties" : { + "entity" : { + "type" : "json" + } + }, "derived_from" : "tosca.datatypes.Dynamic" } } diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json index be3bd319a..ed7c580bc 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json @@ -1,5 +1,84 @@ { "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" + }, + "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-restconf-executor" : { "description" : "This is Restconf Transaction Configuration Component API", "version" : "1.0.0", @@ -34,6 +113,11 @@ "entry_schema" : { "type" : "string" } + }, + "dynamic-properties" : { + "description" : "Dynamic Json Content or DSL Json reference.", + "required" : false, + "type" : "json" } }, "outputs" : { @@ -73,6 +157,24 @@ }, "derived_from" : "tosca.nodes.DG" }, + "source-input" : { + "description" : "This is Input Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "key" : { + "required" : false, + "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", @@ -82,6 +184,11 @@ "description" : "This is Directed Graph Node Type", "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" } } } \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json index 6f31cf5a2..98a73b101 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json @@ -1 +1,17 @@ -{ } \ No newline at end of file +{ + "entity" : { + "tags" : "entity", + "name" : "entity", + "property" : { + "description" : "entity", + "type" : "json" + }, + "updated-by" : "Rodrigo Ottero ", + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configDeploy.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configDeploy.xml new file mode 100644 index 000000000..fbed3d575 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configDeploy.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml deleted file mode 100644 index c48ffbed4..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py deleted file mode 100644 index 36dd32ffc..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfAssignConfig.py +++ /dev/null @@ -1,38 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - - -from org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor import \ - RestconfComponentFunction - - -class RestconfAssignConfig(RestconfComponentFunction): - - - def process(self, execution_request): - # create instances of the needed objects - # retrieve any needed information not present on the request, like pnf ip - # create the configlet - # persist the configlet - # end - print("process", execution_request) - - - def recover(self, runtime_exception, execution_request): - print("recover") - return None \ 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 new file mode 100644 index 000000000..33f9400eb --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py @@ -0,0 +1,112 @@ +# ============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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +from time import sleep + +from org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor import \ + RestconfComponentFunction +from java.lang import Exception as JavaException + + +class RestconfConfigDeploy(RestconfComponentFunction): + + log = globals()["log"] + seconds_to_sleep = 5 + base_mount_url = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" + server_identifier = "sdncodl" + configlet_template_name = "config-assign" + + def process(self, execution_request): + + self.log.info("Started execution of process method") + try: + self.log.info("getting resolution-key") + resolution_key = self.getDynamicProperties("resolution-key").asText() + self.log.info("resolution_key: {}", resolution_key) + + self.log.info("getting pnf-id") + pnf_id = execution_request.payload.get("config-deploy-request").get("config-deploy-properties").get("entity").get("pnf-id") + pnf_id = str(pnf_id).strip('\"') + self.log.info("pnf-id: {}", pnf_id) + + self.log.info("mounting device {}", pnf_id) + self.mount(pnf_id) + + self.log.info("sleeping for {} seconds", self.seconds_to_sleep) + sleep(self.seconds_to_sleep) + + try: + self.log.info("configuring device {}", pnf_id) + self.apply_configuration(pnf_id, resolution_key, self.configlet_template_name) + except Exception, err: + self.log.error("an error occurred while configuring device {}", err) + raise err + finally: + self.log.info("unmounting device {}", pnf_id) + self.unmount(pnf_id) + + self.log.info("Ended execution of process method") + + 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", err) + raise err + + def mount(self, pnf_id): + self.log.info("meshing mount payload") + mount_payload = self.resolveAndGenerateMessage("config-deploy-mapping", "config-deploy-template") + self.log.info("mount payload: \n {}", mount_payload) + + # defining custom header + headers = { + "Content-Type": "application/xml" + } + + url = self.base_mount_url + str(pnf_id) + self.log.info("sending mount request, url: {}", url) + web_client_service = self.restClientService(self.server_identifier) + web_client_service.exchangeResource("PUT", url, mount_payload, headers) + + def unmount(self, pnf_id): + url = self.base_mount_url + str(pnf_id) + self.log.info("sending unmount request, url: {}", url) + web_client_service = self.restClientService(self.server_identifier) + web_client_service.exchangeResource("DELETE", url, "") + + def apply_configuration(self, pnf_id, resolution_key, template_name): + self.log.info("Retrieving configlet from database (resolution-key: {}, template_name: {}", + resolution_key, template_name) + configlet = self.resolveFromDatabase(resolution_key, template_name) + self.log.info("Configlet: {}", configlet) + + # defining custom header + headers = { + "Content-Type": "application/yang.patch+json" + } + + url = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" + pnf_id \ + + "/yang-ext:mount/mynetconf:netconflist" + self.log.info("sending patch request, url: {}", url) + web_client_service = self.restClientService(self.server_identifier) + result = web_client_service.exchangeResource("PATCH", url, configlet, headers) + self.log.info("Configuration application result: {}", result) + + def recover(self, runtime_exception, execution_request): + self.log.info("Recover method, no code to execute") + return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py deleted file mode 100644 index c584baa9b..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigure.py +++ /dev/null @@ -1,38 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - - -from org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor import \ - RestconfComponentFunction - - -class RestconfConfigure(RestconfComponentFunction): - - - def process(self, execution_request): - # create instances of the needed objects - # retrieve any needed information not present on the request, like pnf ip - # retrieve the configlet - # send the configlet - # end - print("process", execution_request) - - - def recover(self, runtime_exception, execution_request): - print("recover") - return None diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json deleted file mode 100644 index 41b42e677..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl index e3d7a6716..3812380ea 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl @@ -1,19 +1,37 @@ - -example-patch -Example patch - - edit1 - create - /car-entry - - - 0 - - - - - edit2 - delete - /car-entry/0 - - +{ + "ietf-restconf:yang-patch":{ + "patch-id":"patch-1", + "edit":[ + { + "edit-id":"edit1", + "operation":"merge", + "target":"/", + "value":{ + "netconflist":{ + "netconf":[ + { + "netconf-id":"40", + "netconf-param":"4040" + } + ] + } + } + }, + { + "edit-id":"edit2", + "operation":"merge", + "target":"/", + "value":{ + "netconflist":{ + "netconf":[ + { + "netconf-id":"50", + "netconf-param":"98765" + } + ] + } + } + } + ] + } +} \ No newline at end of file diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-deploy-restconf-mount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-deploy-restconf-mount-template.vtl new file mode 100644 index 000000000..935177658 --- /dev/null +++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-deploy-restconf-mount-template.vtl @@ -0,0 +1,14 @@ + + $entity.pnf-id + + ODL-private-key + netconf + + $entity.pnf-name + 6513 + false + + TLS + + 5 + diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json deleted file mode 100644 index 41b42e677..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl deleted file mode 100644 index a899aa45c..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl +++ /dev/null @@ -1,14 +0,0 @@ - - $pnf-id - - ODL-private-key - netconf - - $pnf-ip - 6513 - false - - TLS - - 5 - diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl deleted file mode 100644 index a0990367e..000000000 --- a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl +++ /dev/null @@ -1 +0,0 @@ -TBD diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/entity.json b/components/model-catalog/resource-dictionary/starter-dictionary/entity.json new file mode 100755 index 000000000..83a32a922 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/entity.json @@ -0,0 +1,15 @@ +{ + "name" : "entity", + "tags" : "entity", + "updated-by" : "Rodrigo Ottero ", + "property" : { + "description" : "entity", + "type" : "json" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/pnf-id.json b/components/model-catalog/resource-dictionary/starter-dictionary/pnf-id.json new file mode 100755 index 000000000..32468533a --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/pnf-id.json @@ -0,0 +1,15 @@ +{ + "name" : "pnf-id", + "tags" : "pnf-id", + "updated-by" : "Rodrigo Ottero ", + "property" : { + "description" : "pnf-id", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/starter-dictionary/pnf-name.json b/components/model-catalog/resource-dictionary/starter-dictionary/pnf-name.json new file mode 100755 index 000000000..edcc3e9a0 --- /dev/null +++ b/components/model-catalog/resource-dictionary/starter-dictionary/pnf-name.json @@ -0,0 +1,15 @@ +{ + "name" : "pnf-name", + "tags" : "pnf-name", + "updated-by" : "Rodrigo Ottero ", + "property" : { + "description" : "pnf-name", + "type" : "string" + }, + "sources" : { + "input" : { + "type" : "source-input", + "properties" : { } + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From ccd1091289c20f3834610d344b270b46cc8d90c5 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Wed, 13 Mar 2019 17:39:15 -0400 Subject: Propagate exceptions correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idaf66eeaa6e57d27c576099fd6ffdeb8b6d8d6c6 Issue-ID: CCSDK-1120 Signed-off-by: Alexis de Talhouët --- .../test-blueprint/golden/Scripts/python/DescriptionExample.py | 4 ++-- .../test-blueprint/golden/Scripts/python/NetconfRpcExample.py | 2 +- .../blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 fce7c3249..4cf635afe 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 @@ -42,5 +42,5 @@ class DescriptionExample(AbstractRAProcessor): return None def recover(self, runtime_exception, resource_assignment): - print "NoOp" - return None + print self.addError(runtime_exception.getMessage()) + return None \ 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/NetconfRpcExample.py index ed22989fb..2d22f8bba 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/NetconfRpcExample.py @@ -57,5 +57,5 @@ class NetconfRpcExample(NetconfComponentFunction): log.error("Python Exception in the script {}", err) def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + print self.addError(runtime_exception.getMessage()) 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 73419d716..deec47007 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 @@ -43,5 +43,5 @@ class Rollback(NetconfComponentFunction): log.error("Python Exception in the script {}", err) def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH + print self.addError(runtime_exception.getMessage()) return None -- cgit 1.2.3-korg From 2d0bfb6f58496fc52cad29a3f9b9064bcae67ed3 Mon Sep 17 00:00:00 2001 From: vinal patel Date: Wed, 20 Feb 2019 16:02:44 -0500 Subject: Ressource resolution using configurable database Change-Id: I40338a221884d6f4df4c8a7dc3dac1f58f142074 Issue-ID: CCSDK-1092 Signed-off-by: vinal patel --- .../baseconfiguration/Definitions/node_types.json | 2 +- .../Definitions/resources_definition_types.json | 4 +- .../golden/Definitions/node_types.json | 2 +- .../Definitions/resources_definition_types.json | 4 +- .../golden/Templates/vf-module-1-mapping.json | 2 +- .../golden/Templates/vfw-interface-mapping.json | 2 +- .../node_type/source-processor-db.json | 48 ++++++++++++++++++++++ .../test-dictionary/vf-module-type.json | 4 +- 8 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json 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 8f6c44f94..68a8ae6bd 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 @@ -223,7 +223,7 @@ }, "derived_from": "tosca.nodes.ResourceSource" }, - "source-primary-db": { + "source-processor-db": { "description": "This is Database Resource Source Node Type", "version": "1.0.0", "properties": { 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 eaf45b35f..6e3d5e94f 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 @@ -26,8 +26,8 @@ "type": "source-input", "properties": {} }, - "primary-db": { - "type": "source-primary-db", + "processor-db": { + "type": "source-processor-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/golden/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json index b05869217..f143e560b 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json @@ -236,7 +236,7 @@ }, "derived_from" : "tosca.nodes.ResourceSource" }, - "source-primary-db" : { + "source-processor-db" : { "description" : "This is Database Resource Source Node Type", "version" : "1.0.0", "properties" : { 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 446a8a681..15f02a1ce 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 @@ -129,8 +129,8 @@ }, "updated-by" : "adetalhouet", "sources" : { - "primary-db" : { - "type" : "source-primary-db", + "processor-db" : { + "type" : "source-processor-db", "properties" : { "type" : "SQL", "query" : "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid", diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json index eba259e33..b7335b513 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json @@ -18,7 +18,7 @@ "type": "string" }, "dictionary-name": "vf-module-type", - "dictionary-source": "primary-db", + "dictionary-source": "processor-db", "dependencies": [ "vf-module-number" ] diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json index 149d3eb20..c1ebe5688 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json +++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json @@ -55,7 +55,7 @@ "type": "string" }, "dictionary-name": "vf-module-type", - "dictionary-source": "primary-db", + "dictionary-source": "processor-db", "dependencies": [ "vf-module-number" ] diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json b/components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json new file mode 100644 index 000000000..702748f8a --- /dev/null +++ b/components/model-catalog/definition-type/starter-type/node_type/source-processor-db.json @@ -0,0 +1,48 @@ +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL", + "PLSQL" + ] + } + ] + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "query": { + "required": true, + "type": "string" + }, + "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" +} \ No newline at end of file diff --git a/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json index b06057c45..9e8c4096f 100644 --- a/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json +++ b/components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json @@ -7,8 +7,8 @@ }, "updated-by": "adetalhouet", "sources": { - "primary-db": { - "type": "source-primary-db", + "processor-db": { + "type": "source-processor-db", "properties": { "type": "SQL", "query": "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid", -- cgit 1.2.3-korg From 61f4924a42bf9a3e4f52e89f2d4f84395a34acd2 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Mar 2019 16:31:51 -0400 Subject: Compile against Fluorine SR2 Updated to compile against Fluorine SR2 Change-Id: I434068531ce4a661a04c20201e0fddf3f6b92f47 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- components/model-catalog/proto-definition/pom.xml | 2 +- components/parent/pom.xml | 2 +- components/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/model-catalog/proto-definition/pom.xml b/components/model-catalog/proto-definition/pom.xml index 35fc9a9a1..d12470843 100644 --- a/components/model-catalog/proto-definition/pom.xml +++ b/components/model-catalog/proto-definition/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.apps ccsdk-apps - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT ../../../ diff --git a/components/parent/pom.xml b/components/parent/pom.xml index dd74622dd..0d5d964e6 100644 --- a/components/parent/pom.xml +++ b/components/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps components - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT org.onap.ccsdk.apps.components parent diff --git a/components/pom.xml b/components/pom.xml index 1915fecf7..115b3a981 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -19,7 +19,7 @@ org.onap.ccsdk.apps ccsdk-apps - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT 4.0.0 components -- cgit 1.2.3-korg From baa596db5ef0ace285f03a68aa8d9307454fc860 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Thu, 21 Mar 2019 15:56:38 -0400 Subject: Add workflow output resolution Change-Id: I3d5bb339fd07257e86ada85e4a30040183808848 Issue-ID: CCSDK-1175 Signed-off-by: Muthuramalingam, Brinda Santh --- .../Definitions/activation-blueprint.json | 15 +++++++++++++++ .../component_invoke/Definitions/component_invoke.json | 12 ++++++++++++ 2 files changed, 27 insertions(+) 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 7a9239819..a8329b837 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 @@ -318,6 +318,21 @@ } ] } + }, + "outputs": { + "response-property": { + "type": "string", + "value": "executed" + }, + "template-properties": { + "type": "json", + "value": { + "get_attribute": [ + "resource-assignment", + "assignment-params" + ] + } + } } }, "activate": { diff --git a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json index eeb9815fa..9e040b85d 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json +++ b/components/model-catalog/blueprint-model/test-blueprint/component_invoke/Definitions/component_invoke.json @@ -54,6 +54,18 @@ "required": true, "type": "string" } + }, + "outputs": { + "response-property1": { + "type": "string", + "value": "executed" + }, + "response-property2": { + "type": "string", + "value": { + "get_input": "action-name" + } + } } } }, -- cgit 1.2.3-korg