diff options
20 files changed, 1133 insertions, 59 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 054234015f..300d06b5d1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -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); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java index 31e913dc27..b522300b6a 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java @@ -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() diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java index a7744a2ea7..e728cfd0d4 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java @@ -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 index 0000000000..73769d745d --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/GetNestedResources.json @@ -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 diff --git a/adapters/mso-openstack-adapters/src/test/resources/GetResources.json b/adapters/mso-openstack-adapters/src/test/resources/GetResources.json index 3366ce4a05..0d403a62b5 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/GetResources.json +++ b/adapters/mso-openstack-adapters/src/test/resources/GetResources.json @@ -223,6 +223,374 @@ "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 index 0000000000..337f3ce853 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/NestedExpectedValue.json @@ -0,0 +1 @@ +[{"vserverId":"03a31a65-91ed-4563-9d5d-4f7223df9767","linterfaces":{"linterface":[]}}]
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn index 0be7c55596..7339b23802 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn @@ -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"> @@ -118,23 +118,23 @@ </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> @@ -146,23 +146,23 @@ </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> @@ -174,47 +174,47 @@ </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> 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 index 0000000000..e0f88a20a5 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java @@ -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); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java index a4ef28496e..24f642ae72 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java @@ -20,7 +20,15 @@ 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); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 867be2ec95..7562bd964e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -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; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java index f1779cf119..043aad43b1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java @@ -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"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 0bc20c16f7..87e6daa58a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -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 index 0000000000..c8420a5fab --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json @@ -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 index 0000000000..0b2d847e03 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json @@ -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 index 0000000000..aa69dba803 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml @@ -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> diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml index d35db00478..7adb7d1131 100644 --- a/mso-api-handlers/mso-api-handler-common/pom.xml +++ b/mso-api-handlers/mso-api-handler-common/pom.xml @@ -38,6 +38,12 @@ </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 index 0000000000..17dd9859b0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java @@ -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 index 0000000000..dae6542b8b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java @@ -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)); + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 434b9e9364..866a4e7ca1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -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); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index df1c947bde..d010288feb 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -787,7 +787,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, |