aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn66
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/TOSCA-Metadata/TOSCA.meta4
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json333
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/artifact_types.json22
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json106
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/node_types.json413
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/policy_types.json3
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/relationship_types.json9
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json148
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml15
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml22
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml15
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/README134
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py46
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py61
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py47
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py0
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta6
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-mapping.json13
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-template.vtl7
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-mapping.json1
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-template.vtl3
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-mapping.json64
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-template.vtl4
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-mapping.json88
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-template.vtl18
-rw-r--r--components/model-catalog/definition-type/starter-type/data_type/dt-netbox-ip.json15
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-rest.json17
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/create_netbox_ip.json29
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/delete_netbox_ip.json30
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/hostname.json14
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/interface-description.json21
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/interface-name.json15
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/prefix-id.json16
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/unit-number.json14
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/vf-module-number.json16
-rw-r--r--components/model-catalog/resource-dictionary/test-dictionary/vf-module-type.json27
-rw-r--r--components/scripts/python/ccsdk_netconf/netconfclient.py4
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt18
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt86
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt3
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt135
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt40
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt43
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt30
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json2
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/pom.xml4
-rwxr-xr-xms/blueprintsprocessor/modules/commons/pom.xml16
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/pom.xml (renamed from ms/blueprintsprocessor/modules/commons/core/pom.xml)2
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt)134
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties (renamed from ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties)32
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt (renamed from ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt)0
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml10
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt10
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt76
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt51
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt73
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt24
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt99
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt25
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt26
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt29
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml23
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt27
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt22
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt5
-rwxr-xr-xms/blueprintsprocessor/modules/services/pom.xml35
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/pom.xml21
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt72
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt6
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt49
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt)21
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt72
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt66
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt54
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt12
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt (renamed from ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt)10
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml19
-rw-r--r--ms/cds-sdc-listener/application/pom.xml3
-rw-r--r--ms/cds-sdc-listener/distribution/pom.xml11
-rw-r--r--ms/cds-sdc-listener/pom.xml2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt4
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt26
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt34
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt44
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt8
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java85
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelController.kt (renamed from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelRest.kt)5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryController.kt68
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java3
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java122
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelControllerTest.kt (renamed from ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelRestTest.kt)5
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeControllerTest.kt120
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt43
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt17
108 files changed, 3069 insertions, 1002 deletions
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 89ae342f..00000000
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Plans/ActivateProcess.bpmn
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
- xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
- xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
- xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1"
- targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.2">
- <bpmn:process id="ActivateProcess" isExecutable="true">
- <bpmn:startEvent id="StartEvent_1">
- <bpmn:outgoing>SequenceFlow_0l0dq58</bpmn:outgoing>
- </bpmn:startEvent>
- <bpmn:endEvent id="EndEvent_1pr0kil">
- <bpmn:incoming>SequenceFlow_1ay0k6p</bpmn:incoming>
- </bpmn:endEvent>
- <bpmn:sequenceFlow id="SequenceFlow_0l0dq58" sourceRef="StartEvent_1" targetRef="activate_device_task"/>
- <bpmn:sequenceFlow id="SequenceFlow_1ay0k6p" sourceRef="activate_device_task" targetRef="EndEvent_1pr0kil"/>
- <bpmn:serviceTask id="activate_device_task" name="Activate Device"
- camunda:delegateExpression="${componentDelegateService}">
- <bpmn:extensionElements>
- <camunda:inputOutput>
- <camunda:inputParameter name="selector"><![CDATA[resource-assignment
-]]></camunda:inputParameter>
- </camunda:inputOutput>
- </bpmn:extensionElements>
- <bpmn:incoming>SequenceFlow_0l0dq58</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1ay0k6p</bpmn:outgoing>
- </bpmn:serviceTask>
- </bpmn:process>
- <bpmndi:BPMNDiagram id="BPMNDiagram_1">
- <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateProcess">
- <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
- <dc:Bounds x="175" y="143" width="36" height="36"/>
- <bpmndi:BPMNLabel>
- <dc:Bounds x="148" y="179" width="90" height="20"/>
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="EndEvent_1pr0kil_di" bpmnElement="EndEvent_1pr0kil">
- <dc:Bounds x="575" y="114" width="36" height="36"/>
- <bpmndi:BPMNLabel>
- <dc:Bounds x="593" y="154" width="0" height="12"/>
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0l0dq58_di" bpmnElement="SequenceFlow_0l0dq58">
- <di:waypoint xsi:type="dc:Point" x="211" y="161"/>
- <di:waypoint xsi:type="dc:Point" x="273" y="161"/>
- <di:waypoint xsi:type="dc:Point" x="273" y="149"/>
- <di:waypoint xsi:type="dc:Point" x="334" y="149"/>
- <bpmndi:BPMNLabel>
- <dc:Bounds x="288" y="149" width="0" height="12"/>
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_1ay0k6p_di" bpmnElement="SequenceFlow_1ay0k6p">
- <di:waypoint xsi:type="dc:Point" x="434" y="149"/>
- <di:waypoint xsi:type="dc:Point" x="505" y="149"/>
- <di:waypoint xsi:type="dc:Point" x="505" y="132"/>
- <di:waypoint xsi:type="dc:Point" x="575" y="132"/>
- <bpmndi:BPMNLabel>
- <dc:Bounds x="520" y="134.5" width="0" height="12"/>
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_0e8ek4f_di" bpmnElement="activate_device_task">
- <dc:Bounds x="334" y="109" width="100" height="80"/>
- </bpmndi:BPMNShape>
- </bpmndi:BPMNPlane>
- </bpmndi:BPMNDiagram>
-</bpmn:definitions>
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 9066e484..8f1df9f2 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 <brindasanth@in.ibm.com>
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/golden/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json
new file mode 100644
index 00000000..b6464f3c
--- /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 00000000..6ec3b410
--- /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 00000000..d60e6f00
--- /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 00000000..b0586921
--- /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 00000000..1e44cc70
--- /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 00000000..027bfc0f
--- /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 00000000..446a8a68
--- /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 00000000..ec154a15
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module="CONFIG" version="1.0.0">
+ <method rpc="ConfigDeploy" mode="sync">
+ <block atomic="true">
+ <execute plugin="config-deploy" method="process">
+ <outcome value="failure">
+ <return status="failure" />
+ </outcome>
+ <outcome value="success">
+ <return status="success" />
+ </outcome>
+ </execute>
+ </block>
+ </method>
+</service-logic> \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml
new file mode 100644
index 00000000..15872e52
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service-logic
+ xmlns='http://www.onap.org/sdnc/svclogic'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd'
+ module='CONFIG'
+ version='1.0.0'>
+ <method rpc='ResourceAssignment' mode='sync'>
+ <block atomic="true">
+ <execute plugin="resource-assignment" method="process">
+ <outcome value='failure'>
+ <return status="failure">
+ </return>
+ </outcome>
+ <outcome value='success'>
+ <return status="success">
+ </return>
+ </outcome>
+ </execute>
+ </block>
+ </method>
+</service-logic> \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml
new file mode 100644
index 00000000..c1231d7a
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module="CONFIG" version="1.0.0">
+ <method rpc="Rollback" mode="sync">
+ <block atomic="true">
+ <execute plugin="rollback" method="process">
+ <outcome value="failure">
+ <return status="failure" />
+ </outcome>
+ <outcome value="success">
+ <return status="success" />
+ </outcome>
+ </execute>
+ </block>
+ </method>
+</service-logic> \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/README b/components/model-catalog/blueprint-model/test-blueprint/golden/README
new file mode 100644
index 00000000..06f91123
--- /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": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration xmlns:junos=\"http://xml.juniper.net/junos/17.4R1/junos\">\n <system xmlns=\"http://yang.juniper.net/junos-qfx/conf/system\">\n <host-name operation=\"delete\" />\n <host-name operation=\"create\">demo123</host-name>\n </system>\n</configuration>\n",
+ "vf-module-1": "<interface>\n <description>This is the Virtual Firewall entity</description>\n <vfw>10.10.10.39/24</vfw>\n</interface>"
+ },
+ "status": "success"
+ }
+
+ config-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 00000000..fce7c324
--- /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 00000000..ed22989f
--- /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 00000000..73419d71
--- /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 00000000..e69de29b
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/__init__.py
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 00000000..065eda19
--- /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 00000000..1e02d690
--- /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 00000000..1e80b6d1
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/hostname-template.vtl
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos">
+ <system xmlns="http://yang.juniper.net/junos-qfx/conf/system">
+ <host-name operation="delete" />
+ <host-name operation="create">$hostname</host-name>
+ </system>
+</configuration>
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 00000000..0637a088
--- /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 00000000..655a2b1c
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/junos-rollback-RPC-template.vtl
@@ -0,0 +1,3 @@
+<rpc>
+ <load-configuration rollback="1"/>
+</rpc> \ 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 00000000..eba259e3
--- /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 00000000..9ba34a05
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vf-module-1-template.vtl
@@ -0,0 +1,4 @@
+<interface>
+ <description>$interface-description</description>
+ <vfw>$vfw_interface_ip.address</vfw>
+</interface> \ 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 00000000..149d3eb2
--- /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 00000000..3223535e
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/golden/Templates/vfw-interface-template.vtl
@@ -0,0 +1,18 @@
+<configuration>
+ <interfaces>
+ <interface>
+ <name>$interface-name</name>
+ <unit operation="create">
+ <name>$unit-number</name>
+ <description>$interface-description</description>
+ <family>
+ <inet>
+ <address>
+ <name>$vfw_interface_ip.address</name>
+ </address>
+ </inet>
+ </family>
+ </unit>
+ </interface>
+ </interfaces>
+</configuration> \ 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 00000000..81c908d6
--- /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/definition-type/starter-type/node_type/source-rest.json b/components/model-catalog/definition-type/starter-type/node_type/source-rest.json
index 04498304..b28e9341 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"
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 00000000..297a8ef8
--- /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 00000000..35a8a351
--- /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 00000000..025cce33
--- /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 00000000..d13bfc44
--- /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 00000000..53a11ed7
--- /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 00000000..e515eca5
--- /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 00000000..333fd78e
--- /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 00000000..cdd40f66
--- /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 00000000..b06057c4
--- /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
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py
index d898ec00..e263ba8f 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
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index 55085216..02c0a342 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -57,6 +57,24 @@ interface NetconfRpcService {
editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
/**
+ * Invoke custom RPC as provided as input.
+ *
+ * Some use cases might required one to directly invoke a device
+ * specific RPC. The RPC must be correctly formatted.
+ *
+ * Ex: in order to rollback last submitted configuration
+ * for JUNOS devices, such RPC can be use:
+ * <code>
+ * &lt;rpc>
+ * &lt;load-configuration rollback="1"/>
+ * &lt;/rpc>
+ * </code>
+ *
+ * @param rpc the rpc content.
+ */
+ fun invokeRpc(rpc: String): DeviceResponse
+
+ /**
* Validate
*
* @param configTarget running or candidate, default candidate
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index 8d8e0ea4..15fb3122 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -41,6 +41,19 @@ class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcServ
this.netconfSession = netconfSession
}
+ override fun invokeRpc(rpc: String): DeviceResponse {
+ var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ log.info("$deviceInfo: invokeRpc: messageId($messageId)")
+ try {
+ output = asyncRpc(rpc, messageId)
+ } catch (e: Exception) {
+ output.status = RpcStatus.FAILURE
+ output.errorMessage = "$deviceInfo: failed in invokeRpc command $e.message"
+ }
+ return output
+ }
+
override fun getConfig(filter: String, configTarget: String): DeviceResponse {
var output = DeviceResponse()
val messageId = messageIdInteger.getAndIncrement().toString()
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index c1282344..335aea1e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -59,14 +59,14 @@ interface ResourceResolutionService {
@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext,
private var resolutionResultService: ResourceResolutionResultService) :
- ResourceResolutionService {
+ ResourceResolutionService {
private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
@@ -92,7 +92,7 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
val result = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)
if (properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
- && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) {
+ && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) {
resolutionResultService.write(properties, result, bluePrintRuntimeService, artifactPrefix)
}
@@ -113,32 +113,32 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
val identifierName = artifactTemplate ?: "no-template"
val resourceAssignmentContent =
- bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
val resourceAssignments: MutableList<ResourceAssignment> =
- JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
- as? MutableList<ResourceAssignment>
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
// Get the Resource Dictionary Name
val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)
- .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
- .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)
val resourceDictionaries: MutableMap<String, ResourceDefinition> =
- JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+ JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
// Resolve resources
resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
val resolvedParamJsonContent =
- ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
+ ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
// Check Template is there
if (artifactTemplate != null) {
val templateContent =
- bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
} else {
resolvedContent = resolvedParamJsonContent
@@ -159,35 +159,33 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
val resourceAssignmentRuntimeService =
- ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
+ ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .forEach { resourceAssignment ->
- val dictionaryName = resourceAssignment.dictionaryName
- val dictionarySource = resourceAssignment.dictionarySource
- /**
- * Get the Processor name
- */
- val processorName = processorName(dictionaryName!!, dictionarySource!!,
- resourceDictionaries)
-
- val resourceAssignmentProcessor =
- applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
- "for resource assignment(${resourceAssignment.name})")
- try {
- // Set BluePrint Runtime Service
- resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- // Set Resource Dictionaries
- resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
- // Invoke Apply Method
- resourceAssignmentProcessor.apply(resourceAssignment)
- } catch (e: RuntimeException) {
- resourceAssignmentProcessor.recover(e, resourceAssignment)
- throw BluePrintProcessorException(e)
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
+ val dictionarySource = resourceAssignment.dictionarySource
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDictionaries)
+
+ val resourceAssignmentProcessor =
+ applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
+ "for resource assignment(${resourceAssignment.name})")
+ try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+ // Invoke Apply Method
+ resourceAssignmentProcessor.apply(resourceAssignment)
+ } catch (e: RuntimeException) {
+ throw BluePrintProcessorException(e)
+ }
}
- }
}
}
@@ -208,18 +206,18 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
else -> {
val resourceDefinition = resourceDictionaries[dictionaryName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
val resourceSource = resourceDefinition.sources[dictionarySource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
- .plus(resourceSource.type)
+ .plus(resourceSource.type)
}
}
checkNotEmptyOrThrow(processorName,
- "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
- "($dictionarySource)")
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
return processorName
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 1c357446..25fc8c01 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -48,6 +48,9 @@ open class DatabaseResourceSource : ResourceSourceProperties() {
}
open class RestResourceSource : ResourceSourceProperties() {
+ lateinit var verb: String
+ @get:JsonProperty("payload")
+ var payload: String? = null
lateinit var type: String
@get:JsonProperty("endpoint-selector")
var endpointSelector: String? = null
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index c2dbd731..6469e78d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -20,10 +20,8 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
@@ -31,14 +29,16 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
-import java.io.File
@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-capability")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class CapabilityResourceResolutionProcessor(private var applicationContext: ApplicationContext,
- private val bluePrintScriptsService: BluePrintScriptsService,
- private val bluePrintJythonService: BlueprintJythonService) :
- ResourceAssignmentProcessor() {
+open class CapabilityResourceResolutionProcessor(private val applicationContext: ApplicationContext,
+ private var componentFunctionScriptingService: ComponentFunctionScriptingService)
+ : ResourceAssignmentProcessor() {
+
+ private val log = LoggerFactory.getLogger(CapabilityResourceResolutionProcessor::class.java)
+
+ var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
override fun getName(): String {
return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-capability"
@@ -62,118 +62,43 @@ open class CapabilityResourceResolutionProcessor(private var applicationContext:
val scriptType = capabilityResourceSourceProperty.scriptType
val scriptClassReference = capabilityResourceSourceProperty.scriptClassReference
+ val instanceDependencies = capabilityResourceSourceProperty.instanceDependencies ?: listOf()
- var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
-
- when (scriptType) {
- BluePrintConstants.SCRIPT_KOTLIN -> {
- componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(scriptClassReference,
- capabilityResourceSourceProperty.instanceDependencies)
- }
- BluePrintConstants.SCRIPT_INTERNAL -> {
- // Initialize Capability Resource Assignment Processor
- componentResourceAssignmentProcessor = applicationContext.getBean(scriptClassReference, ResourceAssignmentProcessor::class.java)
- }
- BluePrintConstants.SCRIPT_JYTHON -> {
- val content = getJythonContent(scriptClassReference)
- componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(scriptClassReference,
- content, capabilityResourceSourceProperty.instanceDependencies)
- }
- }
+ componentResourceAssignmentProcessor = scriptInstance(scriptType, scriptClassReference, instanceDependencies)
- checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($scriptClassReference)" }
+ checkNotNull(componentResourceAssignmentProcessor) {
+ "failed to get capability resource assignment processor($scriptClassReference)"
+ }
// Assign Current Blueprint runtime and ResourceDictionaries
- componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService
- componentResourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+ componentResourceAssignmentProcessor!!.raRuntimeService = raRuntimeService
+ componentResourceAssignmentProcessor!!.resourceDictionaries = resourceDictionaries
// Invoke componentResourceAssignmentProcessor
- componentResourceAssignmentProcessor.apply(resourceAssignment)
+ componentResourceAssignmentProcessor!!.apply(resourceAssignment)
}
override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
-
- TODO("To Implement")
- }
-
- private fun getKotlinResourceAssignmentProcessorInstance(scriptClassName: String,
- instanceNames: List<String>? = null): ResourceAssignmentProcessor {
- var scriptPropertyInstances: MutableMap<String, Any>? = null
-
- if (instanceNames != null && instanceNames.isNotEmpty()) {
- scriptPropertyInstances = hashMapOf()
- instanceNames.forEach {
- scriptPropertyInstances[it] = applicationContext.getBean(it)
- ?: throw BluePrintProcessorException("couldn't get the dependency instance($it)")
- }
- }
-
- return getKotlinResourceAssignmentProcessorInstance(scriptClassName, scriptPropertyInstances)
-
- }
-
- fun getKotlinResourceAssignmentProcessorInstance(scriptClassName: String,
- scriptPropertyInstances: MutableMap<String, Any>? = null):
- ResourceAssignmentProcessor {
-
- val resourceAssignmentProcessor = bluePrintScriptsService
- .scriptInstance<ResourceAssignmentProcessor>(raRuntimeService.bluePrintContext(),
- scriptClassName, false)
-
- // Add additional Instance
- if (scriptPropertyInstances != null) {
- resourceAssignmentProcessor.scriptPropertyInstances = scriptPropertyInstances
+ log.info("Recovering for : ${resourceAssignment.name} : ${runtimeException.toString()}")
+ if (componentResourceAssignmentProcessor != null) {
+ componentResourceAssignmentProcessor!!.recover(runtimeException, resourceAssignment)
}
-
- return resourceAssignmentProcessor
- }
-
- private fun getJythonContent(instanceName: String): String {
- val absolutePath = raRuntimeService.bluePrintContext().rootPath
- .plus(File.separator)
- .plus(BluePrintConstants.TOSCA_SCRIPTS_JYTHON_DIR)
- .plus(File.separator)
- .plus("$instanceName.py")
-
- return JacksonUtils.getContent(absolutePath)
-
}
- /**
- * getJythonResourceAssignmentProcessorInstance Purpose: prepare the jython
- * executor component as a resource assignment processor
- *
- * @param pythonClassName String
- * @param content String
- * @param dependencyInstances List<String>
- * @return resourceAssignmentProcessor ResourceAssignmentProcessor
- */
- private fun getJythonResourceAssignmentProcessorInstance(pythonClassName: String, content: String,
- dependencyInstances: List<String>?):
- ResourceAssignmentProcessor {
- val jythonContextInstance: MutableMap<String, Any> = hashMapOf()
- jythonContextInstance["log"] = LoggerFactory.getLogger(pythonClassName)
- jythonContextInstance["raRuntimeService"] = raRuntimeService
- dependencyInstances?.forEach { instanceName ->
- jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
- }
-
- return getJythonResourceAssignmentProcessorInstance(pythonClassName, content, jythonContextInstance)
- }
+ fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List<String>)
+ : ResourceAssignmentProcessor {
- fun getJythonResourceAssignmentProcessorInstance(pythonClassName: String, content: String,
- dependencyInstances: MutableMap<String, Any>):
- ResourceAssignmentProcessor {
+ log.info("creating resource resolution of script type($scriptType), reference name($scriptClassReference) and" +
+ "instanceDependencies($instanceDependencies)")
- val resourceAssignmentProcessor = bluePrintJythonService
- .jythonInstance<ResourceAssignmentProcessor>(raRuntimeService.bluePrintContext(), pythonClassName,
- content, dependencyInstances)
+ val scriptComponent = componentFunctionScriptingService
+ .scriptInstance<ResourceAssignmentProcessor>(raRuntimeService.bluePrintContext(), scriptType,
+ scriptClassReference)
- // Add additional Instance
- if (dependencyInstances != null) {
- resourceAssignmentProcessor.scriptPropertyInstances = dependencyInstances
+ instanceDependencies.forEach { instanceDependency ->
+ scriptPropertyInstances[instanceDependency] = applicationContext
+ .getBean(instanceDependency)
}
-
- return resourceAssignmentProcessor
+ return scriptComponent
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
index 39be14c9..c76bff32 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
@@ -18,11 +18,18 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import com.fasterxml.jackson.databind.node.JsonNodeFactory
+import com.fasterxml.jackson.databind.node.MissingNode
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkEqualsOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
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.ResourceDictionaryConstants
@@ -31,7 +38,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
import org.springframework.stereotype.Service
-import java.util.*
/**
* DatabaseResourceAssignmentProcessor
@@ -54,11 +60,8 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
validate(resourceAssignment)
// Check if It has Input
- try {
- val value = raRuntimeService.getInputValue(resourceAssignment.name)
- logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- } catch (e: BluePrintProcessorException) {
+ val value = getFromInput(resourceAssignment)
+ if (value == null || value is MissingNode) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
@@ -71,12 +74,16 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
- logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping)
+
+ val resolvedSql = resolveFromInputKeyMapping(sql, resolvedInputKeyMapping)
+
+ logger.info("$dSource dictionary information : ($resolvedSql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
val jdbcTemplate = blueprintDBLibService(sourceProperties)
- val rows = jdbcTemplate.queryForList(sql, populateNamedParameter(inputKeyMapping))
+ val rows = jdbcTemplate.queryForList(resolvedSql, resolvedInputKeyMapping)
if (rows.isNullOrEmpty()) {
- logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)")
+ logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($resolvedSql)")
} else {
populateResource(resourceAssignment, sourceProperties, rows)
}
@@ -91,7 +98,7 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
}
private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): NamedParameterJdbcTemplate {
- return if (checkNotEmpty(sourceProperties.endpointSelector!!)) {
+ return if (checkNotEmpty(sourceProperties.endpointSelector)) {
val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!)
dBLibGenericService.remoteJdbcTemplate(dbPropertiesJson)
} else {
@@ -109,17 +116,6 @@ open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService:
}
}
- private fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> {
- val namedParameters = HashMap<String, Any>()
- inputKeyMapping.forEach {
- val expressionValue = raRuntimeService.getDictionaryStore(it.value).textValue()
- logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)")
- namedParameters[it.key] = expressionValue
- }
- logger.info("Parameter information : ({})", namedParameters)
- return namedParameters
- }
-
@Throws(BluePrintProcessorException::class)
private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
val dName = resourceAssignment.dictionaryName
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index 528705f1..d487eab6 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -17,7 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.MissingNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
@@ -44,19 +44,11 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
override fun process(resourceAssignment: ResourceAssignment) {
try {
- // Check if It has Input
- var value: JsonNode?
- try {
- value = raRuntimeService.getInputValue(resourceAssignment.name)
- } catch (e: BluePrintProcessorException) {
- // If value is null get it from default source
- logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})")
+ var value = getFromInput(resourceAssignment)
+ if (value == null || value is MissingNode) {
value = resourceAssignment.property?.defaultValue
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
}
-
- logger.info("For template key (${resourceAssignment.name}) setting value as ($value)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
-
// Check the value has populated for mandatory case
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index 9b7c70aa..8e9606c4 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -17,12 +17,18 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.JsonNode
+import org.apache.commons.collections.MapUtils
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
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.BluePrintTemplateService
+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.slf4j.LoggerFactory
+import java.util.*
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> {
@@ -31,19 +37,50 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
lateinit var raRuntimeService: ResourceAssignmentRuntimeService
lateinit var resourceDictionaries: MutableMap<String, ResourceDefinition>
- var scriptPropertyInstances: Map<String, Any> = hashMapOf()
+ var scriptPropertyInstances: MutableMap<String, Any> = hashMapOf()
/**
* This will be called from the scripts to serve instance from runtime to scripts.
*/
open fun <T> scriptPropertyInstanceType(name: String): T {
return scriptPropertyInstances as? T
- ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ }
+
+ open fun getFromInput(resourceAssignment: ResourceAssignment): JsonNode? {
+ var value: JsonNode? = null
+ try {
+ value = raRuntimeService.getInputValue(resourceAssignment.name)
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
+ } catch (e: BluePrintProcessorException) {
+ // NoOp - couldn't find value from input
+ }
+ return value
}
open fun resourceDefinition(name: String): ResourceDefinition {
return resourceDictionaries[name]
- ?: throw BluePrintProcessorException("couldn't get resource definition for ($name)")
+ ?: throw BluePrintProcessorException("couldn't get resource definition for ($name)")
+ }
+
+ open fun resolveInputKeyMappingVariables(inputKeyMapping: Map<String, String>): Map<String, Any> {
+ val resolvedInputKeyMapping = HashMap<String, Any>()
+ if (MapUtils.isNotEmpty(inputKeyMapping)) {
+ for ((key, value) in inputKeyMapping) {
+ val resultValue = raRuntimeService.getResolutionStore(value)
+ val expressionValue = JacksonUtils.getValue(resultValue)
+ log.trace("Reference dictionary key ({}), value ({})", key, expressionValue)
+ resolvedInputKeyMapping[key] = expressionValue
+ }
+ }
+ return resolvedInputKeyMapping
+ }
+
+ open fun resolveFromInputKeyMapping(valueToResolve: String, keyMapping: Map<String, Any>): String {
+ if (valueToResolve.isEmpty() || !valueToResolve.contains("$")) {
+ return valueToResolve
+ }
+ return BluePrintTemplateService.generateContent(valueToResolve, additionalContext = keyMapping)
}
override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 37b4774a..f279f544 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -20,8 +20,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.MissingNode
-import com.fasterxml.jackson.databind.node.NullNode
-import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
@@ -63,11 +61,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
validate(resourceAssignment)
// Check if It has Input
- val value = raRuntimeService.getInputValue(resourceAssignment.name)
- if (value !is MissingNode && value !is NullNode) {
- logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
- ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- } else {
+ val value = getFromInput(resourceAssignment)
+ if (value == null || value is MissingNode) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
@@ -78,17 +73,22 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
val sourceProperties =
JacksonUtils.getInstanceFromMap(resourceSourceProperties, RestResourceSource::class.java)
-
- val urlPath =
- checkNotNull(sourceProperties.urlPath) { "failed to get request urlPath for $dName under $dSource properties" }
val path = nullToEmpty(sourceProperties.path)
val inputKeyMapping =
checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+ val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping)
+
+ // Resolving content Variables
+ val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping)
+ val urlPath =
+ resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
+ val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
// Get the Rest Client Service
val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
- val response = restClientService.getResource(urlPath, String::class.java)
+
+ val response = restClientService.exchangeResource(verb, urlPath, payload)
if (response.isBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
} else {
@@ -104,8 +104,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
}
- open fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
- restResourceSource: RestResourceSource): BlueprintWebClientService {
+ private fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
+ restResourceSource: RestResourceSource): BlueprintWebClientService {
return if (checkNotEmpty(restResourceSource.endpointSelector)) {
val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!)
blueprintRestLibPropertyService.blueprintWebClientService(restPropertiesJson)
@@ -165,7 +165,9 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
else -> {
// Complex Types
- val objectNode = responseNode as ObjectNode
+ entrySchemaType =
+ returnNotEmptyOrThrow(resourceAssignment.property?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ val objectNode = JsonNodeFactory.instance.objectNode()
outputKeyMapping.map {
val responseKeyValue = responseNode.get(it.key)
val propertyTypeForDataType =
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index b5b126ab..d55ccacb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -24,7 +24,13 @@ 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.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
@@ -36,7 +42,6 @@ class ResourceAssignmentUtils {
private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
// TODO("Modify Value type from Any to JsonNode")
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun setResourceDataValue(resourceAssignment: ResourceAssignment,
raRuntimeService: ResourceAssignmentRuntimeService, value: Any?) {
@@ -85,7 +90,6 @@ class ResourceAssignmentUtils {
}
- @Synchronized
fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
if (checkNotEmpty(resourceAssignment.name)) {
resourceAssignment.updatedDate = Date()
@@ -95,7 +99,6 @@ class ResourceAssignmentUtils {
}
}
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
@@ -105,7 +108,6 @@ class ResourceAssignmentUtils {
}
}
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
val result: String
@@ -139,10 +141,6 @@ class ResourceAssignmentUtils {
return resourceAssignmentRuntimeService
}
- /*
- * Populate the Field property type for the Data type
- */
- @Synchronized
@Throws(BluePrintProcessorException::class)
fun getPropertyType(raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String, propertyName: String): String {
lateinit var type: String
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index f779054e..6da3fd71 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -21,6 +21,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
@@ -36,7 +37,8 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [CapabilityResourceResolutionProcessor::class, BluePrintScriptsServiceImpl::class,
+@ContextConfiguration(classes = [CapabilityResourceResolutionProcessor::class, ComponentFunctionScriptingService::class,
+ BluePrintScriptsServiceImpl::class,
BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::class])
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
@@ -62,9 +64,11 @@ class CapabilityResourceResolutionProcessorTest {
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
scriptPropertyInstances["mock-service2"] = MockCapabilityService()
+ val instanceDependencies: List<String> = listOf()
+
val resourceAssignmentProcessor = capabilityResourceResolutionProcessor
- .getKotlinResourceAssignmentProcessorInstance(
- "ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", scriptPropertyInstances)
+ .scriptInstance("kotlin",
+ "ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", instanceDependencies)
assertNotNull(resourceAssignmentProcessor, "couldn't get kotlin script resource assignment processor")
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
index fe89291c..b565eec8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
@@ -11,7 +11,7 @@
"type": "source-capability",
"properties": {
"script-type": "jython",
- "script-class-reference": "SampleRAProcessor",
+ "script-class-reference": "Scripts/python/SampleRAProcessor.py",
"instance-dependencies": []
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
index 7c5aecb7..1f8251bd 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
@@ -36,16 +36,14 @@
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>db-resources</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>blueprint-validation</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 9d5dc51c..e1c07ddb 100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -3,6 +3,7 @@
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Modifications Copyright © 2019 Bell Canada.
+ ~ Modifications Copyright © 2019 IBM.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -16,7 +17,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -30,9 +32,9 @@
<description>Blueprints Processor Commons</description>
<modules>
+ <module>processor-core</module>
<module>db-lib</module>
<module>rest-lib</module>
- <module>core</module>
<module>dmaap-lib</module>
</modules>
<dependencies>
@@ -42,6 +44,11 @@
</dependency>
<!-- Test Dependencies -->
<dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
@@ -57,6 +64,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
diff --git a/ms/blueprintsprocessor/modules/commons/core/pom.xml b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
index 42710b51..aadff9c9 100644
--- a/ms/blueprintsprocessor/modules/commons/core/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/pom.xml
@@ -24,7 +24,7 @@
<version>0.4.1-SNAPSHOT</version>
</parent>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
<packaging>jar</packaging>
<name>Blueprints Processor Core</name>
<description>Blueprints Processor Core</description>
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
index 07e494a1..07e494a1 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
index 10b8ceb5..10b8ceb5 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index 41bbd1df..41bbd1df 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
index 66643ee0..9c6e5075 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
@@ -1,68 +1,68 @@
-/*
- * 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.blueprintsprocessor.core.factory
-
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.springframework.context.ApplicationContext
-import org.springframework.context.ApplicationContextAware
-
-/**
- * ComponentNode
- *
- * @author Brinda Santh
- */
-interface ComponentNode {
-
- @Throws(BluePrintProcessorException::class)
- fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-
- @Throws(BluePrintProcessorException::class)
- fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-
- @Throws(BluePrintProcessorException::class)
- fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-
- @Throws(BluePrintProcessorException::class)
- fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
-}
-
-/**
- * ComponentNodeFactory
- *
- * @author Brinda Santh
- */
-open class ComponentNodeFactory : ApplicationContextAware {
- private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
-
- var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
-
- fun getInstance(instanceName: String): ComponentNode? {
- log.trace("looking for Component Nodes : {}", instanceName)
- return componentNodes.get(instanceName)
- }
-
- fun injectInstance(instanceName: String, componentNode: ComponentNode) {
- this.componentNodes[instanceName] = componentNode
- }
-
- override fun setApplicationContext(context: ApplicationContext) {
- componentNodes = context.getBeansOfType(ComponentNode::class.java)
- log.info("Injected Component Nodes : {}", componentNodes)
- }
+/*
+ * 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.blueprintsprocessor.core.factory
+
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.context.ApplicationContext
+import org.springframework.context.ApplicationContextAware
+
+/**
+ * ComponentNode
+ *
+ * @author Brinda Santh
+ */
+interface ComponentNode {
+
+ @Throws(BluePrintProcessorException::class)
+ fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+
+ @Throws(BluePrintProcessorException::class)
+ fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>)
+}
+
+/**
+ * ComponentNodeFactory
+ *
+ * @author Brinda Santh
+ */
+open class ComponentNodeFactory : ApplicationContextAware {
+ private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
+
+ var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
+
+ fun getInstance(instanceName: String): ComponentNode? {
+ log.trace("looking for Component Nodes : {}", instanceName)
+ return componentNodes.get(instanceName)
+ }
+
+ fun injectInstance(instanceName: String, componentNode: ComponentNode) {
+ this.componentNodes[instanceName] = componentNode
+ }
+
+ override fun setApplicationContext(context: ApplicationContext) {
+ componentNodes = context.getBeansOfType(ComponentNode::class.java)
+ log.info("Injected Component Nodes : {}", componentNodes)
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
index 31dca33b..31dca33b 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties
index 2ce87147..c10e96ee 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/resources/application.properties
@@ -1,16 +1,16 @@
-#
-# 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.
-#
-
+#
+# 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.
+#
+
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt
index 66de11fd..66de11fd 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintPropertiesTest.kt
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
index f1d97896..625297bf 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
@@ -15,7 +15,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -34,7 +35,12 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${apache.httpcomponents.client.version}</version>
</dependency>
</dependencies>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
index f63e39f3..7af91c6f 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
@@ -30,6 +30,7 @@ open class BluePrintRestLibConfiguration
class RestLibConstants {
companion object {
const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
+ const val TYPE_TOKEN_AUTH = "token-auth"
const val TYPE_BASIC_AUTH = "basic-auth"
const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
const val TYPE_DME2_PROXY = "dme2-proxy"
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
index 41e45458..dd4d9f7d 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
@@ -19,19 +19,23 @@ package org.onap.ccsdk.apps.blueprintsprocessor.rest
open class RestClientProperties {
lateinit var type: String
lateinit var url: String
- lateinit var userId: String
}
open class BasicAuthRestClientProperties : RestClientProperties() {
+ lateinit var password: String
+ lateinit var username: String
+}
+
+open class TokenAuthRestClientProperties : RestClientProperties() {
var token: String? = null
}
open class SSLBasicAuthRestClientProperties : RestClientProperties() {
lateinit var keyStoreInstance: String // JKS, PKCS12
lateinit var sslTrust: String
- lateinit var sslTrustPasswd: String
+ lateinit var sslTrustPassword: String
lateinit var sslKey: String
- lateinit var sslKeyPasswd: String
+ lateinit var sslKeyPassword: String
}
open class DME2RestClientProperties : RestClientProperties() {
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
index 130706d7..0502f67c 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,67 +16,31 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import org.apache.http.message.BasicHeader
import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
-import org.springframework.web.reactive.function.BodyInserters
-import org.springframework.web.reactive.function.client.ExchangeFilterFunctions
-import org.springframework.web.reactive.function.client.WebClient
-
-
-class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) : BlueprintWebClientService {
-
- private var webClient: WebClient? = null
-
- override fun webClient(): WebClient {
- if (webClient == null) {
- webClient = WebClient.builder()
- .baseUrl(restClientProperties.url)
- .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
- .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
- .filter(ExchangeFilterFunctions
- .basicAuthentication(restClientProperties.userId, restClientProperties.token))
- .filter(WebClientUtils.logRequest())
- .filter(WebClientUtils.logResponse())
- .build()
- }
- return webClient!!
- }
-
- override fun <T> getResource(path: String, responseType: Class<T>): T {
- return getResource(path, null, responseType)
- }
-
- override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
- return webClient().get()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .retrieve()
- .bodyToMono(responseType).block()!!
- }
-
- override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- return postResource(path, null, request, responseType)
+import java.nio.charset.Charset
+import java.util.*
+
+class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) :
+ BlueprintWebClientService {
+
+ override fun headers(): Array<BasicHeader> {
+ val encodedCredentials = setBasicAuth(restClientProperties.username, restClientProperties.password)
+ val params = arrayListOf<BasicHeader>()
+ params.add(BasicHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.AUTHORIZATION, "Basic $encodedCredentials"))
+ return params.toTypedArray()
}
- override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
- return webClient().post()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .body(BodyInserters.fromObject(request))
- .retrieve().bodyToMono(responseType).block()!!
+ override fun host(uri: String): String {
+ return restClientProperties.url + uri
}
- override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ private fun setBasicAuth(username: String, password: String): String {
+ val credentialsString = "$username:$password"
+ return Base64.getEncoder().encodeToString(credentialsString.toByteArray(Charset.defaultCharset()))
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
index 705caa2e..3888bb72 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
* Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,13 @@ package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.DME2RestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.PolicyManagerRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.TokenAuthRestClientProperties
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@@ -27,6 +33,17 @@ import org.springframework.stereotype.Service
@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
+ fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
+ val restClientProperties = restClientProperties(jsonNode)
+ return blueprintWebClientService(restClientProperties)
+ }
+
+ fun blueprintWebClientService(selector: String): BlueprintWebClientService {
+ val prefix = "blueprintsprocessor.restclient.$selector"
+ val restClientProperties = restClientProperties(prefix)
+ return blueprintWebClientService(restClientProperties)
+ }
+
fun restClientProperties(prefix: String): RestClientProperties {
val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
return when (type) {
@@ -48,9 +65,12 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
+ private fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
val type = jsonNode.get("type").textValue()
return when (type) {
+ RestLibConstants.TYPE_TOKEN_AUTH -> {
+ JacksonUtils.readValue(jsonNode, TokenAuthRestClientProperties::class.java)!!
+ }
RestLibConstants.TYPE_BASIC_AUTH -> {
JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!!
}
@@ -69,20 +89,11 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
-
- fun blueprintWebClientService(selector: String): BlueprintWebClientService {
- val prefix = "blueprintsprocessor.restclient.$selector"
- val restClientProperties = restClientProperties(prefix)
- return blueprintWebClientService(restClientProperties)
- }
-
- fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
- val restClientProperties = restClientProperties(jsonNode)
- return blueprintWebClientService(restClientProperties)
- }
-
- fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
+ private fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
when (restClientProperties) {
+ is TokenAuthRestClientProperties -> {
+ return TokenAuthRestClientService(restClientProperties)
+ }
is BasicAuthRestClientProperties -> {
return BasicAuthRestClientService(restClientProperties)
}
@@ -98,19 +109,19 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
+ private fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
}
- fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
+ private fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
}
- fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
+ private fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
}
- fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
+ private fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
}
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
index 8106c077..9c2caad7 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,21 +16,76 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-import org.springframework.web.reactive.function.client.WebClient
+import org.apache.commons.io.IOUtils
+import org.apache.http.client.methods.HttpDelete
+import org.apache.http.client.methods.HttpGet
+import org.apache.http.client.methods.HttpPost
+import org.apache.http.client.methods.HttpPut
+import org.apache.http.entity.StringEntity
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
+import org.apache.http.message.BasicHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.http.HttpMethod
+import java.nio.charset.Charset
interface BlueprintWebClientService {
- fun webClient(): WebClient
+ fun headers(): Array<BasicHeader>
- fun <T> getResource(path: String, responseType: Class<T>): T
+ fun host(uri: String): String
- fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T
+ fun httpClient(): CloseableHttpClient {
+ return HttpClients.custom()
+ .addInterceptorFirst(WebClientUtils.logRequest())
+ .addInterceptorLast(WebClientUtils.logResponse())
+ .build()
+ }
- fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+ fun exchangeResource(methodType: String, path: String, request: String): String {
+ return when (HttpMethod.resolve(methodType)) {
+ HttpMethod.DELETE -> delete(path)
+ HttpMethod.GET -> get(path)
+ HttpMethod.POST -> post(path, request)
+ HttpMethod.PUT -> put(path, request)
+ else -> throw BluePrintProcessorException("Unsupported methodType($methodType)")
+ }
+ }
- fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T
+ fun delete(path: String): String {
+ val httpDelete = HttpDelete(host(path))
+ httpDelete.setHeaders(headers())
+ httpClient().execute(httpDelete).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
- fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
+ fun get(path: String): String {
+ val httpGet = HttpGet(host(path))
+ httpGet.setHeaders(headers())
+ httpClient().execute(httpGet).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
-}
+ fun post(path: String, request: String): String {
+ val httpPost = HttpPost(host(path))
+ val entity = StringEntity(request)
+ httpPost.entity = entity
+ httpPost.setHeaders(headers())
+ httpClient().execute(httpPost).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
+ fun put(path: String, request: String): String {
+ val httpPut = HttpPut(host(path))
+ val entity = StringEntity(request)
+ httpPut.entity = entity
+ httpPut.setHeaders(headers())
+ httpClient().execute(httpPut).entity.content.use {
+ return IOUtils.toString(it, Charset.defaultCharset())
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
index 27dbe6f8..2b2578a3 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,31 +16,15 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import org.apache.http.message.BasicHeader
import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
-import org.springframework.web.reactive.function.client.WebClient
class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
- override fun webClient(): WebClient {
+ override fun headers(): Array<BasicHeader> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
- override fun <T> getResource(path: String, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+ override fun host(uri: String): String {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
index 71727b93..dc2993d9 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
@@ -1,5 +1,5 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2019 AT&T, Bell Canada
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,82 +16,59 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-import io.netty.handler.ssl.SslContextBuilder
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
+import org.apache.http.message.BasicHeader
+import org.apache.http.ssl.SSLContextBuilder
import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
-import org.springframework.http.client.reactive.ReactorClientHttpConnector
-import org.springframework.web.reactive.function.BodyInserters
-import org.springframework.web.reactive.function.client.WebClient
-import reactor.netty.http.client.HttpClient
import java.io.File
+import java.io.FileInputStream
import java.security.KeyStore
import java.security.cert.X509Certificate
+class SSLBasicAuthRestClientService(private val restClientProperties: SSLBasicAuthRestClientProperties) :
+ BlueprintWebClientService {
-class SSLBasicAuthRestClientService(private val restClientProperties: SSLBasicAuthRestClientProperties) : BlueprintWebClientService {
+ override fun headers(): Array<BasicHeader> {
+ val params = arrayListOf<BasicHeader>()
+ params.add(BasicHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
+ return params.toTypedArray()
+ }
- override fun webClient(): WebClient {
+ override fun host(uri: String): String {
+ return restClientProperties.url + uri
+ }
- // Load the Keystore Information
- val ketInputStream = File(restClientProperties.sslKey).inputStream()
- val ks = KeyStore.getInstance(restClientProperties.keyStoreInstance)
- ks.load(ketInputStream, restClientProperties.sslKeyPasswd.toCharArray())
+ override fun httpClient(): CloseableHttpClient {
- // Manage Trust Store
- val trustCertCollection = ks.aliases().toList().map { alias ->
- ks.getCertificate(alias) as X509Certificate
- }.toTypedArray()
- val sslContext = SslContextBuilder
- .forClient()
- .trustManager(*trustCertCollection)
- .build()
+ val keystoreInstance = restClientProperties.keyStoreInstance
+ val sslKey = restClientProperties.sslKey
+ val sslKeyPwd = restClientProperties.sslKeyPassword
+ val sslTrust = restClientProperties.sslTrust
+ val sslTrustPwd = restClientProperties.sslTrustPassword
- // Create Http Client
- val httpClient = HttpClient.create().secure { t -> t.sslContext(sslContext) }
+ val acceptingTrustStrategy = { chain: Array<X509Certificate>, authType: String -> true }
- return WebClient.builder()
- .baseUrl(restClientProperties.url)
- .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
- .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
- .filter(WebClientUtils.logRequest())
- .clientConnector(ReactorClientHttpConnector(httpClient)).build()
- }
+ FileInputStream(sslKey).use { keyInput ->
+ val keyStore = KeyStore.getInstance(keystoreInstance)
+ keyStore.load(keyInput, sslKeyPwd.toCharArray())
- override fun <T> getResource(path: String, responseType: Class<T>): T {
- return getResource(path, null, responseType)
- }
+ val sslContext =
+ SSLContextBuilder.create()
+ .loadKeyMaterial(keyStore, sslKeyPwd.toCharArray())
+ .loadTrustMaterial(File(sslTrust), sslTrustPwd.toCharArray(), acceptingTrustStrategy).build()
- override fun <T> getResource(path: String, headers: Map<String, String>?, responseType: Class<T>): T {
- return webClient().get()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .retrieve()
- .bodyToMono(responseType).block()!!
- }
-
- override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
- return postResource(path, null, request, responseType)
- }
-
- override fun <T> postResource(path: String, headers: Map<String, String>?, request: Any, responseType: Class<T>): T {
- return webClient().post()
- .uri(path)
- .headers { httpHeaders ->
- headers?.forEach {
- httpHeaders.set(it.key, it.value)
- }
- }
- .body(BodyInserters.fromObject(request))
- .retrieve().bodyToMono(responseType).block()!!
- }
+ val csf = SSLConnectionSocketFactory(sslContext!!)
- override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ return HttpClients.custom()
+ .addInterceptorFirst(WebClientUtils.logRequest())
+ .addInterceptorLast(WebClientUtils.logResponse())
+ .setSSLSocketFactory(csf).build()
+ }
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
new file mode 100644
index 00000000..6e90957d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
@@ -0,0 +1,38 @@
+/*
+ * 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.blueprintsprocessor.rest.service
+
+import org.apache.http.message.BasicHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.TokenAuthRestClientProperties
+import org.springframework.http.HttpHeaders
+import org.springframework.http.MediaType
+
+class TokenAuthRestClientService(private val restClientProperties: TokenAuthRestClientProperties) :
+ BlueprintWebClientService {
+
+ override fun headers(): Array<BasicHeader> {
+ val params = arrayListOf<BasicHeader>()
+ params.add(BasicHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
+ params.add(BasicHeader(HttpHeaders.AUTHORIZATION, restClientProperties.token))
+ return params.toTypedArray()
+ }
+
+ override fun host(uri: String): String {
+ return restClientProperties.url + uri
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
index 40d6ba63..d6167a87 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
@@ -16,29 +16,20 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.utils
+import org.apache.http.HttpRequestInterceptor
+import org.apache.http.HttpResponseInterceptor
+import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import org.springframework.web.reactive.function.client.ExchangeFilterFunction
-import reactor.core.publisher.Mono
-
class WebClientUtils {
companion object {
- val log = LoggerFactory.getLogger(WebClientUtils::class.java)!!
-
- fun logRequest(): ExchangeFilterFunction {
+ val log: Logger = LoggerFactory.getLogger(WebClientUtils::class.java)
- return ExchangeFilterFunction.ofRequestProcessor { clientRequest ->
- log.info("Rest request method(${clientRequest.method()}), url(${clientRequest.url()})")
- Mono.just(clientRequest)
- }
- }
+ fun logRequest(): HttpRequestInterceptor =
+ HttpRequestInterceptor { request, _ -> log.info("Rest request method(${request?.requestLine?.method}), url(${request?.requestLine?.uri})") }
- fun logResponse(): ExchangeFilterFunction {
- return ExchangeFilterFunction.ofResponseProcessor { clientResponse ->
- log.info("Response status(${clientResponse.statusCode()})")
- Mono.just(clientResponse)
- }
- }
+ fun logResponse(): HttpResponseInterceptor =
+ HttpResponseInterceptor { response, _ -> log.info("Response status(${response.statusLine.statusCode})") }
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
index 25821966..4fa82df2 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.http.HttpMethod
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@@ -39,11 +40,10 @@ import kotlin.test.assertNotNull
@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class,
SampleController::class, BluePrintProperties::class, BluePrintProperties::class])
@TestPropertySource(properties =
-["server.port=9111",
- "blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:9111",
- "blueprintsprocessor.restclient.sample.userId=sampleuser",
- "blueprintsprocessor.restclient.sample.token=sampletoken"])
+["blueprintsprocessor.restclient.sample.type=basic-auth",
+ "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8080",
+ "blueprintsprocessor.restclient.sample.username=sampleuser",
+ "blueprintsprocessor.restclient.sample.password=sampletoken"])
class RestClientServiceTest {
@Autowired
@@ -51,11 +51,10 @@ class RestClientServiceTest {
@Test
fun testBaseAuth() {
-
val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
val headers = mutableMapOf<String, String>()
headers["X-Transaction-Id"] = "1234"
- val response = restClientService.getResource("/sample/name", headers, String::class.java)
+ val response = restClientService.exchangeResource(HttpMethod.GET.name, "/sample/name", "")
assertNotNull(response, "failed to get response")
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index d7c0cc4f..273abd51 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~ Modifications Copyright © 2019 IBM.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -64,6 +65,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
index aadbec83..ebeda69b 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +18,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import io.grpc.stub.StreamObserver
+import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toJava
import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
@@ -28,18 +30,20 @@ import org.springframework.stereotype.Service
@Service
open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
- private val executionServiceHandler: ExecutionServiceHandler)
+ private val executionServiceHandler: ExecutionServiceHandler)
: BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
@PreAuthorize("hasRole('USER')")
override fun process(
- responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
+ responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
try {
- executionServiceHandler.process(executionServiceInput.toJava(), responseObserver)
+ runBlocking {
+ executionServiceHandler.process(executionServiceInput.toJava(), responseObserver)
+ }
} catch (e: Exception) {
onError(e)
}
@@ -48,8 +52,8 @@ open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration
override fun onError(error: Throwable) {
log.debug("Fail to process message", error)
responseObserver.onError(io.grpc.Status.INTERNAL
- .withDescription(error.message)
- .asException())
+ .withDescription(error.message)
+ .asException())
}
override fun onCompleted() {
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index 16f0fa86..6e729479 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +18,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
import io.swagger.annotations.ApiOperation
+import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
@@ -24,13 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.http.codec.multipart.FilePart
import org.springframework.security.access.prepost.PreAuthorize
-import org.springframework.web.bind.annotation.PostMapping
-import org.springframework.web.bind.annotation.RequestBody
-import org.springframework.web.bind.annotation.RequestMapping
-import org.springframework.web.bind.annotation.RequestMethod
-import org.springframework.web.bind.annotation.RequestPart
-import org.springframework.web.bind.annotation.ResponseBody
-import org.springframework.web.bind.annotation.RestController
+import org.springframework.web.bind.annotation.*
import reactor.core.publisher.Mono
@RestController
@@ -42,8 +38,8 @@ open class ExecutionServiceController {
@RequestMapping(path = ["/ping"], method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
- fun ping(): Mono<String> {
- return Mono.just("Success")
+ fun ping(): String = runBlocking {
+ "Success"
}
@PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@@ -52,20 +48,20 @@ open class ExecutionServiceController {
@PreAuthorize("hasRole('USER')")
fun upload(@RequestPart("file") parts: Mono<FilePart>): Mono<String> {
return parts
- .filter { it is FilePart }
- .ofType(FilePart::class.java)
- .flatMap(executionServiceHandler::upload)
+ .filter { it is FilePart }
+ .ofType(FilePart::class.java)
+ .flatMap(executionServiceHandler::upload)
}
@RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
@ApiOperation(value = "Resolve Resource Mappings",
- notes = "Takes the blueprint information and process as per the payload")
+ notes = "Takes the blueprint information and process as per the payload")
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput = runBlocking {
if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
}
- return executionServiceHandler.processSync(executionServiceInput)
+ executionServiceHandler.doProcess(executionServiceInput)
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index 5278c17e..d8afe168 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,18 +23,14 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.*
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.saveCBAFile
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
@@ -44,7 +41,8 @@ import reactor.core.publisher.Mono
@Service
class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
private val bluePrintCatalogService: BluePrintCatalogService,
- private val blueprintDGExecutionService: BlueprintDGExecutionService) {
+ private val bluePrintWorkflowExecutionService
+ : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>) {
private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
@@ -60,8 +58,8 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
}
}
- fun process(executionServiceInput: ExecutionServiceInput,
- responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>) {
+ suspend fun process(executionServiceInput: ExecutionServiceInput,
+ responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>) {
when {
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> {
GlobalScope.launch(Dispatchers.Default) {
@@ -77,16 +75,12 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
responseObserver.onCompleted()
}
else -> responseObserver.onNext(response(executionServiceInput,
- "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
- true).toProto());
+ "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
+ true).toProto());
}
}
- fun processSync(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
- return doProcess(executionServiceInput)
- }
-
- private fun doProcess(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ suspend fun doProcess(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
val requestId = executionServiceInput.commonHeader.requestId
log.info("processing request id $requestId")
@@ -100,7 +94,8 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString())
- return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
+ return bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService,
+ executionServiceInput, hashMapOf())
}
private fun response(executionServiceInput: ExecutionServiceInput, errorMessage: String = "",
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index df68b952..f5e3b3d0 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -44,7 +44,7 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>processor-core</artifactId>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -67,26 +67,5 @@
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-provider</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-test-junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index a67e006a..f2b6e3ff 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -26,11 +26,10 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.asObjectNode
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
/**
@@ -51,8 +50,11 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
lateinit var operationName: String
lateinit var nodeTemplateName: String
var operationInputs: MutableMap<String, JsonNode> = hashMapOf()
+
+ //FIXME("Move to Script abstract class")
/**
- * Store Dynamic Dependency Instances
+ * Store Dynamic Script Dependency Instances, Objects present inside won't be persisted or state maintained.
+ * Later it will be moved to ScriptComponentFunction class, sub class for abstract class
*/
var functionDependencyInstances: MutableMap<String, Any> = hashMapOf()
@@ -91,7 +93,8 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)
check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }
- val operationResolvedProperties = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
+ val operationResolvedProperties = bluePrintRuntimeService
+ .resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
this.operationInputs.putAll(operationResolvedProperties)
@@ -103,15 +106,16 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
-
// Resolve the Output Expression
val stepOutputs = bluePrintRuntimeService
.resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
- bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asJsonNode())
+ // FIXME("Not the right place to populate the response payload")
+ executionServiceOutput.payload = stepOutputs.asObjectNode()
- executionServiceOutput.payload = JacksonUtils.objectNodeFromObject(stepOutputs)
+ bluePrintRuntimeService.put("$stepName-step-outputs", executionServiceOutput.payload)
+ // FIXME("Not the right place to populate the status")
// Populate Status
val status = Status()
status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name
@@ -122,8 +126,12 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
}
override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
- prepareRequest(executionServiceInput)
- process(executionServiceInput)
+ try {
+ prepareRequest(executionServiceInput)
+ process(executionServiceInput)
+ } catch (runtimeException: RuntimeException) {
+ recover(runtimeException, executionServiceInput)
+ }
return prepareResponse()
}
@@ -136,6 +144,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName, key, value)
}
+ //FIXME("Move to Script abstract class")
/**
* This will be called from the scripts to serve instance from runtime to scripts.
*/
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
index ecdd454e..9bae4eb3 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
@@ -20,6 +20,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.Bluepr
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
@@ -34,19 +35,24 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
fun <T : AbstractComponentFunction> scriptInstance(componentFunction: AbstractComponentFunction, scriptType: String,
scriptClassReference: String,
- instanceDependencies: MutableList<String>): T {
+ instanceDependencies: List<String>): T {
+
log.info("creating component function of script type($scriptType), reference name($scriptClassReference) and " +
"instanceDependencies($instanceDependencies)")
val scriptComponent: T = scriptInstance(componentFunction.bluePrintRuntimeService.bluePrintContext(),
scriptType, scriptClassReference)
- populateScriptDependencies(scriptComponent, instanceDependencies)
+ // Populate Instance Properties
+ instanceDependencies.forEach { instanceDependency ->
+ componentFunction.functionDependencyInstances[instanceDependency] = applicationContext
+ .getBean(instanceDependency)
+ }
return scriptComponent
}
- fun <T : AbstractComponentFunction> scriptInstance(bluePrintContext: BluePrintContext, scriptType: String,
- scriptClassReference: String): T {
+ fun <T : BlueprintFunctionNode<*, *>> scriptInstance(bluePrintContext: BluePrintContext, scriptType: String,
+ scriptClassReference: String): T {
var scriptComponent: T? = null
when (scriptType) {
@@ -66,12 +72,4 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
return scriptComponent
}
-
- private fun populateScriptDependencies(componentFunction: AbstractComponentFunction,
- instanceDependencies: MutableList<String>) {
- instanceDependencies.forEach { instanceDependency ->
- componentFunction.functionDependencyInstances[instanceDependency] = applicationContext
- .getBean(instanceDependency)
- }
- }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
index 9c039016..3937f27c 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
@@ -22,6 +22,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractCompon
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.Logger
@@ -55,7 +56,7 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
}
fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String):
- AbstractComponentFunction {
+ BlueprintFunctionNode<*, *> {
val blueprintBasePath: String = bluePrintContext.rootPath
val pythonFileName = bluePrintContext.rootPath
@@ -74,7 +75,7 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
val jythonInstances: MutableMap<String, Any> = hashMapOf()
jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
- return jythonInstance<AbstractComponentFunction>(bluePrintContext, pythonClassName,
+ return jythonInstance<BlueprintFunctionNode<*, *>>(bluePrintContext, pythonClassName,
content, jythonInstances)
}
diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml
index 469899d0..4388eeb9 100755
--- a/ms/blueprintsprocessor/modules/services/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/pom.xml
@@ -3,6 +3,7 @@
~ Copyright © 2017-2018 AT&T Intellectual Property.
~
~ Modifications Copyright © 2019 Bell Canada.
+ ~ Modifications Copyright © 2019 IBM.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -33,4 +34,38 @@
<module>execution-service</module>
<module>workflow-service</module>
</modules>
+
+ <dependencies>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
index 4f929064..634d2233 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml
@@ -40,27 +40,6 @@
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-provider</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-test-junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
new file mode 100644
index 00000000..73f6f497
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service("bluePrintWorkflowExecutionService")
+open class BluePrintWorkflowExecutionServiceImpl(
+ private val componentWorkflowExecutionService: ComponentWorkflowExecutionService,
+ private val dgWorkflowExecutionService: DGWorkflowExecutionService
+) : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+
+ private val log = LoggerFactory.getLogger(BluePrintWorkflowExecutionServiceImpl::class.java)!!
+
+ override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>): ExecutionServiceOutput {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ // Get the DG Node Template
+ val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
+
+ val derivedFrom = bluePrintContext.nodeTemplateNodeType(nodeTemplateName).derivedFrom
+
+ log.info("Executing workflow($workflowName) NodeTemplate($nodeTemplateName), derived from($derivedFrom)")
+
+ val executionServiceOutput: ExecutionServiceOutput = when {
+ derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> {
+ componentWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ }
+ derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_DG, true) -> {
+ dgWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, properties)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't execute workflow($workflowName) step mapped " +
+ "to node template($nodeTemplateName) derived from($derivedFrom)")
+ }
+ }
+
+ executionServiceOutput.commonHeader = executionServiceInput.commonHeader
+ executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
+ // TODO("Populate Response Payload and status")
+ return executionServiceOutput
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
index dfa22f68..fd7ec45b 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +36,7 @@ interface BlueprintSvcLogicService : SvcLogicServiceBase {
fun unRegisterExecutors(name: String)
- fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any
+ suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any
@Deprecated("Populate Graph Dynamically from Blueprints, No need to get from Database Store ")
override fun getStore(): SvcLogicStore {
@@ -87,7 +88,8 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
}
}
- override fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any {
+ override suspend fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ input: Any): Any {
//Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
val blueprintSvcLogicContext = BlueprintSvcLogicContext()
blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
new file mode 100644
index 00000000..76d0c46b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
+
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+
+@Service("componentWorkflowExecutionService")
+open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
+ : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
+
+ override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>): ExecutionServiceOutput {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ // Get the DG Node Template
+ val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
+
+ // Assign Workflow inputs
+ val input = executionServiceInput.payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
+ return nodeTemplateExecutionService.executeNodeTemplate(bluePrintRuntimeService,
+ nodeTemplateName, executionServiceInput)
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
index 8ba02ac8..262b1be1 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,26 +20,22 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.io.File
-interface BlueprintDGExecutionService {
+@Service("dgWorkflowExecutionService")
+open class DGWorkflowExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService)
+ : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput> {
- fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput
+ private val log = LoggerFactory.getLogger(DGWorkflowExecutionService::class.java)
-}
-
-@Service
-class DefaultBlueprintDGExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService) : BlueprintDGExecutionService {
-
- private val log = LoggerFactory.getLogger(DefaultBlueprintDGExecutionService::class.java)
-
- override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput,
+ properties: MutableMap<String, Any>): ExecutionServiceOutput {
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
new file mode 100644
index 00000000..6ce4753b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/NodeTemplateExecutionService.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
+
+import com.fasterxml.jackson.databind.JsonNode
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+open class NodeTemplateExecutionService(private val applicationContext: ApplicationContext) {
+
+ private val log = LoggerFactory.getLogger(NodeTemplateExecutionService::class.java)!!
+
+ suspend fun executeNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ // Get the Blueprint Context
+ val blueprintContext = bluePrintRuntimeService.bluePrintContext()
+ // Get the Component Name, NodeTemplate type is mapped to Component Name
+ val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type
+
+ val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+
+ val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+ log.info("executing node template($nodeTemplateName) component($componentName) " +
+ "interface($interfaceName) operation($operationName)")
+
+ // Get the Component Instance
+ val plugin = applicationContext.getBean(componentName, AbstractComponentFunction::class.java)
+ // Set the Blueprint Service
+ plugin.bluePrintRuntimeService = bluePrintRuntimeService
+ plugin.stepName = nodeTemplateName
+
+ // Populate Step Meta Data
+ val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+ stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+ plugin.bluePrintRuntimeService.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+
+ // Get the Request from the Context and Set to the Function Input and Invoke the function
+ return withContext(Dispatchers.Default) {
+ plugin.apply(executionServiceInput)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
index 7a59a0ab..1e856b68 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,16 +17,10 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor
-import com.fasterxml.jackson.databind.JsonNode
-import kotlinx.coroutines.async
-import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
-import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.NodeTemplateExecutionService
import org.onap.ccsdk.sli.core.sli.SvcLogicContext
import org.onap.ccsdk.sli.core.sli.SvcLogicException
import org.onap.ccsdk.sli.core.sli.SvcLogicNode
@@ -33,33 +28,17 @@ import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor
import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver
import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase
import org.slf4j.LoggerFactory
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
@Service
-open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
+open class ComponentExecuteNodeExecutor(private val nodeTemplateExecutionService: NodeTemplateExecutionService)
+ : ExecuteNodeExecutor() {
private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
- @Autowired
- private lateinit var context: ApplicationContext
-
- fun getComponentFunction(pluginName: String): AbstractComponentFunction {
- return context.getBean(pluginName, AbstractComponentFunction::class.java)
- }
-
@Throws(SvcLogicException::class)
override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext)
: SvcLogicNode = runBlocking {
- coroutineScope {
- val job = async { executeAsy(svc, node, svcLogicContext) }
- job.await()
- }
- }
-
-
- private fun executeAsy(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext): SvcLogicNode {
var outValue: String
@@ -67,35 +46,11 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
val nodeTemplateName = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx)
- try {
- // Get the Blueprint Context
- val blueprintContext = ctx.getBluePrintService().bluePrintContext()
- // Get the Component Name, NodeTemplate type is mapped to Component Name
- val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type
+ val executionInput = ctx.getRequest() as ExecutionServiceInput
- val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
-
- val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
-
- log.info("executing node template($nodeTemplateName) component($componentName) interface($interfaceName) operation($operationName)")
- // Get the Component Instance
- val plugin = this.getComponentFunction(componentName)
- // Set the Blueprint Service
- plugin.bluePrintRuntimeService = ctx.getBluePrintService()
- plugin.stepName = nodeTemplateName
-
- val executionInput = ctx.getRequest() as ExecutionServiceInput
-
- // Populate Step Meta Data
- val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
- stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
- stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
- stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
-
- plugin.bluePrintRuntimeService.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
-
- // Get the Request from the Context and Set to the Function Input and Invoke the function
- val executionOutput = plugin.apply(executionInput)
+ try { // Get the Request from the Context and Set to the Function Input and Invoke the function
+ val executionOutput = nodeTemplateExecutionService.executeNodeTemplate(ctx.getBluePrintService(),
+ nodeTemplateName, executionInput)
ctx.setResponse(executionOutput)
@@ -103,11 +58,12 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
ctx.status = executionOutput.status.message
} catch (e: Exception) {
- this.log.error("Could not execute plugin($nodeTemplateName) : ", e)
+ log.error("Could not execute plugin($nodeTemplateName) : ", e)
outValue = "failure"
ctx.status = "failure"
}
- return this.getNextNode(node, outValue)
+ getNextNode(node, outValue)
}
+
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
new file mode 100644
index 00000000..7ac9bc33
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [WorkflowServiceConfiguration::class])
+class BluePrintWorkflowExecutionServiceImplTest {
+
+ @Autowired
+ lateinit var bluePrintWorkflowExecutionService: BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>
+
+ @Test
+ fun testBluePrintWorkflowExecutionService() {
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java)!!
+
+ runBlocking {
+ bluePrintWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput,
+ hashMapOf())
+ }
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
index 6184162f..b374e7d4 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
+import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
@@ -41,7 +43,7 @@ class BlueprintServiceLogicTest {
lateinit var applicationContext: ApplicationContext
@Autowired
- lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
+ lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
@Test
fun testExecuteGraphWithSingleComponent() {
@@ -51,8 +53,10 @@ class BlueprintServiceLogicTest {
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ runBlocking {
+ dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ }
- blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
}
@@ -64,7 +68,9 @@ class BlueprintServiceLogicTest {
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
- blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
+ runBlocking {
+ dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ }
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
index 5369bd32..2e36fb5f 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
+import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
@@ -29,12 +31,12 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
-class BlueprintDGExecutionServiceTest {
+class DGWorkflowExecutionServiceTest {
private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
@Autowired
- lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
+ lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
@Test
@@ -45,7 +47,9 @@ class BlueprintDGExecutionServiceTest {
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
- blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
+ runBlocking {
+ dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ }
}
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 045ce711..210943ae 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -264,10 +264,10 @@
</dependency>
- <!-- Application Module Dependencies -->
+ <!-- Blueprint Processor Application Module Dependencies -->
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>application</artifactId>
+ <artifactId>processor-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -282,7 +282,7 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
- <artifactId>core</artifactId>
+ <artifactId>dmaap-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -305,6 +305,11 @@
<artifactId>selfservice-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>application</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Functions -->
<dependency>
@@ -328,7 +333,7 @@
<version>${project.version}</version>
</dependency>
- <!-- Application Component Dependency -->
+ <!-- Controller Blueprints Application Dependency -->
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
@@ -346,6 +351,11 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>db-resources</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>blueprint-validation</artifactId>
<version>${project.version}</version>
</dependency>
@@ -357,6 +367,7 @@
<version>${h2database.version}</version>
<scope>test</scope>
</dependency>
+
<!-- Test Dependency -->
<dependency>
<groupId>io.mockk</groupId>
diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml
index a5e6f1e5..daa9f0a6 100644
--- a/ms/cds-sdc-listener/application/pom.xml
+++ b/ms/cds-sdc-listener/application/pom.xml
@@ -17,7 +17,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>application</artifactId>
+ <groupId>org.onap.ccsdk.apps</groupId>
+ <artifactId>cds-sdc-listener-application</artifactId>
<name>CDS-SDC Listener Application </name>
<dependencies>
diff --git a/ms/cds-sdc-listener/distribution/pom.xml b/ms/cds-sdc-listener/distribution/pom.xml
index 9ff555fc..f2280783 100644
--- a/ms/cds-sdc-listener/distribution/pom.xml
+++ b/ms/cds-sdc-listener/distribution/pom.xml
@@ -15,7 +15,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>distribution</artifactId>
+ <groupId>org.onap.ccsdk.apps</groupId>
+ <artifactId>cds-sdc-listener-distribution</artifactId>
<name>CDS-SDC Listener Distribution</name>
<properties>
@@ -71,10 +72,10 @@
<build>
<cleanup>try</cleanup>
<dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>
- <imagetags>
- <imageTag>${project.version}</imageTag>
- <imageTag>${project.version}-STAGING-${maven.build.timestamp}</imageTag>
- </imagetags>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-STAGING-${maven.build.timestamp}</tag>
+ </tags>
</build>
</image>
</images>
diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml
index 3998f5f2..0c393db7 100644
--- a/ms/cds-sdc-listener/pom.xml
+++ b/ms/cds-sdc-listener/pom.xml
@@ -22,7 +22,9 @@
<modules>
<module>application</module>
+ <!-- Module is not currently working
<module>distribution</module>
+ -->
</modules>
</project> \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
index 7d98c42d..462935d6 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
@@ -50,6 +50,10 @@ fun MutableMap<String, *>.asJsonNode(): JsonNode {
return JacksonUtils.jsonNodeFromObject(this)
}
+fun MutableMap<String, *>.asObjectNode(): ObjectNode {
+ return JacksonUtils.objectNodeFromObject(this)
+}
+
fun format(message: String, vararg args: Any?): String {
if (args != null && args.isNotEmpty()) {
return MessageFormatter.arrayFormat(message, args).message
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt
new file mode 100644
index 00000000..c536aef7
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
+
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+
+interface BluePrintWorkflowExecutionService<Input, Output> {
+
+ suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: Input,
+ properties: MutableMap<String, Any> = hashMapOf()): Output
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt
index d175fdde..4fa69cad 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt
@@ -34,34 +34,32 @@ open class BluePrintTemplateService {
companion object {
/**
- * Generate Content from Velocity Template and JSON Content.
+ * Generate Content from Velocity Template and JSON Content or property map.
*/
- fun generateContent(template: String, json: String,
+ fun generateContent(template: String, json: String = "",
ignoreJsonNull: Boolean = false,
- additionalContext: MutableMap<String, Any> = hashMapOf()): String {
+ additionalContext: Map<String, Any> = hashMapOf()): String {
Velocity.init()
val mapper = ObjectMapper()
val nodeFactory = BluePrintJsonNodeFactory()
- mapper.setNodeFactory(nodeFactory)
-
- val jsonNode = mapper.readValue<JsonNode>(json, JsonNode::class.java)
- ?: throw BluePrintProcessorException("couldn't get json node from json")
-
- if (ignoreJsonNull)
- JacksonUtils.removeJsonNullNode(jsonNode)
+ mapper.nodeFactory = nodeFactory
val velocityContext = VelocityContext()
velocityContext.put("StringUtils", StringUtils::class.java)
velocityContext.put("BooleanUtils", BooleanUtils::class.java)
- /**
- * Add the Custom Velocity Context API
- */
+
+ // 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)
+
+ // Add the JSON Data to the context
+ if (json.isNotEmpty()) {
+ val jsonNode = mapper.readValue<JsonNode>(json, JsonNode::class.java)
+ ?: throw BluePrintProcessorException("couldn't get json node from json")
+ if (ignoreJsonNull)
+ JacksonUtils.removeJsonNullNode(jsonNode)
+ jsonNode.fields().forEach { entry ->
+ velocityContext.put(entry.key, entry.value)
+ }
}
val stringWriter = StringWriter()
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 932f0edc..e0341b8a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -22,8 +22,13 @@ import com.fasterxml.jackson.annotation.JsonInclude
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.BooleanNode
+import com.fasterxml.jackson.databind.node.DoubleNode
+import com.fasterxml.jackson.databind.node.FloatNode
+import com.fasterxml.jackson.databind.node.IntNode
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.databind.node.TextNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
@@ -46,7 +51,7 @@ class JacksonUtils {
companion object {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
inline fun <reified T : Any> readValue(content: String): T =
- jacksonObjectMapper().readValue(content, T::class.java)
+ jacksonObjectMapper().readValue(content, T::class.java)
fun <T> readValue(content: String, valueType: Class<T>): T? {
return jacksonObjectMapper().readValue(content, valueType)
@@ -84,7 +89,7 @@ class JacksonUtils {
return runBlocking {
withContext(Dispatchers.Default) {
IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
+ .getResourceAsStream(fileName), Charset.defaultCharset())
}
}
}
@@ -184,7 +189,7 @@ class JacksonUtils {
fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
return readValue(getJson(properties), classType)
- ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")
+ ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")
}
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
@@ -228,14 +233,35 @@ class JacksonUtils {
}
}
+ fun getValue(value: JsonNode): Any {
+ return when (value) {
+ is BooleanNode -> value.booleanValue()
+ is IntNode -> value.intValue()
+ is FloatNode -> value.floatValue()
+ is DoubleNode -> value.doubleValue()
+ is TextNode -> value.textValue()
+ else -> value
+ }
+ }
+
+ fun getValue(value: Any, type: String): Any {
+ return when (type.toLowerCase()) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> (value as BooleanNode).booleanValue()
+ BluePrintConstants.DATA_TYPE_INTEGER -> (value as IntNode).intValue()
+ BluePrintConstants.DATA_TYPE_FLOAT -> (value as FloatNode).floatValue()
+ BluePrintConstants.DATA_TYPE_DOUBLE -> (value as DoubleNode).doubleValue()
+ BluePrintConstants.DATA_TYPE_STRING -> (value as TextNode).textValue()
+ else -> (value as JsonNode)
+ }
+ }
+
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)
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, (value as BooleanNode).booleanValue())
+ BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, (value as IntNode).intValue())
+ BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, (value as FloatNode).floatValue())
+ BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, (value as DoubleNode).doubleValue())
+ else -> objectNode.put(key, (value as TextNode).textValue())
}
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
index b35bca74..cd1dd431 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
@@ -76,14 +76,6 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio
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()
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
deleted file mode 100644
index 8b7a9577..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java
+++ /dev/null
@@ -1,85 +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.service.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Deprecated
-@RestController
-@RequestMapping(value = "/api/v1/dictionary")
-public class ResourceDictionaryRest {
-
-
- private ResourceDictionaryHandler resourceDictionaryHandler;
-
- /**
- * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
- *
- * @param resourceDictionaryHandler Data Dictionary Handler
- */
- public ResourceDictionaryRest(ResourceDictionaryHandler resourceDictionaryHandler) {
- this.resourceDictionaryHandler = resourceDictionaryHandler;
- }
-
- @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {
- return resourceDictionaryHandler.saveResourceDictionary(dataDictionary);
- }
-
- @DeleteMapping(path = "/{name}")
- public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {
- resourceDictionaryHandler.deleteResourceDictionary(name);
- }
-
- @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
- return resourceDictionaryHandler.getResourceDictionaryByName(name);
- }
-
- @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {
- return resourceDictionaryHandler.searchResourceDictionaryByNames(names);
- }
-
- @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {
- return resourceDictionaryHandler.searchResourceDictionaryByTags(tags);
-
- }
-
- @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)
- public @ResponseBody
- ResourceSourceMapping getResourceSourceMapping() {
- return resourceDictionaryHandler.getResourceSourceMapping();
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelRest.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelController.kt
index 0fca07b0..60c07ad2 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelRest.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelController.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2019 Bell Canada Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +28,14 @@ import org.springframework.web.bind.annotation.*
import reactor.core.publisher.Mono
/**
- * BlueprintModelRest Purpose: Handle controllerBlueprint API request
+ * BlueprintModelController Purpose: Handle controllerBlueprint API request
*
* @author Vinal Patel
* @version 1.0
*/
@RestController
@RequestMapping("/api/v1/blueprint-model")
-open class BlueprintModelRest(private val bluePrintModelHandler: BluePrintModelHandler) {
+open class BlueprintModelController(private val bluePrintModelHandler: BluePrintModelHandler) {
@PostMapping("", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@ResponseBody
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryController.kt
new file mode 100644
index 00000000..38397faa
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryController.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.controller
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
+import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+
+@RestController
+@RequestMapping(value = ["/api/v1/dictionary"])
+open class ResourceDictionaryController(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
+
+ @GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun getResourceDictionaryByName(@PathVariable(value = "name") name: String): ResourceDictionary {
+ return resourceDictionaryHandler.getResourceDictionaryByName(name)
+ }
+
+ @PostMapping(path = [""], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun saveResourceDictionary(@RequestBody dataDictionary: ResourceDictionary): ResourceDictionary {
+ return resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
+ }
+
+ @DeleteMapping(path = ["/{name}"])
+ fun deleteResourceDictionaryByName(@PathVariable(value = "name") name: String) {
+ resourceDictionaryHandler.deleteResourceDictionary(name)
+ }
+
+ @PostMapping(path = ["/by-names"], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchResourceDictionaryByNames(@RequestBody names: List<String>): List<ResourceDictionary> {
+ return resourceDictionaryHandler.searchResourceDictionaryByNames(names)
+ }
+
+ @GetMapping(path = ["/search/{tags}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List<ResourceDictionary> {
+ return resourceDictionaryHandler.searchResourceDictionaryByTags(tags)
+
+ }
+
+ @GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun getResourceSourceMapping(): ResourceSourceMapping {
+ return resourceDictionaryHandler.getResourceSourceMapping()
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
index 42c6365a..a94df6ae 100644
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java
@@ -28,7 +28,6 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
-import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.annotation.Commit;
@@ -45,7 +44,7 @@ import java.util.List;
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeServiceTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeServiceTest.class);
@Autowired
private ModelTypeHandler modelTypeHandler;
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
deleted file mode 100644
index 64c87e06..00000000
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java
+++ /dev/null
@@ -1,122 +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.service.rs;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.junit.Assert;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.test.annotation.Commit;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.util.List;
-
-@RunWith(SpringRunner.class)
-@DataJpaTest
-@ContextConfiguration(classes = {TestApplication.class})
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class ModelTypeRestTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
- @Autowired
- ModelTypeController modelTypeController;
-
- String modelName = "test-datatype";
-
- @Test
- @Commit
- public void test01SaveModelType() throws Exception {
- log.info("**************** test01SaveModelType ********************");
-
- String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
- modelType.setDescription("Definition for Sample Datatype ");
- modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
- modelType.setModelName(modelName);
- modelType.setVersion("1.0.0");
- modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
- + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelType.setUpdatedBy("xxxxxx@xxx.com");
- modelType = modelTypeController.saveModelType(modelType);
- log.info("Saved Mode {}", modelType.toString());
- Assert.assertNotNull("Failed to get Saved ModelType", modelType);
- Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());
-
- ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName());
- Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
- dbModelType);
-
- // Model Update
- modelType.setUpdatedBy("bs2796@xxx.com");
- modelType = modelTypeController.saveModelType(modelType);
- Assert.assertNotNull("Failed to get Saved ModelType", modelType);
- Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
-
- }
-
- @Test
- public void test02SearchModelTypes() throws Exception {
- log.info("*********************** test02SearchModelTypes ***************************");
-
- String tags = "test-datatype";
-
- List<ModelType> dbModelTypes = modelTypeController.searchModelTypes(tags);
- Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
- Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);
-
- }
-
- @Test
- public void test03GetModelType() throws Exception {
- log.info("************************* test03GetModelType *********************************");
- ModelType dbModelType = modelTypeController.getModelTypeByName(modelName);
- Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType);
- Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
-
- List<ModelType> dbDatatypeModelTypes =
- modelTypeController.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);
- Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);
- }
-
- @Test
- @Commit
- public void test04DeleteModelType() throws Exception {
- log.info(
- "************************ test03DeleteModelType ***********************");
- ModelType dbResourceMapping = modelTypeController.getModelTypeByName(modelName);
- Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);
- Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName());
-
- modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName());
- }
-
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelRestTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelControllerTest.kt
index f82aace4..d504c293 100644
--- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelRestTest.kt
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/BlueprintModelControllerTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2019 Bell Canada Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +49,7 @@ import java.nio.file.Files
import java.nio.file.Paths
/**
- * BlueprintModelRestTest Purpose: Integration test at API level
+ * BlueprintModelControllerTest Purpose: Integration test at API level
*
* @author Vinal Patel
* @version 1.0
@@ -60,7 +61,7 @@ import java.nio.file.Paths
@ComponentScan(basePackages = ["org.onap.ccsdk.apps.controllerblueprints"])
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@EnableAutoConfiguration
-class BlueprintModelRestTest {
+class BlueprintModelControllerTest {
companion object {
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeControllerTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeControllerTest.kt
new file mode 100644
index 00000000..6fd0d1f0
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeControllerTest.kt
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.controller
+
+import com.att.eelf.configuration.EELFManager
+import org.junit.Assert
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@DataJpaTest
+@ContextConfiguration(classes = [TestApplication::class])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ModelTypeControllerTest {
+
+ private val log = EELFManager.getInstance().getLogger(ModelTypeControllerTest::class.java)!!
+
+ @Autowired
+ internal var modelTypeController: ModelTypeController? = null
+
+ private var modelName = "test-datatype"
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test01SaveModelType() {
+ log.info("**************** test01SaveModelType ********************")
+
+ val content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json")
+ var modelType = ModelType()
+ modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT
+ modelType.description = "Definition for Sample Datatype "
+ modelType.definition = JacksonUtils.jsonNode(content)
+ modelType.modelName = modelName
+ modelType.version = "1.0.0"
+ modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ modelType.updatedBy = "xxxxxx@xxx.com"
+ modelType = modelTypeController!!.saveModelType(modelType)
+ log.info("Saved Mode {}", modelType.toString())
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName)
+
+ val dbModelType = modelTypeController!!.getModelTypeByName(modelType.modelName)
+ Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
+ dbModelType)
+
+ // Model Update
+ modelType.updatedBy = "bs2796@xxx.com"
+ modelType = modelTypeController!!.saveModelType(modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy)
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test02SearchModelTypes() {
+ log.info("*********************** test02SearchModelTypes ***************************")
+
+ val tags = "test-datatype"
+
+ val dbModelTypes = modelTypeController!!.searchModelTypes(tags)
+ Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes)
+ Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.isNotEmpty())
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test03GetModelType() {
+ log.info("************************* test03GetModelType *********************************")
+ val dbModelType = modelTypeController!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName $modelName", dbModelType)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType!!.modelName)
+
+ val dbDatatypeModelTypes = modelTypeController!!.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes)
+ Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.isNotEmpty())
+ }
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test04DeleteModelType() {
+ log.info(
+ "************************ test03DeleteModelType ***********************")
+ val dbResourceMapping = modelTypeController!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName)
+
+ modelTypeController!!.deleteModelTypeByName(dbResourceMapping.modelName)
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt
new file mode 100644
index 00000000..96c14261
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ResourceDictionaryControllerTest.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.controller
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [TestApplication::class])
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ComponentScan(basePackages = ["org.onap.ccsdk.apps.controllerblueprints"])
+class ResourceDictionaryControllerTest {
+
+ @Autowired
+ lateinit var resourceDictionaryController: ResourceDictionaryController
+
+ @Test
+ fun testResourceDictionaryControllerPresence() {
+ assertNotNull(resourceDictionaryController, "failed to initialise ResourceDictionaryController")
+ }
+
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
index 3bfb3d2b..919d202f 100644
--- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
@@ -55,6 +55,7 @@ class BluePrintEnhancerServiceImplTest {
runBlocking {
modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type")
resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary")
+ resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/test-dictionary")
}
}
@@ -73,4 +74,20 @@ class BluePrintEnhancerServiceImplTest {
val valid = bluePrintValidatorService.validateBluePrints(targetPath)
Assert.assertTrue("blueprint validation failed ", valid)
}
+
+ @Test
+ @Throws(Exception::class)
+ fun testEnhancementAndValidation2() {
+
+ val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/golden"
+
+ val targetPath = Paths.get("target", "bp-enhance").toUri().path
+
+ val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath)
+ Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext)
+
+ // Validate the Generated BluePrints
+ val valid = bluePrintValidatorService.validateBluePrints(targetPath)
+ Assert.assertTrue("blueprint validation failed ", valid)
+ }
} \ No newline at end of file