Merge "Workflow Recipe Lookup"
authorSteve Smokowski <ss835w@att.com>
Mon, 8 Apr 2019 16:45:20 +0000 (16:45 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 8 Apr 2019 16:45:20 +0000 (16:45 +0000)
28 files changed:
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryService.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java
adapters/mso-openstack-adapters/src/test/resources/GetNestedResources.json [new file with mode: 0644]
adapters/mso-openstack-adapters/src/test/resources/GetResources.json
adapters/mso-openstack-adapters/src/test/resources/NestedExpectedValue.json [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
bpmn/mso-infrastructure-bpmn/pom.xml
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml [new file with mode: 0644]
mso-api-handlers/mso-api-handler-common/pom.xml
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java [new file with mode: 0644]
mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java [new file with mode: 0644]
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java

index 0542340..300d06b 100644 (file)
@@ -1710,12 +1710,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
 
        return vduStatus;
     }
-
-       public Resources queryStackResources(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+    
+       public Resources queryStackResources(String cloudSiteId, String tenantId, String stackName, int nestedDepth) throws MsoException {
                CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId)
                                .orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
                Heat heatClient = getHeatClient(cloudSite, tenantId);
-               OpenStackRequest<Resources> request = heatClient.getResources().listResources(stackName);
+               OpenStackRequest<Resources> request = heatClient.getResources().listResources(stackName).queryParam("nested_depth", nestedDepth);
                return executeAndRecordOpenstackRequest(request);
        }
 
index 6d4deeb..eb003cd 100644 (file)
@@ -233,7 +233,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
             StackInfo stackStatus = getStackStatus(cloudSiteId, cloudOwner, tenantId, canonicalName, pollForCompletion, timeoutMinutes, backout);
 
             if (HeatStatus.CREATED.equals(stackStatus.getStatus())) {
-                multicloudAaiUpdate(cloudSiteId, cloudOwner, tenantId, genericVnfId, vfModuleId, multicloudResponseBody.getWorkloadId(), pollForCompletion, timeoutMinutes);
+                String workloadId = multicloudResponseBody == null ? null : multicloudResponseBody.getWorkloadId();
+                multicloudAaiUpdate(cloudSiteId, cloudOwner, tenantId, genericVnfId, vfModuleId, workloadId, pollForCompletion, timeoutMinutes);
             }
 
             return stackStatus;
@@ -398,6 +399,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
         if (multicloudClient == null) {
             if (logger.isDebugEnabled())
                 logger.debug("Multicloud client could not be initialized");
+            return;
         }
 
         Response response = multicloudClient.post(multicloudRequest);
index 1e16c2a..ed29a1c 100644 (file)
@@ -63,7 +63,7 @@ public class AuditStackService {
                                auth);
                ExternalTaskClient client = ExternalTaskClient.create()
                                .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
-                               .asyncResponseTimeout(120000).build();
+                               .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
                client.subscribe("InventoryAddAudit").lockDuration(60000)
                                .handler(auditCreateStack::executeExternalTask).open();
        }
@@ -80,7 +80,7 @@ public class AuditStackService {
                                auth);
                ExternalTaskClient client = ExternalTaskClient.create()
                                .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
-                               .asyncResponseTimeout(120000).build();
+                               .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0,0,0)).build();
                client.subscribe("InventoryDeleteAudit").lockDuration(60000)
                                .handler(auditDeleteStack::executeExternalTask).open();
        }
index 31e913d..b522300 100644 (file)
@@ -68,7 +68,7 @@ public class HeatStackAudit {
        public Optional<AAIObjectAuditList> auditHeatStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) {
                try {
                        logger.debug("Fetching Top Level Stack Information");
-                       Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName);
+                       Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName, 3);
                        List<Resource> novaResources = resources.getList().stream()
                                        .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
                        List<Resource> resourceGroups = resources.getList().stream()
index b2eadaf..58d8a4c 100644 (file)
@@ -60,7 +60,7 @@ public class CreateInventoryService {
                                auth);
                ExternalTaskClient client = ExternalTaskClient.create()
                                .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
-                               .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build();
+                               .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
                client.subscribe("InventoryCreate").lockDuration(60000)
                                .handler(createInventory::executeExternalTask).open();
        }
index a7744a2..e728cfd 100644 (file)
@@ -169,19 +169,34 @@ public class HeatStackAuditTest extends HeatStackAudit {
                
                String actualValue = objectMapper.writeValueAsString(vserversWithSubInterfaces);
                String expectedValue = getJson("ExpectedVserversToAudit.json");
-               System.out.println(actualValue);
                JSONAssert.assertEquals(expectedValue, actualValue, false);
        }
        
        @Test
        public void auditHeatStackNoServers_Test() throws Exception{
                Resources getResource = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class);
-               doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion,   tenantId, "heatStackName");
+               doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion,   tenantId, "heatStackName", 3);
                
                Optional<AAIObjectAuditList> actual = heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName");
                assertEquals(true, actual.get().getAuditList().isEmpty());
        }
        
+       @Test
+       public void auditHeatStackNestedServers_Test() throws Exception{
+               Resources getResource = objectMapper.readValue(new File("src/test/resources/GetNestedResources.json"), Resources.class);                
+               List<Resource> novaResources = getResource.getList().stream()
+                               .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());              
+               List<Resource> resourceGroups = getResource.getList().stream()
+                               .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType())).collect(Collectors.toList());
+               
+               doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion,   tenantId, "heatStackName", 3);          
+               Set<Vserver> vServersToAudit = heatStackAudit.createVserverSet(resources, novaResources,portList);              
+               Set<Vserver> vserversWithSubInterfaces = heatStackAudit.processSubInterfaces(cloudRegion,tenantId,resourceGroups, vServersToAudit);
+               String actualValue = objectMapper.writeValueAsString(vserversWithSubInterfaces);
+               String expectedValue = getJson("NestedExpectedValue.json");
+               JSONAssert.assertEquals(expectedValue, actualValue, false);
+       }
+       
 
        @Test
        public void findInterfaceInformation_Test(){
diff --git a/adapters/mso-openstack-adapters/src/test/resources/GetNestedResources.json b/adapters/mso-openstack-adapters/src/test/resources/GetNestedResources.json
new file mode 100644 (file)
index 0000000..73769d7
--- /dev/null
@@ -0,0 +1,277 @@
+{
+    "resources": [
+        {
+            "resource_name": "rar_keypair",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module/9b93aecf-fe05-4047-ba36-d5eb7bc7354e/resources/rar_keypair",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module/9b93aecf-fe05-4047-ba36-d5eb7bc7354e",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_keypair",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:49Z",
+            "required_by": [
+                "rar_node_0"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "rdm6ararf8001v-key_pair",
+            "resource_type": "OS::Nova::KeyPair"
+        },
+        {
+            "resource_name": "rar_node_0",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module/9b93aecf-fe05-4047-ba36-d5eb7bc7354e/resources/rar_node_0",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module/9b93aecf-fe05-4047-ba36-d5eb7bc7354e",
+                    "rel": "stack"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "nested"
+                }
+            ],
+            "logical_resource_id": "rar_node_0",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:49Z",
+            "required_by": [],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "c4876377-22bb-45d2-9fc3-f36a32207fa5",
+            "resource_type": "nest_rareport_server.yaml"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_volumeattachment_0",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_volumeattachment_0",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_volumeattachment_0",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "a27b9151-f439-437e-b7b0-94068cc856fa",
+            "resource_type": "OS::Cinder::VolumeAttachment"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_volume_0",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_volume_0",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_volume_0",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_volumeattachment_0"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "a27b9151-f439-437e-b7b0-94068cc856fa",
+            "resource_type": "OS::Cinder::Volume"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_RMM",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_RMM",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_RMM",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_server_0"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "dd23e047-d169-4cc3-a90a-6bc81b1ea17a",
+            "resource_type": "OS::Heat::MultipartMime"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_server_0",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_server_0",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_server_0",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_volumeattachment_0"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "03a31a65-91ed-4563-9d5d-4f7223df9767",
+            "resource_type": "OS::Nova::Server"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_RSC",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_RSC",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_RSC",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_RMM"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "7cea5faf-f5a8-4182-a686-05964f51ad95",
+            "resource_type": "OS::Heat::SoftwareConfig"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_0_oam_port_0",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_0_oam_port_0",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_0_oam_port_0",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_server_0"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "d2bc253c-96a5-47df-a00f-5b9f3eebe684",
+            "resource_type": "OS::Neutron::Port"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_RCC_2",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_RCC_2",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_RCC_2",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_RMM"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "15d092ab-4702-4635-8da9-24fff85c175b",
+            "resource_type": "OS::Heat::CloudConfig"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_RCC_0",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_RCC_0",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_RCC_0",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_RMM"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "9420ad4c-49da-4f23-89fc-109f9d5a4505",
+            "resource_type": "OS::Heat::CloudConfig"
+        },
+        {
+            "parent_resource": "rar_node_0",
+            "resource_name": "rar_RCC_1",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5/resources/rar_RCC_1",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module-rar_node_0-4pkqvamx52u6/c4876377-22bb-45d2-9fc3-f36a32207fa5",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_RCC_1",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:56Z",
+            "required_by": [
+                "rar_RMM"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "321b91fb-f265-4e56-8025-3c3e88da320a",
+            "resource_type": "OS::Heat::CloudConfig"
+        },
+        {
+            "resource_name": "rar_Sec_Grp",
+            "links": [
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module/9b93aecf-fe05-4047-ba36-d5eb7bc7354e/resources/rar_Sec_Grp",
+                    "rel": "self"
+                },
+                {
+                    "href": "https://test.com:8004/v1/326799122bd4451c801153f5db7f8509/stacks/rdm6ararf8001v_base_module/9b93aecf-fe05-4047-ba36-d5eb7bc7354e",
+                    "rel": "stack"
+                }
+            ],
+            "logical_resource_id": "rar_Sec_Grp",
+            "resource_status": "CREATE_COMPLETE",
+            "updated_time": "2019-04-02T20:13:49Z",
+            "required_by": [
+                "rar_node_0"
+            ],
+            "resource_status_reason": "state changed",
+            "physical_resource_id": "99fc77c6-019b-441c-ad99-b48dd1059f71",
+            "resource_type": "OS::Neutron::SecurityGroup"
+        }
+    ]
+}
\ No newline at end of file
index 3366ce4..0d403a6 100644 (file)
       "resource_status_reason": "state changed", 
       "resource_type": "OS::Heat::ResourceGroup", 
       "updated_time": "2019-01-23T19:34:15Z"
+    }, 
+    {
+      "resources": [
+        {
+          "links": [
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources/1", 
+              "rel": "self"
+            }, 
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672", 
+              "rel": "stack"
+            }, 
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-1-fmn5laetg5cs/0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", 
+              "rel": "nested"
+            }
+          ], 
+          "logical_resource_id": "1", 
+          "parent_resource": "ssc_1_subint_service1_port_0_subinterfaces", 
+          "physical_resource_id": "0d9cd813-2ae1-46c0-9ebb-48081f6cffbb", 
+          "required_by": [], 
+          "resource_name": "1", 
+          "resource_status": "CREATE_COMPLETE", 
+          "resource_status_reason": "state changed", 
+          "resource_type": "vlan_subinterface_ssc_service1.yaml", 
+          "updated_time": "2019-01-23T19:34:56Z"
+        }, 
+        {
+          "links": [
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources/0", 
+              "rel": "self"
+            }, 
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672", 
+              "rel": "stack"
+            }, 
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-0-yghihziaf36m/b7019dd0-2ee9-4447-bdef-ac25676b205a", 
+              "rel": "nested"
+            }
+          ], 
+          "logical_resource_id": "0", 
+          "parent_resource": "ssc_1_subint_service1_port_0_subinterfaces", 
+          "physical_resource_id": "b7019dd0-2ee9-4447-bdef-ac25676b205a", 
+          "required_by": [], 
+          "resource_name": "0", 
+          "resource_status": "CREATE_COMPLETE", 
+          "resource_status_reason": "state changed", 
+          "resource_type": "vlan_subinterface_ssc_service1.yaml", 
+          "updated_time": "2019-01-23T19:34:56Z"
+        }, 
+        {
+          "links": [
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672/resources/2", 
+              "rel": "self"
+            }, 
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz/31d0647a-6043-49a4-81b6-ccab29380672", 
+              "rel": "stack"
+            }, 
+            {
+              "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service1_port_0_subinterfaces-dtmxjmny7yjz-2-y3ndsavmsymv/bd0fc728-cbde-4301-a581-db56f494675c", 
+              "rel": "nested"
+            }
+          ], 
+          "logical_resource_id": "2", 
+          "parent_resource": "ssc_1_subint_service1_port_0_subinterfaces", 
+          "physical_resource_id": "bd0fc728-cbde-4301-a581-db56f494675c", 
+          "required_by": [], 
+          "resource_name": "2", 
+          "resource_status": "CREATE_COMPLETE", 
+          "resource_status_reason": "state changed", 
+          "resource_type": "vlan_subinterface_ssc_service1.yaml", 
+          "updated_time": "2019-01-23T19:34:56Z"
+        }
+      ]
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "d54dfd09-75c6-4e04-b204-909455b8f933", 
+      "required_by": [
+        "ssc_subint_service_1_vmi_0_v6_ip_0", 
+        "ssc_subint_service_1_vmi_0_ip_0"
+      ], 
+      "resource_name": "ssc_subint_service_1_vmi_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::VirtualMachineInterface", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0_v6_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0_v6_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "e7f25707-12fd-454f-95ac-6a05cd70806f", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service_1_vmi_0_v6_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "6d23f4d3-8f7b-42c5-bb9e-4aee5797d506", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service_1_vmi_0_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "f7a998c0-8939-4b07-bf4a-0862e9c325e1", 
+      "required_by": [
+        "ssc_subint_service_1_vmi_0_v6_ip_0", 
+        "ssc_subint_service_1_vmi_0_ip_0"
+      ], 
+      "resource_name": "ssc_subint_service_1_vmi_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::VirtualMachineInterface", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0_v6_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0_v6_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "e7f25707-12fd-454f-95ac-6a05cd70806f", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service_1_vmi_0_v6_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "6d23f4d3-8f7b-42c5-bb9e-4aee5797d506", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service_1_vmi_0_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "621c1fea-60b8-44ee-aede-c01b8b1aaa70", 
+      "required_by": [
+        "ssc_subint_service_1_vmi_0_v6_ip_0", 
+        "ssc_subint_service_1_vmi_0_ip_0"
+      ], 
+      "resource_name": "ssc_subint_service_1_vmi_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::VirtualMachineInterface", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0_v6_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0_v6_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "e7f25707-12fd-454f-95ac-6a05cd70806f", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service_1_vmi_0_v6_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service_1_vmi_0_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service_1_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service_1_vmi_0_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "6d23f4d3-8f7b-42c5-bb9e-4aee5797d506", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service_1_vmi_0_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c/resources/0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst/447a9b41-714e-434b-b1d0-6cce8d9f0f0c", 
+          "rel": "stack"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "nested"
+        }
+      ], 
+      "logical_resource_id": "0", 
+      "parent_resource": "ssc_1_subint_service2_port_0_subinterfaces", 
+      "physical_resource_id": "f711be16-2654-4a09-b89d-0511fda20e81", 
+      "required_by": [], 
+      "resource_name": "0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "vlan_subinterface_ssc_service2.yaml", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service2_vmi_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service2_vmi_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "2bbfa345-33bb-495a-94b2-fb514ee1cffc", 
+      "required_by": [
+        "ssc_subint_service2_vmi_0_v6_ip_0", 
+        "ssc_subint_service2_vmi_0_ip_0"
+      ], 
+      "resource_name": "ssc_subint_service2_vmi_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::VirtualMachineInterface", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service2_vmi_0_v6_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service2_vmi_0_v6_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "e7f25707-12fd-454f-95ac-6a05cd70806f", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service2_vmi_0_v6_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
+    }, 
+    {
+      "links": [
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81/resources/ssc_subint_service2_vmi_0_ip_0", 
+          "rel": "self"
+        }, 
+        {
+          "href": "https://orchestration.com:8004/v1/ea2d13cc98b44d60a6f94bdcb2738f9e/stacks/tsbc0005vm002ssc001-ssc_1_subint_service2_port_0_subinterfaces-hlzdigtimzst-0-upfi5nhurk7y/f711be16-2654-4a09-b89d-0511fda20e81", 
+          "rel": "stack"
+        }
+      ], 
+      "logical_resource_id": "ssc_subint_service2_vmi_0_ip_0", 
+      "parent_resource": "0", 
+      "physical_resource_id": "6d23f4d3-8f7b-42c5-bb9e-4aee5797d506", 
+      "required_by": [], 
+      "resource_name": "ssc_subint_service2_vmi_0_ip_0", 
+      "resource_status": "CREATE_COMPLETE", 
+      "resource_status_reason": "state changed", 
+      "resource_type": "OS::ContrailV2::InstanceIp", 
+      "updated_time": "2019-01-23T19:34:56Z"
     }
   ]
 }
diff --git a/adapters/mso-openstack-adapters/src/test/resources/NestedExpectedValue.json b/adapters/mso-openstack-adapters/src/test/resources/NestedExpectedValue.json
new file mode 100644 (file)
index 0000000..337f3ce
--- /dev/null
@@ -0,0 +1 @@
+[{"vserverId":"03a31a65-91ed-4563-9d5d-4f7223df9767","linterfaces":{"linterface":[]}}]
\ No newline at end of file
index 750b7ac..083a6b6 100644 (file)
@@ -130,19 +130,12 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
             ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution
                     .getVariable("executionServiceInput");
 
-            //CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils();
-
-            CDSProcessingClient cdsClient = null;
-            CountDownLatch countDownLatch;
-            try {
-                cdsClient = new CDSProcessingClient(this);
-                countDownLatch = cdsClient.sendRequest(executionServiceInput);
+            try(CDSProcessingClient cdsClient = new CDSProcessingClient(this)) {
+                CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
                 countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
-            } catch (InterruptedException ex) {
+            } catch (InterruptedException ex){
                 logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
                 Thread.currentThread().interrupt();
-            } finally {
-                cdsClient.close();
             }
 
             if (cdsResponse != null) {
index 6f0b1f6..2abea6e 100644 (file)
                        <artifactId>camunda-bpm-spring-boot-starter</artifactId>
                        <version>${camunda.springboot.version}</version>
                </dependency>
-               <dependency>
-                       <groupId>org.camunda.bpm.springboot</groupId>
-                       <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
-                       <version>${camunda.springboot.version}</version>
-               </dependency>
                <dependency>
                        <groupId>org.camunda.bpm.springboot</groupId>
                        <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
                <dependency>
                        <groupId>org.camunda.bpm.springboot</groupId>
                        <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
-                       <version>2.3.0</version>
+                       <version>${camunda.springboot.version}</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.camunda.bpmn</groupId>
+                                       <artifactId>camunda-engine-rest-core</artifactId>
+                               </exclusion>
+                       </exclusions>
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
index 0be7c55..7339b23 100644 (file)
@@ -1,5 +1,5 @@
 <?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.8.2">
+<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="2.0.3">
   <bpmn:process id="SDNCHandler" name="SDNC" isExecutable="true">
     <bpmn:startEvent id="SDNC_Start">
       <bpmn:outgoing>SequenceFlow_1n0j3hz</bpmn:outgoing>
@@ -38,7 +38,7 @@
     <bpmn:boundaryEvent id="BoundaryEvent_1quvxva" name="Timeout" attachedToRef="SubProcess_0y8yozw">
       <bpmn:outgoing>SequenceFlow_1yifu46</bpmn:outgoing>
       <bpmn:timerEventDefinition>
-        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("sdncTimeout")}]]></bpmn:timeDuration>
+        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">${execution.getVariable("sdncTimeout")}</bpmn:timeDuration>
       </bpmn:timerEventDefinition>
     </bpmn:boundaryEvent>
     <bpmn:sequenceFlow id="SequenceFlow_1ecej8g" sourceRef="SubProcess_0y8yozw" targetRef="ExclusiveGateway_09ehhaf" />
@@ -48,7 +48,7 @@
       <bpmn:outgoing>SequenceFlow_0i4u8g4</bpmn:outgoing>
     </bpmn:exclusiveGateway>
     <bpmn:sequenceFlow id="SequenceFlow_0rh24pq" name="Final Ack = N" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SubProcess_0y8yozw">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isCallbackCompleted")}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isCallbackCompleted") == false}</bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_1yifu46" sourceRef="BoundaryEvent_1quvxva" targetRef="Task_1un0flc" />
     <bpmn:sequenceFlow id="SequenceFlow_1n0j3hz" sourceRef="SDNC_Start" targetRef="SNDC_SetupCallback" />
@@ -62,7 +62,7 @@
     <bpmn:sequenceFlow id="SequenceFlow_0flbj8a" sourceRef="SNDC_SetupCallback" targetRef="Call_SDNC" />
     <bpmn:sequenceFlow id="SequenceFlow_0i4u8g4" name="Final Ack = Y" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SDNC_End" />
     <bpmn:sequenceFlow id="SequenceFlow_0puiqga" name="Final Ack = Y" sourceRef="isAsync_Gateway" targetRef="SDNC_End">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isSDNCCompleted")}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isSDNCCompleted")}</bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:serviceTask id="SNDC_SetupCallback" name="Setup Callback Variables" camunda:expression="${SDNCRequestTasks.createCorrelationVariables(execution)}">
       <bpmn:incoming>SequenceFlow_1n0j3hz</bpmn:incoming>
@@ -72,7 +72,7 @@
       <bpmn:incoming>SequenceFlow_1yifu46</bpmn:incoming>
     </bpmn:serviceTask>
   </bpmn:process>
-  <bpmn:message id="Message_06oc4iz" name="SDNCCallbackMessage" />
+  <bpmn:message id="Message_06oc4iz" name="WorkflowMessage" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="SDNCHandler">
       <bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="SDNC_Start">
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1qxm8ot_di" bpmnElement="SequenceFlow_1qxm8ot">
-        <di:waypoint xsi:type="dc:Point" x="347" y="-72" />
-        <di:waypoint xsi:type="dc:Point" x="376" y="-72" />
+        <di:waypoint x="347" y="-72" />
+        <di:waypoint x="376" y="-72" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="316.5" y="-93.5" width="90" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_05eggbt_di" bpmnElement="SequenceFlow_05eggbt">
-        <di:waypoint xsi:type="dc:Point" x="412" y="-72" />
-        <di:waypoint xsi:type="dc:Point" x="438" y="-72" />
+        <di:waypoint x="412" y="-72" />
+        <di:waypoint x="438" y="-72" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="380" y="-93.5" width="90" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1ecej8g_di" bpmnElement="SequenceFlow_1ecej8g">
-        <di:waypoint xsi:type="dc:Point" x="618" y="-67" />
-        <di:waypoint xsi:type="dc:Point" x="798" y="-67" />
-        <di:waypoint xsi:type="dc:Point" x="798" y="28" />
+        <di:waypoint x="618" y="-67" />
+        <di:waypoint x="798" y="-67" />
+        <di:waypoint x="798" y="28" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="663" y="-88.5" width="90" height="13" />
         </bpmndi:BPMNLabel>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0rh24pq_di" bpmnElement="SequenceFlow_0rh24pq">
-        <di:waypoint xsi:type="dc:Point" x="773" y="53" />
-        <di:waypoint xsi:type="dc:Point" x="449" y="53" />
-        <di:waypoint xsi:type="dc:Point" x="449" y="9" />
+        <di:waypoint x="773" y="53" />
+        <di:waypoint x="449" y="53" />
+        <di:waypoint x="449" y="9" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="579.9877300613497" y="32" width="66" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1yifu46_di" bpmnElement="SequenceFlow_1yifu46">
-        <di:waypoint xsi:type="dc:Point" x="636" y="-144" />
-        <di:waypoint xsi:type="dc:Point" x="748" y="-145" />
+        <di:waypoint x="636" y="-144" />
+        <di:waypoint x="748" y="-145" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="647" y="-166" width="90" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1n0j3hz_di" bpmnElement="SequenceFlow_1n0j3hz">
-        <di:waypoint xsi:type="dc:Point" x="-231" y="152" />
-        <di:waypoint xsi:type="dc:Point" x="-171" y="152" />
+        <di:waypoint x="-231" y="152" />
+        <di:waypoint x="-171" y="152" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="-201" y="130.5" width="0" height="13" />
         </bpmndi:BPMNLabel>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0yve6l6_di" bpmnElement="SequenceFlow_0yve6l6">
-        <di:waypoint xsi:type="dc:Point" x="253" y="127" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="92" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="92" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="-67" />
-        <di:waypoint xsi:type="dc:Point" x="278" y="-67" />
+        <di:waypoint x="253" y="127" />
+        <di:waypoint x="253" y="92" />
+        <di:waypoint x="253" y="92" />
+        <di:waypoint x="253" y="-67" />
+        <di:waypoint x="278" y="-67" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="263" y="57" width="65" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_07vnhri_di" bpmnElement="SequenceFlow_07vnhri">
-        <di:waypoint xsi:type="dc:Point" x="115" y="152" />
-        <di:waypoint xsi:type="dc:Point" x="228" y="152" />
+        <di:waypoint x="115" y="152" />
+        <di:waypoint x="228" y="152" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="171.5" y="130" width="0" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0flbj8a_di" bpmnElement="SequenceFlow_0flbj8a">
-        <di:waypoint xsi:type="dc:Point" x="-71" y="152" />
-        <di:waypoint xsi:type="dc:Point" x="15" y="152" />
+        <di:waypoint x="-71" y="152" />
+        <di:waypoint x="15" y="152" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="-28" y="130.5" width="0" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0i4u8g4_di" bpmnElement="SequenceFlow_0i4u8g4">
-        <di:waypoint xsi:type="dc:Point" x="798" y="78" />
-        <di:waypoint xsi:type="dc:Point" x="798" y="174" />
+        <di:waypoint x="798" y="78" />
+        <di:waypoint x="798" y="174" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="809" y="119" width="66" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0puiqga_di" bpmnElement="SequenceFlow_0puiqga">
-        <di:waypoint xsi:type="dc:Point" x="253" y="177" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="192" />
-        <di:waypoint xsi:type="dc:Point" x="780" y="192" />
+        <di:waypoint x="253" y="177" />
+        <di:waypoint x="253" y="192" />
+        <di:waypoint x="780" y="192" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="310" y="161" width="66" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0oh3ye4_di" bpmnElement="SequenceFlow_0oh3ye4">
-        <di:waypoint xsi:type="dc:Point" x="538" y="-72" />
-        <di:waypoint xsi:type="dc:Point" x="562" y="-72" />
+        <di:waypoint x="538" y="-72" />
+        <di:waypoint x="562" y="-72" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="550" y="-93.5" width="0" height="13" />
         </bpmndi:BPMNLabel>
index 113f05d..9b878af 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.workflow.service;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
 import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Optional;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.ParseException;
@@ -68,17 +71,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.web.util.UriUtils;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
 public class ServicePluginFactory {
 
        // SOTN calculate route
        public static final String OOF_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/oof/sotncalc";
 
        public static final String THIRD_SP_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/sp/resourcemgr/querytps";
-       
+
        public static final String INVENTORY_OSS_DEFAULT_ENDPOINT = "http://192.168.1.199:8443/oss/inventory";
 
        private static final int DEFAULT_TIME_OUT = 60000;
@@ -88,7 +87,7 @@ public class ServicePluginFactory {
        private static Logger logger = LoggerFactory.getLogger(ServicePluginFactory.class);
 
        private static ServicePluginFactory instance;
-       
+
 
        public static synchronized ServicePluginFactory getInstance() {
                if (null == instance) {
@@ -100,11 +99,11 @@ public class ServicePluginFactory {
        private ServicePluginFactory() {
 
        }
-       
+
        private String getInventoryOSSEndPoint(){
                return UrnPropertiesReader.getVariable("mso.service-plugin.inventory-oss-endpoint", INVENTORY_OSS_DEFAULT_ENDPOINT);
        }
-       
+
        private String getThirdSPEndPoint(){
                return UrnPropertiesReader.getVariable("mso.service-plugin.third-sp-endpoint", THIRD_SP_DEFAULT_ENDPOINT);
        }
@@ -118,18 +117,23 @@ public class ServicePluginFactory {
                if(!isNeedProcessSite(uuiRequest)) {
                        return uuiRequest;
                }
-       
-               Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
-               Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
-               Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
-               Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
-               List<Object> resources = (List<Object>) serviceParametersObject.get("resources");       
-
-               if (isSiteLocationLocal(serviceRequestInputs, resources)) {
-                       // resources changed : added TP info 
-                       String newRequest = getJsonString(uuiObject);
-                       return newRequest;
-               }
+
+      Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
+      if (uuiObject == null) {
+          return uuiRequest;
+      }
+      Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+          .getOrDefault("service", Collections.emptyMap());
+      Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+          .getOrDefault("parameters", Collections.emptyMap());
+      Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+          .getOrDefault("requestInputs", Collections.emptyMap());
+      List<Object> resources = (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList());
+
+      if (isSiteLocationLocal(serviceRequestInputs, resources)) {
+          // resources changed : added TP info
+          return getJsonString(uuiObject);
+      }
 
                List<Resource> addResourceList = new ArrayList<>();
                addResourceList.addAll(serviceDecomposition.getServiceResources());
@@ -155,9 +159,9 @@ public class ServicePluginFactory {
        }
 
        @SuppressWarnings("unchecked")
-       private boolean isSiteLocationLocal(Map<String, Object> serviceRequestInputs, List<Object> resources) {         
-       Map<String, Object> tpInfoMap = getTPforVPNAttachment(serviceRequestInputs);    
-                       
+       private boolean isSiteLocationLocal(Map<String, Object> serviceRequestInputs, List<Object> resources) {
+      Map<String, Object> tpInfoMap = getTPforVPNAttachment(serviceRequestInputs);
+
                if(tpInfoMap.isEmpty()) {
                        return true;
                }
@@ -166,7 +170,7 @@ public class ServicePluginFactory {
                if (!host.isEmpty()) {
                        return false;
                }
-               
+
                Map<String, Object> accessTPInfo = new HashMap<String, Object>();
                accessTPInfo.put("access-provider-id", tpInfoMap.get("access-provider-id"));
                accessTPInfo.put("access-client-id", tpInfoMap.get("access-client-id"));
@@ -180,7 +184,7 @@ public class ServicePluginFactory {
                        Map<String, Object> resource = (Map<String, Object>)curResource;
                        String curResourceName = (String) resource.get("resourceName");
                        curResourceName = curResourceName.replaceAll(" ", "");
-                       if(resourceName.equalsIgnoreCase(curResourceName)) { 
+                       if(resourceName.equalsIgnoreCase(curResourceName)) {
                                putResourceRequestInputs(resource, accessTPInfo);
                                break;
                        }
@@ -188,7 +192,7 @@ public class ServicePluginFactory {
 
                return true;
        }
-       
+
        @SuppressWarnings("unchecked")
        private Map<String, Object> getTPforVPNAttachment(Map<String, Object> serviceRequestInputs) {
                Object location = null;
@@ -199,24 +203,24 @@ public class ServicePluginFactory {
                // logic for R2 uuiRequest params in service level
                for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) {
                        String key = entry.getKey();
-                       if (key.toLowerCase().contains("site_address")) {                               
+                       if (key.toLowerCase().contains("site_address")) {
                                location = entry.getValue();
-                       } 
-                       if (key.toLowerCase().contains("sotncondition_clientsignal")) {                         
+                       }
+                       if (key.toLowerCase().contains("sotncondition_clientsignal")) {
                                clientSignal = entry.getValue();
                                vpnAttachmentResourceName = key.substring(0, key.indexOf("_"));
                        }
                }
 
                Map<String, Object> tpInfoMap =  new HashMap<String, Object>();
-               
+
                // Site resource has location param and SOTNAttachment resource has clientSignal param
                if(location == null || clientSignal == null ) {
                        return tpInfoMap;
                }
-               
-               // Query terminal points from InventoryOSS system by location.          
-               String locationAddress = (String) location;             
+
+               // Query terminal points from InventoryOSS system by location.
+               String locationAddress = (String) location;
                List<Object> locationTPList = queryAccessTPbyLocationFromInventoryOSS(locationAddress);
                if(locationTPList != null && !locationTPList.isEmpty()) {
                    for(Object tp: locationTPList) {
@@ -232,10 +236,10 @@ public class ServicePluginFactory {
                        logger.debug("Get Terminal TP from InventoryOSS");
                        return tpInfoMap;
                }
-               
+
                return tpInfoMap;
        }
-       
+
        @SuppressWarnings("unchecked")
        private List<Object> queryAccessTPbyLocationFromInventoryOSS(String locationAddress) {
                String url = getInventoryOSSEndPoint();
@@ -247,7 +251,7 @@ public class ServicePluginFactory {
                }
                return accessTPs;
        }
-       
+
        @SuppressWarnings("unchecked")
        private void putResourceRequestInputs(Map<String, Object> resource, Map<String, Object> resourceInputs) {
                Map<String, Object> resourceParametersObject = new HashMap<>();
@@ -260,7 +264,7 @@ public class ServicePluginFactory {
                        if(resParametersObject.containsKey("requestInputs")) {
                                Map<String, Object> resRequestInputs = (Map<String, Object>) resourceRequestInputs.get("requestInputs");
                                Map<String, Object> oldRequestInputs = (Map<String, Object>) resParametersObject.get("requestInputs");
-                               if(oldRequestInputs != null) {                                  
+                               if(oldRequestInputs != null) {
                                        oldRequestInputs.putAll(resRequestInputs);
                                }
                                else {
@@ -268,7 +272,7 @@ public class ServicePluginFactory {
                                }
                        }
                        else {
-                               resParametersObject.putAll(resourceRequestInputs);                              
+                               resParametersObject.putAll(resourceRequestInputs);
                        }
                }
                else {
@@ -277,24 +281,29 @@ public class ServicePluginFactory {
 
                return;
        }
-       
 
-       
+
+
        @SuppressWarnings("unchecked")
-       public String doTPResourcesAllocation(DelegateExecution execution, String uuiRequest) {         
-               Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
-               Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
-               Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
-               Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
-               
-               if(!isNeedAllocateCrossTPResources(serviceRequestInputs)) {
-                       return uuiRequest;
-               }
-               
-               allocateCrossTPResources(execution, serviceRequestInputs);
-               String newRequest = getJsonString(uuiObject);
-               return newRequest;
-       }
+       public String doTPResourcesAllocation(DelegateExecution execution, String uuiRequest) {
+      Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
+      if (uuiObject == null) {
+          return uuiRequest;
+      }
+      Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+          .getOrDefault("service", Collections.emptyMap());
+      Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+          .getOrDefault("parameters", Collections.emptyMap());
+      Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+          .getOrDefault("requestInputs", Collections.emptyMap());
+
+      if (!isNeedAllocateCrossTPResources(serviceRequestInputs)) {
+          return uuiRequest;
+      }
+
+      allocateCrossTPResources(execution, serviceRequestInputs);
+      return getJsonString(uuiObject);
+  }
 
        @SuppressWarnings("unchecked")
        private boolean isNeedAllocateCrossTPResources(Map<String, Object> serviceRequestInputs) {
@@ -303,7 +312,7 @@ public class ServicePluginFactory {
                        String callSource = (String) serviceRequestInputs.get("CallSource");
                        if("ExternalAPI".equalsIgnoreCase(callSource)) {
                                return false;
-                       }                                                       
+                       }
                }
                for (String input : serviceRequestInputs.keySet())
                {
@@ -313,12 +322,12 @@ public class ServicePluginFactory {
                }
                return false;
        }
-       
+
        @SuppressWarnings("unchecked")
        private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) {
 
                Map<String, Object> crossTPs = this.getTPsfromAAI();
-               
+
                if(crossTPs == null || crossTPs.isEmpty()) {
                        serviceRequestInputs.put("local-access-provider-id", "");
                        serviceRequestInputs.put("local-access-client-id", "");
@@ -329,7 +338,7 @@ public class ServicePluginFactory {
                        serviceRequestInputs.put("remote-access-client-id", "");
                        serviceRequestInputs.put("remote-access-topology-id", "");
                        serviceRequestInputs.put("remote-access-node-id", "");
-                       serviceRequestInputs.put("remote-access-ltp-id", "");                   
+                       serviceRequestInputs.put("remote-access-ltp-id", "");
                }
                else {
                        serviceRequestInputs.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
@@ -343,24 +352,24 @@ public class ServicePluginFactory {
                        serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-node-id"));
                        serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id"));
                }
-               
+
                return;
        }
 
-       // This method returns Local and remote TPs information from AAI        
+       // This method returns Local and remote TPs information from AAI
        public Map getTPsfromAAI() {
                Map<String, Object> tpInfo = new HashMap<>();
-               
+
                AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK);
                AAIResourcesClient client = new AAIResourcesClient();
                Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri);
-               
+
                if (result.isPresent()) {
                        LogicalLinks links = result.get();
                        boolean isRemoteLink = false;
-                       
+
                        links.getLogicalLink();
-                       
+
                        for (LogicalLink link : links.getLogicalLink()) {
                                AAIResultWrapper wrapper = new AAIResultWrapper(link);
                                Optional<Relationships> optRelationships = wrapper.getRelationships();
@@ -372,7 +381,7 @@ public class ServicePluginFactory {
                                        }
                                        pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE));
                                }
-                               
+
                                if (isRemoteLink) {
                                        // find remote p interface
                                        AAIResourceUri localTP = null;
@@ -393,7 +402,7 @@ public class ServicePluginFactory {
                                                String tpUrl = localTP.build().toString();
                                                PInterface intfLocal = client.get(PInterface.class, localTP).get();
                                                tpInfo.put("local-access-node-id", tpUrl.split("/")[6]);
-                                       
+
                                                String[] networkRef = intfLocal.getNetworkRef().split("/");
                                                if (networkRef.length == 6) {
                                                        tpInfo.put("local-access-provider-id", networkRef[1]);
@@ -404,7 +413,7 @@ public class ServicePluginFactory {
                                                if (ltpIdStr.contains("-")) {
                                                        tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1));
                                                }
-                                               
+
                                                // give remote tp
                                                tpUrl = remoteTP.build().toString();
                                                PInterface intfRemote = client.get(PInterface.class, remoteTP).get();
@@ -431,7 +440,7 @@ public class ServicePluginFactory {
 
        // this method check if pInterface is remote
        private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) {
-               
+
                String uriString = uri.build().toString();
 
                if (uriString != null) {
@@ -447,7 +456,7 @@ public class ServicePluginFactory {
                                return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty();
                        }
                }
-               
+
                return false;
        }
 
@@ -475,12 +484,19 @@ public class ServicePluginFactory {
                return uuiRequest.contains("clientSignal") && uuiRequest.contains("vpnType");
        }
 
+       @SuppressWarnings("unchecked")
        private String preProcessSOTNService(ServiceDecomposition serviceDecomposition, String uuiRequest) {
                Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
-               Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
-               Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
-               Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
-               List<Object> resources = (List<Object>) serviceParametersObject.get("resources");
+      if (uuiObject == null) {
+          return uuiRequest;
+      }
+      Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+          .getOrDefault("service", Collections.emptyMap());
+      Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+          .getOrDefault("parameters", Collections.emptyMap());
+      Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+          .getOrDefault("requestInputs", Collections.emptyMap());
+      List<Object> resources = (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList());
                // This is a logic for demo , it could not be finalized to community.
                String srcLocation = "";
                String dstLocation = "";
@@ -534,7 +550,7 @@ public class ServicePluginFactory {
                        vpnRequestInputs.put("src-client-signal", srcClientSignal);
                        vpnRequestInputs.put("dst-client-signal", dstClientSignal);
                }
-               
+
 
                // Now we need to query terminal points from SP resourcemgr system.
                List<Object> locationTerminalPointList = queryTerminalPointsFromServiceProviderSystem(srcLocation, dstLocation);
@@ -589,54 +605,61 @@ public class ServicePluginFactory {
                }
                return null;
        }
-       
+
        public static void main(String args[]){
                String str = "restconf/config/GENERIC-RESOURCE-API:services/service/eca7e542-12ba-48de-8544-fac59303b14e/service-data/networks/network/aec07806-1671-4af2-b722-53c8e320a633/network-data/";
-               
+
                int index1 = str.indexOf("/network/");
                int index2 = str.indexOf("/network-data");
-               
+
                String str1 = str.substring(index1 + "/network/".length(), index2);
                System.out.println(str1);
-               
+
        }
 
-       private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) {
-               // query the route for the service.
-               Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
-               Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
-               Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
-               Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
-               Map<String, Object> oofQueryObject = new HashMap<>();
-               List<Object> resources = (List<Object>) serviceParametersObject.get("resources");
-               oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id"));
-               oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id"));
-               oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id"));
-               oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id"));
-               oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id"));
-               oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id"));
-               oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id"));
-               oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id"));
-               oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id"));
-               oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id"));
-               String oofRequestReq = getJsonString(oofQueryObject);
-               String url = getOOFCalcEndPoint();
-               String responseContent = sendRequest(url, "POST", oofRequestReq);
+    @SuppressWarnings("unchecked")
+    private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) {
+        // query the route for the service.
+        Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
+        if (uuiObject == null) {
+            return uuiRequest;
+        }
+        Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+            .getOrDefault("service", Collections.emptyMap());
+        Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+            .getOrDefault("parameters", Collections.emptyMap());
+        Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+            .getOrDefault("requestInputs", Collections.emptyMap());
+        Map<String, Object> oofQueryObject = new HashMap<>();
+        List<Object> resources = (List<Object>) serviceParametersObject
+            .getOrDefault("resources", Collections.emptyList());
+        oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id"));
+        oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id"));
+        oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id"));
+        oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id"));
+        oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id"));
+        oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id"));
+        oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id"));
+        oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id"));
+        oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id"));
+        oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id"));
+        String oofRequestReq = getJsonString(oofQueryObject);
+        String url = getOOFCalcEndPoint();
+        String responseContent = sendRequest(url, "POST", oofRequestReq);
+
+        List<Object> returnList = new ArrayList<>();
+        if (null != responseContent) {
+            returnList = getJsonObject(responseContent, List.class);
+        }
+        // in demo we have only one VPN. no cross VPNs, so get first item.
+        Map<String, Object> returnRoute = getReturnRoute(returnList);
+        Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources);
+        if (null != vpnRequestInputs) {
+            vpnRequestInputs.putAll(returnRoute);
+        }
+        return getJsonString(uuiObject);
+    }
 
-               List<Object> returnList = new ArrayList<>();
-               if (null != responseContent) {
-                       returnList = getJsonObject(responseContent, List.class);
-               }
-               // in demo we have only one VPN. no cross VPNs, so get first item.
-               Map<String, Object> returnRoute = getReturnRoute(returnList);
-               Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources);
-               if(null!=vpnRequestInputs) {
-                       vpnRequestInputs.putAll(returnRoute);
-               }
-               String newRequest = getJsonString(uuiObject);
-               return newRequest;
-       }
-       
        private Map<String, Object> getReturnRoute(List<Object> returnList){
                Map<String, Object> returnRoute = new HashMap<>();
                for(Object returnVpn :returnList){
@@ -681,7 +704,7 @@ public class ServicePluginFactory {
                return resourceInputsFromUuiMap;
        }
 
-       public static <T> T getJsonObject(String jsonstr, Class<T> type) {
+       private static <T> T getJsonObject(String jsonstr, Class<T> type) {
                ObjectMapper mapper = new ObjectMapper();
                mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
                try {
@@ -706,7 +729,7 @@ public class ServicePluginFactory {
        }
 
        private static String sendRequest(String url, String methodType, String content) {
-               
+
                String msbUrl = url;
                HttpRequestBase method = null;
                HttpResponse httpResponse = null;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java
new file mode 100644 (file)
index 0000000..6e22123
--- /dev/null
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Samsung Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.workflow.service;
+
+import static org.mockito.Mockito.doReturn;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.core.domain.ServiceDecomposition;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ServicePluginFactoryTest {
+
+    @Mock
+    ServiceDecomposition serviceDecomposition;
+
+    @Spy
+    ServicePluginFactory servicePluginFactory;
+
+    String uuiRequest = "{"
+        + "    \"service\":{"
+        + "        \"name\":\"ONAP_223531\","
+        + "        \"description\":\"ONAP_1546\","
+        + "        \"serviceInvariantUuid\":\"4a09419a-c9fd-4a53-b1bd-b49603169ca1\","
+        + "        \"serviceUuid\":\"1bd0eae6-2dcc-4461-9ae6-56d641f369d6\","
+        + "        \"globalSubscriberId\":\"test_custormer\","
+        + "        \"serviceType\":\"example-service-type\","
+        + "        \"parameters\":{"
+        + "            \"locationConstraints\":["
+        + "            ],"
+        + "            \"resources\":["
+        + "                {"
+        + "                    \"resourceName\":\"vEPC_ONAP01\","
+        + "                    \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\","
+        + "                    \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\","
+        + "                    \"resourceCustomizationUuid\":\"47a0e235-b67a-4ea4-a0cf-25761afed231\","
+        + "                    \"parameters\":{"
+        + "                        \"locationConstraints\":["
+        + "                            {"
+        + "                                \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\","
+        + "                                \"locationConstraints\":{"
+        + "                                    \"vimId\":\"vmware_vio\""
+        + "                                }"
+        + "                            },"
+        + "                            {"
+        + "                                \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\","
+        + "                                \"locationConstraints\":{"
+        + "                                    \"vimId\":\"core-dc_RegionOne\""
+        + "                                }"
+        + "                            }"
+        + "                        ],"
+        + "                        \"resources\":["
+        + "                        ],"
+        + "                        \"requestInputs\":{"
+        + "                            \"sdncontroller\":\"\""
+        + "                        }"
+        + "                    }"
+        + "                },"
+        + "                {"
+        + "                    \"resourceName\":\"VL OVERLAYTUNNEL\","
+        + "                    \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\","
+        + "                    \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\","
+        + "                    \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\","
+        + "                    \"parameters\":{"
+        + "                        \"locationConstraints\":["
+        + "                        ],"
+        + "                        \"resources\":["
+        + "                        ],"
+        + "                        \"requestInputs\":{"
+        + "                        }"
+        + "                    }"
+        + "                }"
+        + "            ],"
+        + "            \"requestInputs\":{"
+        + "                \"vlunderlayvpn0_name\":\"l3connect\","
+        + "                \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\","
+        + "                \"vlunderlayvpn0_site2_id\":\"SPTNController\","
+        + "                \"vlunderlayvpn0_site1_networkName\":\"network1,network2\","
+        + "                \"vlunderlayvpn0_site2_networkName\":\"network3,network4\","
+        + "                \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\","
+        + "                \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\","
+        + "                \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\","
+        + "                \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\","
+        + "                \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\","
+        + "                \"vlunderlayvpn0_site1_vni\":\"2000\","
+        + "                \"vlunderlayvpn0_site2_vni\":\"3000\","
+        + "                \"vlunderlayvpn0_tunnelType\":\"L3-DCI\","
+        + "                \"CallSource\":\"NOT-ExternalAPI\","
+        + "                \"sotnconnectivity\":\"\""
+        + "            }"
+        + "        }"
+        + "    }"
+        + "}";
+
+
+    @Test
+    public void doProcessSiteLocation_isNeedProcessSite() {
+        String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, uuiRequest);
+        Assert.assertEquals(result, uuiRequest);
+    }
+
+    @Test
+    public void doProcessSiteLocation_uuiObjectNull() {
+        String faultyJsonInput = "site_address,sotncondition_clientsignal";
+        String result = servicePluginFactory.doProcessSiteLocation(
+            serviceDecomposition, faultyJsonInput);
+        Assert.assertEquals(result, faultyJsonInput);
+    }
+
+    @Test
+    public void doProcessSiteLocation_isSiteLocationLocal() {
+        String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
+        String result = servicePluginFactory.doProcessSiteLocation(
+            serviceDecomposition, jsonWithOnlyNeededValues);
+        Assert.assertEquals(result, jsonWithOnlyNeededValues);
+    }
+
+
+    @Test
+    public void doTPResourcesAllocation_Success() {
+        doReturn(null).when(servicePluginFactory).getTPsfromAAI();
+        String result = servicePluginFactory.doTPResourcesAllocation(null, uuiRequest);
+        Assert.assertNotEquals(result, uuiRequest);
+    }
+
+    @Test
+    public void doTPResourcesAllocation_uuiObjectNull() {
+        String faultyJsonInput = "site_address,sotncondition_clientsignal";
+        String result = servicePluginFactory.doTPResourcesAllocation(null, faultyJsonInput);
+        Assert.assertEquals(result, faultyJsonInput);
+    }
+
+    @Test
+    public void doTPResourcesAllocation_isNeedAllocateCrossTPResources() {
+        //doReturn(null).when(servicePluginFactory).getTPsfromAAI();
+        String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
+        String result = servicePluginFactory.doTPResourcesAllocation(null, jsonWithOnlyNeededValues);
+        Assert.assertEquals(result, jsonWithOnlyNeededValues);
+    }
+
+    @Test
+    public void preProcessService_isSOTN() {
+        String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
+        String result = servicePluginFactory.preProcessService(null, invalidJsonWithOnlyNeededValues);
+        Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);
+    }
+
+    @Test
+    public void preProcessService() {
+        String result = servicePluginFactory.preProcessService(null, uuiRequest);
+        Assert.assertEquals(result, uuiRequest);
+    }
+
+    @Test
+    public void doServiceHoming() {
+        String result = servicePluginFactory.doServiceHoming(null, uuiRequest);
+        Assert.assertEquals(result, uuiRequest);
+    }
+
+    @Test
+    public void doServiceHoming_isSOTN() {
+        String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
+        String result = servicePluginFactory.doServiceHoming(null, invalidJsonWithOnlyNeededValues);
+        Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);
+    }
+}
index c4804c0..e13d1e4 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Ericsson. All rights reserved.
  * ================================================================================
+ *  Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -85,8 +87,7 @@ public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask {
           + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
       LOGGER.error(message);
       exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
-    }
-    if (operationStatusOption.isPresent()) {
+    } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
       final OperationStateEnum operationStatus = operationStatusOption.get();
       if (operationStatus != OperationStateEnum.COMPLETED) {
         final String message =
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
new file mode 100644 (file)
index 0000000..e0f88a2
--- /dev/null
@@ -0,0 +1,13 @@
+package org.onap.so.bpmn.infrastructure.sdnc.exceptions;
+
+public class SDNCErrorResponseException extends Exception {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 7807799223298140702L;
+       
+       public SDNCErrorResponseException(String message) {
+               super(message);
+       }
+}
index a4ef284..24f642a 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.sdnc.tasks;
 
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
 import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException;
 import org.onap.so.client.exception.BadResponseException;
 import org.onap.so.client.exception.ExceptionBuilder;
 import org.onap.so.client.exception.MapperException;
@@ -31,6 +39,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.HttpClientErrorException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
 
 import com.jayway.jsonpath.JsonPath;
 import com.jayway.jsonpath.PathNotFoundException;
@@ -44,6 +54,7 @@ public class SDNCRequestTasks {
        private static final String MESSAGE = "_MESSAGE";
        private static final String CORRELATOR = "_CORRELATOR";
        protected static final String IS_CALLBACK_COMPLETED = "isCallbackCompleted";
+       protected static final String SDNC_SUCCESS = "200";
        
        @Autowired
        private ExceptionBuilder exceptionBuilder;
@@ -82,9 +93,24 @@ public class SDNCRequestTasks {
                try {
                        SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
                        String asyncRequest = (String) execution.getVariable(request.getCorrelationName()+MESSAGE);
-                       String finalMessageIndicator = JsonPath.read(asyncRequest, "$.input.ack-final-indicator");              
+                       
+               DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+               DocumentBuilder db = dbf.newDocumentBuilder();
+               Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
+
+               String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
                        boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
                        execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
+                       if(isCallbackCompleted) {
+                               String responseCode = getXmlElement(doc, "/input/response-code");
+                               String responseMessage = getXmlElement(doc, "/input/response-message"); 
+                               if(!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
+                                       throw new SDNCErrorResponseException(responseMessage);
+                               }
+                       }
+               } catch (SDNCErrorResponseException e) {
+                       logger.error("SDNC error response - " + e.getMessage());
+                       exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
                } catch (Exception e) {
                        logger.error("Error procesing SDNC callback", e);
                        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback");
@@ -99,4 +125,9 @@ public class SDNCRequestTasks {
                return "Y".equals(finalMessageIndicator);
        }
        
+       protected String getXmlElement(Document doc, String exp) throws Exception {
+               XPath xPath = XPathFactory.newInstance().newXPath();
+               return xPath.evaluate(exp, doc);
+       }
+       
 }
index 867be2e..7562bd9 100644 (file)
@@ -372,6 +372,31 @@ public class WorkflowAction {
                return vnfcs;
        }
        
+       protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) {
+               
+               List<T> configurations = new ArrayList<>();
+               AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+               AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
+               Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
+               if (!relationshipsOp.isPresent()) {
+                       logger.debug("No relationships were found for VNFC in AAI");
+               } else {
+                       Relationships relationships = relationshipsOp.get();
+                       List<AAIResultWrapper> configurationResultWrappers = this.getResultWrappersFromRelationships(relationships, type);
+                       for(AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
+                               Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
+                               if(configurationOp.isPresent()) {
+                                       configurations.add(configurationOp.get());
+                               }
+                       }
+               }
+               return configurations;
+       }
+       
+       protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships, AAIObjectType type){
+               return relationships.getByType(type);
+       }
+       
        protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) {
                for(OrchestrationFlow flow : orchFlows) {
                        if(flow.getFlowName().contains("Configuration")) {
@@ -384,6 +409,7 @@ public class WorkflowAction {
        protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey,
                        String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType,
                        WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) {
+               
                List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
                List<OrchestrationFlow> result = new ArrayList<>(orchFlows);
                result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
@@ -392,22 +418,29 @@ public class WorkflowAction {
                
                String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
                String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
-               List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
-               
-               for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
-                       workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
-                       for(OrchestrationFlow orchFlow : result) {
-                               resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
-                               resourceKey.setCvnfModuleCustomizationId(configuration.getModelCustomizationId());
-                               resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
-                               ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
-                                               requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
-                               String vnfcName = getVnfcNameForConfiguration(configuration);
-                               if(vnfcName == null || vnfcName.isEmpty()) {
-                                       buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
+
+               List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC);
+               for(org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
+                       List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+                       if (configurations.size() > 1){
+                               String multipleRelationshipsError = "Multiple relationships exist from VNFC "+vnfc.getVnfcName()+" to Configurations";
+                               buildAndThrowException(execution, multipleRelationshipsError, new Exception(multipleRelationshipsError));
+                       }
+                       for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
+                               workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
+                               for(OrchestrationFlow orchFlow : result) {
+                                       resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
+                                       resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+                                       resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
+                                       ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
+                                                       requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
+                                       String vnfcName = getVnfcNameForConfiguration(configuration);
+                                       if(vnfcName == null || vnfcName.isEmpty()) {
+                                               buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
+                                       }
+                                       ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
+                                       flowsToExecuteConfigs.add(ebb);
                                }
-                               ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
-                               flowsToExecuteConfigs.add(ebb);
                        }
                }
                return flowsToExecuteConfigs;
index f1779cf..043aad4 100644 (file)
@@ -27,9 +27,13 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import java.io.IOException;
+import java.io.StringReader;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.camunda.bpm.engine.delegate.BpmnError;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 
@@ -51,6 +55,8 @@ import org.onap.so.client.exception.MapperException;
 import org.onap.so.client.sdnc.SDNCClient;
 import org.onap.so.client.sdnc.beans.SDNCRequest;
 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
 
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
@@ -131,12 +137,29 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks{
        
        @Test
        public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
-               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_ASYNC_Request.json")));    
+               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));    
                delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);                 
                sndcRequestTasks.processCallback(delegateExecution);            
                assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
        }
        
+       @Test
+       public void getXmlElementTest() throws Exception {
+               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));    
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+        DocumentBuilder db;
+        db = dbf.newDocumentBuilder ();
+        Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
+        
+        String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
+        String responseCode = getXmlElement(doc, "/input/response-code");
+               String responseMessage = getXmlElement(doc, "/input/response-message"); 
+               
+               assertEquals("Y", finalMessageIndicator);
+               assertEquals("200", responseCode);
+               assertEquals("Success", responseMessage);
+       }
+       
        public SDNCRequest createSDNCRequest(){
                SDNCRequest request = new SDNCRequest();
                request.setCorrelationName("correlationName");
index 0bc20c1..87e6daa 100644 (file)
@@ -53,6 +53,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
+import org.mockito.Spy;
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.L3Network;
 import org.onap.aai.domain.yang.Relationship;
@@ -60,6 +61,7 @@ import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.aai.domain.yang.ServiceInstance;
 import org.onap.aai.domain.yang.VfModule;
 import org.onap.aai.domain.yang.VfModules;
+import org.onap.aai.domain.yang.Vnfc;
 import org.onap.aai.domain.yang.VolumeGroup;
 import org.onap.so.bpmn.BaseTaskTest;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -67,7 +69,11 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
 import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResource;
 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
@@ -100,9 +106,15 @@ public class WorkflowActionTest extends BaseTaskTest {
        private DelegateExecution execution;
 
        
+       @InjectMocks
+       @Spy
+       protected WorkflowAction SPY_workflowAction;
+       
        @Rule
        public ExpectedException thrown = ExpectedException.none();
        
+       private String RESOURCE_PATH = "src/test/resources/__files/";
+       
        @Before
        public void before() throws Exception {
                execution = new DelegateExecutionFake();
@@ -930,6 +942,123 @@ public class WorkflowActionTest extends BaseTaskTest {
                assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
        }
        
+       @Test
+       public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception{
+               String gAction = "deleteInstance";
+               String resource = "VfModule";
+               execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+               execution.setVariable("requestAction", gAction);
+               String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+               execution.setVariable("bpmnRequest", bpmnRequest);              
+               execution.setVariable("aLaCarte", true);
+               execution.setVariable("apiVersion", "7");
+               execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+               
+               NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+               List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+               northBoundRequest.setOrchestrationFlowList(orchFlows);
+               
+               when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+               
+               org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+               vnf.setVnfId("vnf0");
+               vnf.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+               
+               org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+               vfModule.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+               
+               List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+               org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+               vnfc.setModelInvariantId("modelInvariantId");
+               vnfc.setVnfcName("testVnfcName");
+               vnfcs.add(vnfc);
+               doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+               
+               List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+               org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+               configuration.setConfigurationId("configurationId");
+               configuration.setModelCustomizationId("modelCustimizationId");
+               configuration.setConfigurationName("testConfigurationName");
+               configurations.add(configuration);
+               doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+               
+               doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+               
+               SPY_workflowAction.selectExecutionList(execution);
+               List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+               assertEqualsBulkFlowName(ebbs,"DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+       }
+       
+       @Test
+       public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception{
+               String gAction = "deleteInstance";
+               String resource = "VfModule";
+               execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+               execution.setVariable("requestAction", gAction);
+               String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+               execution.setVariable("bpmnRequest", bpmnRequest);              
+               execution.setVariable("aLaCarte", true);
+               execution.setVariable("apiVersion", "7");
+               execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+               
+               NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+               List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+               northBoundRequest.setOrchestrationFlowList(orchFlows);
+               
+               when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+               
+               org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+               vnf.setVnfId("vnf0");
+               vnf.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+               
+               org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+               vfModule.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+               
+               List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+               org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+               vnfc.setModelInvariantId("modelInvariantId");
+               vnfc.setVnfcName("testVnfcName");
+               vnfcs.add(vnfc);
+               doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+               
+               List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+               org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+               doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+               
+               doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+               
+               SPY_workflowAction.selectExecutionList(execution);
+               List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+               assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+       }
+       
+       @Test
+       public void getRelatedResourcesInVfModuleTest() throws Exception{
+               org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+               vnfc.setModelInvariantId("modelInvariantId");
+               vnfc.setVnfcName("testVnfcName");
+               
+               String vfncPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
+               AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
+               
+               String configurationPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
+               AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
+               List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
+               configurationResultWrappers.add(configurationWrapper);
+               
+               AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+               when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
+               
+               doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),anyObject());
+               List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+               assertEquals(1,configurationsList.size());
+               assertEquals("testConfigurationId",configurationsList.get(0).getConfigurationId());
+       }
+       
        /**
         * WorkflowActionBB Tests
         */
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json
new file mode 100644 (file)
index 0000000..c8420a5
--- /dev/null
@@ -0,0 +1,8 @@
+{
+       "configuration-id": "testConfigurationId",
+       "configuration-type": "...",
+       "orchestration-status": "...",
+       "tunnel-bandwidth": "100",
+       "vendor-allowed-max-bandwidth": "90",
+       "resource-version": "1234"
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json
new file mode 100644 (file)
index 0000000..0b2d847
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "vnfc-name": "vnfcName",
+  "nfc-naming-code": "oamfw",
+  "nfc-function": "FIREWALL",
+  "prov-status": "PREPROV",
+  "orchestration-status": "Active",
+  "in-maint": false,
+  "is-closed-loop-disabled": false,
+  "model-invariant-id": "9dae8bb5-0709-4c0e-8f5b-6448232510ea",
+  "model-version-id": "b4e05ccb-01d0-4176-90ae-380308a35e5f",
+  "model-customization-id": "abf73d38-9da2-47af-bd53-26954318449f",
+  "resource-version": "1552319567126",
+   "relationship-list": {
+      "relationship": [
+        {
+          "related-to": "generic-vnf",
+          "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/testGenericVnfId",
+          "relationship-data": {
+            "relationship-key": "generic-vnf",
+            "relationship-value": "4a9184ac-5fad-44a1-b224-289bb490eaa9"
+          },
+          "related-to-property": {
+            "property-key": "generic-vnf.vnf-name",
+            "property-value": "USBBBBmtwnjVVHP047"
+          }
+        }
+      ]
+    }
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
new file mode 100644 (file)
index 0000000..aa69dba
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<input>
+   <service-information>
+      <service-type>MY-SERVICE-TYPE</service-type>
+      <service-instance-id>b8308928-de76-4ce6-9e58-ec6033ff43b3</service-instance-id>
+   </service-information>
+   <svc-request-id>aa243891-4575-4040-bceb-25d5b7bc8c61</svc-request-id>
+   <response-code>200</response-code>
+   <response-message>Success</response-message>
+   <ack-final-indicator>Y</ack-final-indicator>
+</input>
index d35db00..7adb7d1 100644 (file)
                </dependencies>
        </dependencyManagement>
        <dependencies>
+                       <!-- Dependencies on other MSO Projects -->
+               <dependency>
+                       <groupId>org.onap.so</groupId>
+                       <artifactId>mso-requests-db</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-jersey</artifactId>
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java
new file mode 100644 (file)
index 0000000..17dd985
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.apihandler.filters;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.slf4j.MDC;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Priority(2)
+@Provider
+@Component
+public class RequestIdFilter implements ContainerRequestFilter {
+
+       protected static Logger logger = LoggerFactory.getLogger(RequestIdFilter.class);
+       
+       @Autowired
+       private RequestsDbClient infraActiveRequestsClient;
+
+       @Override
+       public void filter(ContainerRequestContext context) throws IOException {
+               String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+       
+        InfraActiveRequests infraActiveRequests = infraActiveRequestsClient.getInfraActiveRequestbyRequestId(requestId);
+        
+        if (infraActiveRequests != null) {
+               MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(HttpStatus.SC_BAD_REQUEST));
+               logger.error("RequestID exists in RequestDB.InfraActiveRequests : " + requestId);
+        }
+       }
+}
diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java
new file mode 100644 (file)
index 0000000..dae6542
--- /dev/null
@@ -0,0 +1,68 @@
+package org.onap.so.apihandler.filters;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+
+import java.io.IOException;
+
+import javax.ws.rs.container.ContainerRequestContext;
+
+import org.apache.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.MockitoRule;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.slf4j.MDC;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RequestIdFilterTest {
+
+    @Mock
+    ContainerRequestContext mockContext;
+       
+       @Mock
+       protected RequestsDbClient requestsDbClient;
+       
+    @InjectMocks
+    @Spy
+    RequestIdFilter requestIdFilter;
+       
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+    
+    @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
+    
+       @Test
+       public void filterTest() throws IOException {
+               
+               String requestId = "32807a28-1a14-4b88-b7b3-2950918aa769";              
+               MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+               
+        //ExpectedRecord InfraActiveRequests
+        InfraActiveRequests infraActiveRequests = new InfraActiveRequests();
+        infraActiveRequests.setRequestStatus("FAILED");
+        infraActiveRequests.setProgress(100L);
+        infraActiveRequests.setLastModifiedBy("APIH");
+        infraActiveRequests.setRequestScope("network");
+        infraActiveRequests.setRequestAction("deleteInstance");
+        infraActiveRequests.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa769");  
+       
+               doReturn(infraActiveRequests).when(requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
+               
+               requestIdFilter.filter(mockContext);
+               
+               Mockito.verify( requestIdFilter, Mockito.times(1)).filter(mockContext);
+               assertEquals(MDC.get(ONAPLogConstants.MDCs.RESPONSE_CODE), String.valueOf(HttpStatus.SC_BAD_REQUEST));
+               
+       }
+}
index 434b9e9..866a4e7 100644 (file)
@@ -26,6 +26,7 @@ import javax.ws.rs.ApplicationPath;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.servlet.ServletProperties;
 import org.onap.so.apihandler.filters.RequestUriFilter;
+import org.onap.so.apihandler.filters.RequestIdFilter;
 import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
 import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration;
 import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration;
@@ -61,6 +62,7 @@ public class JerseyConfiguration extends ResourceConfig {
                register(ApiExceptionMapper.class);
                register(RuntimeExceptionMapper.class);
                register(RequestUriFilter.class);
+               register(RequestIdFilter.class);
                register(E2EServiceInstances.class);
                register(WorkflowSpecificationsHandler.class);
                register(InstanceManagement.class);
index f17c39c..2ce1263 100644 (file)
@@ -799,7 +799,7 @@ public class CatalogDbClient {
             logger.debug("Found CvnfcCustomization: {}", filtered.get(0));
             return filtered.get(0);
         }else
-            throw new EntityNotFoundException("Unable to find VfModuleCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid);
+            throw new EntityNotFoundException("Unable to find CvnfcCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid);
     }
     
     public CvnfcConfigurationCustomization getCvnfcCustomization(String serviceModelUUID, String vnfCustomizationUuid,