From 6ba0a22bc952232d14d2d24c5f73a42aae2791a9 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Thu, 11 Oct 2018 13:55:37 -0400 Subject: Dynamic Cloud Owner Support added in cloud configuration object to request params Fix Bean scanning so it picks up the resttemplate removed unnecessary RestTemplate Bean configurations corrected typo in CloudConfiguration class updated gr api test cases with dynamic cloud owner updated groovy files to allow for dynamic cloud owner values updated GR API layer to include cloud owner added enum for default cloud owner add cloud owner variable to camunda in mapping removed references to att-aic from BBInputSetup updated aai schema dependency to 1.3.1 from 1.3.0 Fixed incorrect type AAIUri and updated logging in the method. use existing service instance id instead of generating Pass cloudOwner to process to propagate to subprocesses. NOTE: our aai-schema dependency is 1.3.1-SNAPSHOT to be compatible with the cloud owner changes here. The releaesed 1.3.0 version is NOT compatible. Change-Id: I43b46774b77981d1c8bfe7c7a79b9434889e62ae Issue-ID: SO-1128 Signed-off-by: Benjamin, Max (mb388a) Signed-off-by: Rob Daugherty --- .../so/db/catalog/client/CatalogDbClientTest.java | 62 ++- .../test/resources/db/migration/afterMigrate.sql | 3 + .../onap/so/asdc/client/ASDCStatusCallBack.java | 1 + .../onap/so/asdc/util/ASDCNotificationLogging.java | 4 +- .../org/onap/so/bpmn/common/scripts/AaiUtil.groovy | 336 ++--------- .../scripts/AbstractServiceTaskProcessor.groovy | 4 + .../common/scripts/AllottedResourceUtils.groovy | 64 +-- .../common/scripts/ConfirmVolumeGroupName.groovy | 79 ++- .../common/scripts/ConfirmVolumeGroupTenant.groovy | 15 +- .../bpmn/common/scripts/CreateAAIVfModule.groovy | 82 ++- .../scripts/CreateAAIVfModuleVolumeGroup.groovy | 29 +- .../bpmn/common/scripts/CustomE2EPutService.groovy | 283 ---------- .../bpmn/common/scripts/DeleteAAIVfModule.groovy | 103 ++-- .../so/bpmn/common/scripts/ExternalAPIUtil.groovy | 24 +- .../common/scripts/GenerateVfModuleName.groovy | 12 +- .../so/bpmn/common/scripts/GenericGetVnf.groovy | 275 --------- .../bpmn/common/scripts/GenericPutService.groovy | 282 ---------- .../so/bpmn/common/scripts/NetworkUtils.groovy | 76 +-- .../common/scripts/PrepareUpdateAAIVfModule.groovy | 171 +++--- .../bpmn/common/scripts/UpdateAAIGenericVnf.groovy | 17 +- .../bpmn/common/scripts/UpdateAAIVfModule.groovy | 18 +- .../homingobjects/Candidate.java | 22 +- .../homingobjects/CandidateType.java | 5 +- .../servicedecomposition/tasks/BBInputSetup.java | 21 +- .../tasks/BBInputSetupMapperLayer.java | 4 +- .../tasks/BBInputSetupUtils.java | 7 +- .../client/appc/ApplicationControllerClient.java | 2 +- .../resources/subprocess/CustomE2EPutService.bpmn | 201 ------- .../main/resources/subprocess/GenericGetVnf.bpmn | 212 ------- .../resources/subprocess/GenericPutService.bpmn | 201 ------- .../onap/so/bpmn/common/scripts/AaiUtilTest.groovy | 311 +---------- .../scripts/ConfirmVolumeGroupNameTest.groovy | 159 ++---- .../common/scripts/CustomE2EPutServiceTest.groovy | 72 --- .../common/scripts/GenerateVfModuleNameTest.groovy | 8 +- .../so/bpmn/common/scripts/MsoGroovyTest.groovy | 85 +++ .../scripts/PrepareUpdateAAIVfModuleTest.groovy | 11 +- .../common/scripts/UpdateAAIGenericVnfTest.groovy | 12 +- .../common/scripts/UpdateAAIVfModuleTest.groovy | 12 +- .../org/onap/so/bpmn/mock/StubResponseAAI.java | 25 - .../tasks/BBInputSetupMapperLayerTest.java | 14 +- .../tasks/BBInputSetupTest.java | 34 +- .../tasks/BBInputSetupUtilsTest.java | 22 +- .../SniroHoming/SniroManagerRequest1Vpn.json | 6 + .../SniroHoming/SniroManagerRequest3AR.json | 4 +- .../SniroHoming/SniroManagerRequest3Vpn.json | 6 + .../GeneralBuildingBlockCMExpected.json | 1 + .../GeneralBuildingBlockExpected.json | 2 +- .../ServiceMacroVfModules.json | 1 + .../ExecuteBuildingBlock/ServiceMacroVnfs.json | 1 + .../AddNetworkPolicy_AAIResponse_Success.xml | 21 - .../CreateAAIVfModuleVolumeGroupRequest.xml | 6 - .../VfModularity/DoUpdateVfModuleRequest.xml | 29 - .../resources/__files/VfModularity/GenericVnf.xml | 38 -- .../PrepareUpdateAAIVfModuleRequest.xml | 5 - .../QueryNetworkPolicy_AAIResponse_Success.xml | 21 - .../VfModularity/SDNCTopologyActivateCallback.xml | 13 - .../VfModularity/SDNCTopologyAssignCallback.xml | 13 - .../SDNCTopologyChangeAssignCallback.xml | 13 - .../VfModularity/SDNCTopologyQueryCallback.xml | 315 ----------- .../SDNCTopologyQueryCallbackVfModule.xml | 141 ----- .../VfModularity/StandardSDNCSynchResponse.xml | 5 - .../VfModularity/UpdateAAIGenericVnfRequest.xml | 5 - .../VfModularity/UpdateAAIVfModuleRequest.xml | 10 - .../__files/VfModularity/UpdateVfModuleRequest.xml | 35 -- .../VfModularity/VNFAdapterRestCreateCallback.xml | 55 -- .../VfModularity/VNFAdapterRestUpdateCallback.xml | 16 - .../VNFAdapterRestVolumeGroupCallback.xml | 15 - .../__files/VfModularity/VfModule-lukewarm.xml | 10 - .../__files/VfModularity/VfModule-new.xml | 9 - .../__files/VfModularity/VfModule-supercool.xml | 27 - .../resources/__files/VfModularity/VolumeGroup.xml | 25 - .../src/test/resources/application-test.yaml | 24 - .../src/main/java/org/onap/so/rest/RESTClient.java | 9 - .../test/java/org/onap/so/rest/RESTClientTest.java | 94 ++-- .../org/onap/so/bpmn/common/GenericGetVnfIT.java | 190 ------- .../AddNetworkPolicy_AAIResponse_Success.xml | 21 + .../CreateAAIVfModuleVolumeGroupRequest.xml | 7 + .../VfModularity/DoUpdateVfModuleRequest.xml | 29 + .../resources/__files/VfModularity/GenericVnf.xml | 38 ++ .../PrepareUpdateAAIVfModuleRequest.xml | 5 + .../QueryNetworkPolicy_AAIResponse_Success.xml | 21 + .../VfModularity/SDNCTopologyActivateCallback.xml | 13 + .../VfModularity/SDNCTopologyAssignCallback.xml | 13 + .../SDNCTopologyChangeAssignCallback.xml | 13 + .../VfModularity/SDNCTopologyQueryCallback.xml | 315 +++++++++++ .../SDNCTopologyQueryCallbackVfModule.xml | 141 +++++ .../VfModularity/StandardSDNCSynchResponse.xml | 5 + .../VfModularity/UpdateAAIGenericVnfRequest.xml | 5 + .../VfModularity/UpdateAAIVfModuleRequest.xml | 10 + .../__files/VfModularity/UpdateVfModuleRequest.xml | 35 ++ .../VfModularity/VNFAdapterRestCreateCallback.xml | 55 ++ .../VfModularity/VNFAdapterRestUpdateCallback.xml | 16 + .../VNFAdapterRestVolumeGroupCallback.xml | 15 + .../__files/VfModularity/VfModule-lukewarm.xml | 10 + .../__files/VfModularity/VfModule-new.xml | 9 + .../__files/VfModularity/VfModule-supercool.xml | 27 + .../resources/__files/VfModularity/VolumeGroup.xml | 25 + .../src/test/java/org/onap/so/BaseTest.java | 53 +- .../org/onap/so/BuildingBlockTestDataSetup.java | 321 +++++------ .../so/bpmn/buildingblock/SniroHomingV2Test.java | 11 +- .../src/test/resources/application-test.yaml | 24 - .../scripts/CreateNetworkInstance.groovy | 2 + .../scripts/CreateVfModuleInfra.groovy | 4 + .../scripts/CreateVfModuleVolumeInfraV1.groovy | 4 + .../scripts/DeleteVfModuleVolumeInfraV1.groovy | 33 +- .../scripts/DoCreateE2EServiceInstance.groovy | 77 +-- .../scripts/DoCreateNetworkInstance.groovy | 228 +++----- .../scripts/DoCreateServiceInstance.groovy | 152 +++-- .../infrastructure/scripts/DoCreateVfModule.groovy | 428 +++++++------- .../scripts/DoCreateVfModuleRollback.groovy | 15 +- .../scripts/DoCreateVfModuleVolumeRollback.groovy | 67 ++- .../scripts/DoCreateVfModuleVolumeV2.groovy | 40 +- .../bpmn/infrastructure/scripts/DoCreateVnf.groovy | 9 +- .../scripts/DoDeleteNetworkInstance.groovy | 204 +++---- .../infrastructure/scripts/DoDeleteVfModule.groovy | 25 +- .../scripts/DoDeleteVfModuleFromVnf.groovy | 26 +- .../scripts/DoDeleteVfModuleVolumeV2.groovy | 94 ++-- .../bpmn/infrastructure/scripts/DoDeleteVnf.groovy | 62 +-- .../scripts/DoDeleteVnfAndModules.groovy | 11 +- .../scripts/DoUpdateE2EServiceInstance.groovy | 85 ++- .../DoUpdateE2EServiceInstanceRollback.groovy | 64 +-- .../scripts/DoUpdateNetworkInstance.groovy | 220 +++----- .../infrastructure/scripts/DoUpdateVfModule.groovy | 88 +-- .../scripts/DoUpdateVnfAndModules.groovy | 11 +- .../infrastructure/scripts/ReplaceVnfInfra.groovy | 2 + .../scripts/UpdateVfModuleInfra.groovy | 4 + .../scripts/UpdateVfModuleInfraV2.groovy | 4 + .../scripts/UpdateVfModuleVolumeInfraV1.groovy | 177 +++--- .../infrastructure/scripts/UpdateVnfInfra.groovy | 2 + .../infrastructure/scripts/VnfInPlaceUpdate.groovy | 2 + .../vcpe/scripts/DeleteVcpeResCustService.groovy | 3 + .../aai/groovyflows/AAICreateResources.java | 2 +- .../workflow/service/ServicePluginFactory.java | 121 +++- .../scripts/CreateNetworkInstanceTest.groovy | 2 + .../scripts/DoCreateE2EServiceInstanceTest.groovy | 5 +- .../scripts/DoCreateServiceInstanceTest.groovy | 8 +- .../scripts/DoDeleteVfModuleFromVnfTest.groovy | 11 +- .../scripts/DoUpdateVfModuleTest.groovy | 15 +- .../scripts/DoUpdateVnfAndModulesTest.groovy | 8 +- .../scripts/CreateVcpeResCustServiceTest.groovy | 3 + .../scripts/DeleteVcpeResCustServiceTest.groovy | 1 + .../src/test/resources/application-test.yml | 619 ++++++++++----------- .../resources/process/CreateNetworkInstance.bpmn | 1 + .../process/CreateVcpeResCustService.bpmn | 1 + .../process/CreateVcpeResCustServiceV2.bpmn | 1 + .../resources/process/CreateVfModuleInfra.bpmn | 1 + .../process/CreateVfModuleVolumeInfraV1.bpmn | 3 +- .../src/main/resources/process/CreateVnfInfra.bpmn | 1 + .../resources/process/DeleteNetworkInstance.bpmn | 1 + .../process/DeleteVcpeResCustService.bpmn | 1 + .../main/resources/process/ReplaceVnfInfra.bpmn | 1 + .../resources/process/UpdateNetworkInstance.bpmn | 1 + .../resources/process/UpdateVfModuleInfra.bpmn | 1 + .../resources/process/UpdateVfModuleInfraV2.bpmn | 1 + .../src/main/resources/process/UpdateVnfInfra.bpmn | 1 + .../subprocess/DoCreateE2EServiceInstance.bpmn | 369 ++++++------ .../subprocess/DoCreateE2EServiceInstanceV2.bpmn | 33 +- .../subprocess/DoCreateServiceInstance.bpmn | 118 ++-- .../resources/subprocess/DoCreateVfModule.bpmn | 32 +- .../src/main/resources/subprocess/DoCreateVnf.bpmn | 140 +---- .../subprocess/DoCreateVnfAndModules.bpmn | 3 + .../src/main/resources/subprocess/DoDeleteVnf.bpmn | 137 ++--- .../subprocess/DoDeleteVnfAndModules.bpmn | 1 + .../subprocess/DoUpdateE2EServiceInstance.bpmn | 140 ++--- .../DoUpdateE2EServiceInstanceRollback.bpmn | 44 +- .../subprocess/DoUpdateVnfAndModules.bpmn | 1 + .../VCPE/CreateVcpeResCustService/request.json | 1 + .../VCPE/DeleteVcpeResCustService/request.json | 1 + .../src/test/resources/application-test.yaml | 24 - .../src/test/resources/application-test.yml | 47 -- bpmn/so-bpmn-tasks/pom.xml | 2 +- .../onap/so/bpmn/buildingblock/SniroHomingV2.java | 5 +- .../flowspecific/tasks/AssignVnf.java | 5 +- .../workflow/tasks/WorkflowAction.java | 19 +- .../vnf/mapper/VnfAdapterVfModuleObjectMapper.java | 38 +- .../orchestration/AAIInstanceGroupResources.java | 7 + .../orchestration/AAIServiceInstanceResources.java | 2 +- .../orchestration/AAIVpnBindingResources.java | 15 +- .../sdnc/mapper/GeneralTopologyObjectMapper.java | 4 +- .../mapper/VnfTopologyOperationRequestMapper.java | 2 +- .../flowspecific/tasks/AssignVnfTest.java | 9 +- .../workflow/tasks/WorkflowActionUnitTest.java | 158 ++++++ .../VnfAdapterVfModuleObjectMapperPayloadTest.java | 19 +- .../AAIInstanceGroupResourcesTest.java | 7 + .../mapper/GeneralTopologyObjectMapperTest.java | 76 ++- .../grApiVmNetworkSubSectionWith5GParams.json | 73 +++ .../src/test/resources/application-test.yaml | 26 +- common/pom.xml | 2 +- .../org/onap/so/client/aai/AAIObjectPlurals.java | 17 +- .../java/org/onap/so/client/aai/AAIObjectType.java | 26 +- .../main/java/org/onap/so/constants/Defaults.java | 18 + .../serviceinstancebeans/CloudConfiguration.java | 23 +- .../ServiceInstanceBeansTest.java | 17 + logger/logback-spring.xml | 188 +++++++ .../exceptions/RequestDbFailureException.java | 43 ++ .../onap/so/apihandlerinfra/ServiceInstances.java | 49 +- .../so/apihandlerinfra/ServiceInstancesTest.java | 90 +++ .../so/db/request/client/RequestsDbClient.java | 1 + .../onap/so/db/catalog/client/CatalogDbClient.java | 56 +- 199 files changed, 4363 insertions(+), 6460 deletions(-) delete mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy delete mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy delete mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy delete mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn delete mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn delete mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn delete mode 100644 bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml delete mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml delete mode 100644 bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/GenericVnf.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-new.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-supercool.xml create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VolumeGroup.xml create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json create mode 100644 common/src/main/java/org/onap/so/constants/Defaults.java create mode 100644 logger/logback-spring.xml create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 5c7b64d054..5e2bd82776 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -20,9 +20,11 @@ package org.onap.so.db.catalog.client; +import java.util.List; +import java.util.UUID; + import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; @@ -30,6 +32,7 @@ import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; +import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.ServerType; @@ -49,10 +52,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import java.net.URI; -import java.util.List; -import java.util.UUID; - @RunWith(SpringRunner.class) @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -414,4 +413,57 @@ public class CatalogDbClientTest { Assert.assertEquals("regionId", getCloudSite.getRegionId()); Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); } + @Test + public void testGetServiceByModelName() { + Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service"); + Assert.assertNotNull(service); + Assert.assertNotNull(service.getModelVersion()); + Assert.assertNotNull(service.getModelInvariantUUID()); + Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName()); + Assert.assertEquals("NA", service.getServiceRole()); + } + + @Test + public void testGetServiceByModelNameNotFound() { + Service service = client.getServiceByModelName("Not_Found"); + Assert.assertNull(service); + } + + @Test + public void testGetServiceByModelUUID() { + Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679"); + Assert.assertNotNull(service); + Assert.assertNotNull(service.getModelVersion()); + Assert.assertNotNull(service.getModelInvariantUUID()); + Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID()); + Assert.assertEquals("NA", service.getServiceRole()); + } + + @Test + public void testGetServiceByModelUUIDNotFound() { + Service service = client.getServiceByModelUUID("Not_Found"); + Assert.assertNull(service); + } + + @Test + public void testFindServiceRecipeByActionAndServiceModelUUID() { + ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance","4694a55f-58b3-4f17-92a5-796d6f5ffd0d" ); + Assert.assertNotNull(serviceRecipe); + Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); + Assert.assertNotNull(serviceRecipe.getAction()); + Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri()); + Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); + } + + @Test + public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() { + ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("not_found","5df8b6de-2083-11e7-93ae-test" ); + Assert.assertNull(serviceRecipe); + } + + @Test + public void testFindExternalToInternalServiceByServiceNameNotFound() { + ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("Not_Found"); + Assert.assertNull(externalServiceToInternalService); + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index d5cdb18a0c..c8475564a4 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -60,6 +60,9 @@ insert into tosca_csar(artifact_uuid, name, version, description, artifact_check insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values ('5df8b6de-2083-11e7-93ae-92361f002671', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '1.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', '0513f839-459d-46b6-aa3d-2edfef89a079', 'NA', 'NA', 'Luna', 'Oxygen'); +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002679', 'MSOTADevInfra_Test_Service', '9647dfc4-2083-11e7-93ae-92361f002673', '3.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', '0513f839-459d-46b6-aa3d-2edfef89a079', 'NA', 'NA', 'Luna', 'Oxygen'); + insert into tosca_csar(ARTIFACT_UUID,NAME,VERSION,DESCRIPTION,ARTIFACT_CHECKSUM,URL,CREATION_TIMESTAMP) values ('266eaf78-af74-45cd-83ec-9c477f189dc1','service-NetworkCollectionSvc0106-csar.csar','1','TOSCA definition package of the asset','OGQ1M2QyYjU0OWMzZTY4MWVlYTNhOWIxNmQ2NjEyZDQ=','/sdc/v1/catalog/services/NetworkCollectionSvc0106/1.0/artifacts/service-NetworkCollectionSvc0106-csar.csar','2018-06-01 16:06:52'); insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java index cbacd88870..248d94d530 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java @@ -45,6 +45,7 @@ public final class ASDCStatusCallBack implements IStatusCallback { @Override public void activateCallback (IStatusData iStatus) { + long startTime = System.currentTimeMillis (); UUIDChecker.generateUUID (LOGGER); MsoLogger.setServiceName ("ASDCStatusCallBack"); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index 9df9ffc7af..ca4c5e83a9 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -368,7 +368,9 @@ public class ASDCNotificationLogging { } } - } + + } + List nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList(); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index 3e451a5a4a..2f4e70c893 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -19,15 +19,24 @@ */ package org.onap.so.bpmn.common.scripts +import java.util.regex.Matcher +import java.util.regex.Pattern + +import javax.ws.rs.core.UriBuilder + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.aai.AAIVersion +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.openpojo.rules.HasToStringRule import org.onap.so.rest.APIResponse; import org.onap.so.rest.RESTClient import org.onap.so.rest.RESTConfig -import org.springframework.web.util.UriUtils -import org.onap.so.logger.MsoLogger +@Deprecated class AaiUtil { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AaiUtil.class); @@ -43,124 +52,13 @@ class AaiUtil { public AaiUtil(AbstractServiceTaskProcessor taskProcessor) { this.taskProcessor = taskProcessor } - public AaiUtil() { - } - - public String getNetworkGenericVnfEndpoint(DelegateExecution execution) { - String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - def uri = getNetworkGenericVnfUri(execution) - msoLogger.debug('AaiUtil.getNetworkGenericVnfEndpoint() - AAI endpoint: ' + endpoint + uri) - return endpoint + uri - } - public String getNetworkGenericVnfUri(DelegateExecution execution) { - def uri = getUri(execution, 'generic-vnf') - msoLogger.debug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkVpnBindingUri(DelegateExecution execution) { - def uri = getUri(execution, 'vpn-binding') - msoLogger.debug('AaiUtil.getNetworkVpnBindingUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkPolicyUri(DelegateExecution execution) { - def uri = getUri(execution, 'network-policy') - msoLogger.debug('AaiUtil.getNetworkPolicyUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkTableReferencesUri(DelegateExecution execution) { - def uri = getUri(execution, 'route-table-reference') - msoLogger.debug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkVceUri(DelegateExecution execution) { - def uri = getUri(execution, 'vce') - msoLogger.debug('AaiUtil.getNetworkVceUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkL3NetworkUri(DelegateExecution execution) { - def uri = getUri(execution, 'l3-network') - msoLogger.debug('AaiUtil.getNetworkL3NetworkUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkDeviceUri(DelegateExecution execution) { - def uri = getUri(execution, 'device') - msoLogger.debug('AaiUtil.getNetworkDeviceUri() - AAI URI: ' + uri) - return uri - } - - public String getBusinessCustomerUri(DelegateExecution execution) { - def uri = getUri(execution, 'customer') - msoLogger.debug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri) - return uri - } - public String getBusinessSPPartnerUri(DelegateExecution execution) { def uri = getUri(execution, 'sp-partner') msoLogger.debug('AaiUtil.getBusinessSPPartnerUri() - AAI URI: ' + uri) return uri } - public String getAAIServiceInstanceUri(DelegateExecution execution) { - String uri = getBusinessCustomerUri(execution) - - uri = uri +"/" + execution.getVariable("globalSubscriberId") + "/service-subscriptions/service-subscription/" + UriUtils.encode(execution.getVariable("serviceType"),"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(execution.getVariable("serviceInstanceId"),"UTF-8") - - msoLogger.debug('AaiUtil.getAAIRequestInputUri() - AAI URI: ' + uri) - return uri - } - - //public String getBusinessCustomerUriv7(DelegateExecution execution) { - // //def uri = getUri(execution, BUSINESS_CUSTOMERV7) - // def uri = getUri(execution, 'Customer') - // msoLogger.debug('AaiUtil.getBusinessCustomerUriv7() - AAI URI: ' + uri) - // return uri - //} - - public String getCloudInfrastructureCloudRegionEndpoint(DelegateExecution execution) { - String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - def uri = getCloudInfrastructureCloudRegionUri(execution) - msoLogger.debug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri) - return endpoint + uri - } - - public String getCloudInfrastructureCloudRegionUri(DelegateExecution execution) { - def uri = getUri(execution, 'cloud-region') - msoLogger.debug('AaiUtil.getCloudInfrastructureCloudRegionUri() - AAI URI: ' + uri) - return uri - } - - public String getCloudInfrastructureTenantUri(DelegateExecution execution) { - def uri = getUri(execution, 'tenant') - msoLogger.debug('AaiUtil.getCloudInfrastructureTenantUri() - AAI URI: ' + uri) - return uri - } - - public String getSearchNodesQueryUri(DelegateExecution execution) { - def uri = getUri(execution, 'nodes-query') - msoLogger.debug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri) - return uri - } - - public String getSearchNodesQueryEndpoint(DelegateExecution execution) { - String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - def uri = getSearchNodesQueryUri(execution) - msoLogger.debug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri) - return endpoint + uri - } - - public String getSearchGenericQueryUri(DelegateExecution execution) { - def uri = getUri(execution, 'generic-query') - msoLogger.debug('AaiUtil.getSearchGenericQueryUri() - AAI URI: ' + uri) - return uri - } - public String getVersion(DelegateExecution execution, resourceName, processKey) { def versionWithResourceKey = "mso.workflow.default.aai.${resourceName}.version" def versionWithProcessKey = "mso.workflow.custom.${processKey}.aai.version" @@ -186,53 +84,13 @@ class AaiUtil { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}") } - public String getMainProcessKey(DelegateExecution execution) { - DelegateExecution exec = execution - - while (true) { - DelegateExecution parent = exec.getSuperExecution() - - if (parent == null) { - parent = exec.getParent() - - if (parent == null) { - break - } - } - - exec = parent - } - - return execution.getProcessEngineServices().getRepositoryService() - .getProcessDefinition(exec.getProcessDefinitionId()).getKey() + public String createAaiUri(AAIUri uri) { + return createAaiUri(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY)), uri) } - - public String getUri(DelegateExecution execution, resourceName) { - - def processKey = getMainProcessKey(execution) - - //set namespace - setNamespace(execution) - - // Check for flow+resource specific first - def key = "mso.workflow.${processKey}.aai.${resourceName}.uri" - def uri = UrnPropertiesReader.getVariable(key, execution) - if(uri) { - msoLogger.debug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}") - return uri - } - - // Check for versioned key - def version = getVersion(execution, resourceName, processKey) - key = "mso.workflow.default.aai.v${version}.${resourceName}.uri" - uri = UrnPropertiesReader.getVariable(key, execution) - - if(uri) { - msoLogger.debug("AaiUtil.getUri() - using versioned URI key: ${key}=${uri}") - return uri - } - - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') + public String createAaiUri(AAIVersion version, AAIUri uri) { + String endpoint = UrnPropertiesReader.getVariable("aai.endpoint") + String result = UriBuilder.fromUri(endpoint).path('aai').path(version.toString()).build().toString() + return UriBuilder.fromUri(result + uri.build().toString()).build().toString() } public String setNamespace(DelegateExecution execution) { @@ -243,6 +101,18 @@ class AaiUtil { } } + public String getNamespace() { + return getNamespace(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY))) + } + + public String getNamespace(AAIVersion version) { + String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY) + if (namespace == null) { + throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') + } + + return namespace + version + } /** * This method can be used for getting the building namespace out of uri. * NOTE: A getUri() method needs to be invoked first. @@ -253,12 +123,11 @@ class AaiUtil { * * @return namespace */ - public String getNamespaceFromUri(String uri) { - if (aaiNamespace == null) { + String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY) + if (namespace == null) { throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') } - String namespace = aaiNamespace if(uri!=null){ String version = getVersionFromUri(uri) return namespace + "v"+version @@ -296,16 +165,13 @@ class AaiUtil { * @return version */ private String getVersionFromUri(String uri) { - def version = "" - def savedVersion = "" - for (int x=2; x<6; x++) { - version = uri.substring(uri.indexOf("v")+1, uri.indexOf("v")+x) - if (!Character.isDigit(version.charAt(version.size()-1))) { - break - } - savedVersion = version + + Matcher versionRegEx = Pattern.compile("/v(\\d+)").matcher(uri) + if (versionRegEx.find()) { + return versionRegEx.group(1); } - return savedVersion + + return ""; } @@ -336,7 +202,7 @@ class AaiUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } - apiResponse = client.get() + apiResponse = client.httpGet() msoLogger.trace("COMPLETED Execute AAI Get Process ") }catch(Exception e){ @@ -682,129 +548,5 @@ class AaiUtil { return 0 } } +} - private def getPInterface(DelegateExecution execution, String aai_uri) { - - String namespace = getNamespaceFromUri(execution, aai_uri) - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - String serviceAaiPath = aai_endpoint + aai_uri - - APIResponse response = executeAAIGetCall(execution, serviceAaiPath) - return new XmlParser().parseText(response.getResponseBodyAsString()) - } - - // This method checks if interface is remote - private def isPInterfaceRemote(DelegateExecution execution, String uri) { - if(uri.contains("ext-aai-network")) { - return true - } else { - return false - } - } - - // This method returns Local and remote TPs information from AAI - public Map getTPsfromAAI(DelegateExecution execution) { - Map tpInfo = [:] - - String aai_uri = '/aai/v14/network/logical-links' - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - String serviceAaiPath = aai_endpoint + aai_uri - - APIResponse response = executeAAIGetCall(execution, serviceAaiPath) - - def logicalLinks = new XmlParser().parseText(response.getResponseBodyAsString()) - - logicalLinks."logical-link".each { link -> - def isRemoteLink = false - def pInterfaces = [] - def relationship = link."relationship-list"."relationship" - relationship.each { rel -> - if ("ext-aai-network".compareToIgnoreCase("${rel."related-to"[0]?.text()}") == 0) { - isRemoteLink = true - } - if ("p-interface".compareToIgnoreCase("${rel."related-to"[0]?.text()}") == 0) { - pInterfaces.add(rel) - } - } - - // if remote link then process - if (isRemoteLink) { - - // find remote p interface - def localTP = null - def remoteTP = null - - def pInterface0 = pInterfaces[0] - def pIntfUrl = "${pInterface0."related-link"[0].text()}" - - if (isRemotePInterface(execution, pIntfUrl)) { - remoteTP = pInterfaces[0] - localTP = pInterfaces[1] - } else { - localTP = pInterfaces[0] - remoteTP = pInterfaces[1] - } - - if (localTP != null && remoteTP != null) { - - // give local tp - def tpUrl = "${localTP."related-link"[0]?.text()}" - def intfLocal = getPInterface(execution, "${localTP?."related-link"[0]?.text()}") - tpInfo.put("local-access-node-id", tpUrl.split("/")[6]) - - def networkRef = "${intfLocal."network-ref"[0]?.text()}".split("/") - if (networkRef.size() == 6) { - tpInfo.put("local-access-provider-id", networkRef[1]) - tpInfo.put("local-access-client-id", networkRef[3]) - tpInfo.put("local-access-topology-id", networkRef[5]) - } - def ltpIdStr = tpUrl?.substring(tpUrl?.lastIndexOf("/") + 1) - if (ltpIdStr?.contains("-")) { - tpInfo.put("local-access-ltp-id", ltpIdStr?.substring(ltpIdStr?.lastIndexOf("-") + 1)) - } - - // give remote tp - tpUrl = "${remoteTP."related-link"[0]?.text()}" - def intfRemote = getPInterface(execution, "${remoteTP."related-link"[0].text()}") - tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]) - - def networkRefRemote = "${intfRemote."network-ref"[0]?.text()}".split("/") - - if (networkRefRemote.size() == 6) { - tpInfo.put("remote-access-provider-id", networkRefRemote[1]) - tpInfo.put("remote-access-client-id", networkRefRemote[3]) - tpInfo.put("remote-access-topology-id", networkRefRemote[5]) - } - def ltpIdStrR = tpUrl?.substring(tpUrl?.lastIndexOf("/") + 1) - if (ltpIdStrR?.contains("-")) { - tpInfo.put("remote-access-ltp-id", ltpIdStrR?.substring(ltpIdStr?.lastIndexOf("-") + 1)) - } - return tpInfo - } - } - - } - return tpInfo - } - - // this method check if pInterface is remote - private def isRemotePInterface(DelegateExecution execution, String uri) { - def aai_uri = uri.substring(0, uri.indexOf("/p-interfaces")) - - String namespace = getNamespaceFromUri(execution, aai_uri) - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - String serviceAaiPath = aai_endpoint + aai_uri - - APIResponse response = executeAAIGetCall(execution, serviceAaiPath) - def pnf = new XmlParser().parseText(response.getResponseBodyAsString()) - - def relationship = pnf."relationship-list"."relationship" - relationship.each { - if ("ext-aai-network".compareToIgnoreCase("${it."related-to"[0]?.text()}") == 0) { - return true - } - } - return false - } -} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 0692e5022a..9e71313e09 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor { @@ -763,4 +764,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) } } + public AAIResourcesClient getAAIClient(){ + return new AAIResourcesClient(); + } } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index b054c0f934..e4bc5f8fa2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -7,9 +7,9 @@ * 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. @@ -22,11 +22,17 @@ package org.onap.so.bpmn.common.scripts import static org.apache.commons.lang3.StringUtils.*; +import javax.ws.rs.NotFoundException + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse; @@ -102,7 +108,7 @@ class AllottedResourceUtils { // setsVariable aaiARGetResponse public String getARbyId (DelegateExecution execution, String allottedResourceId) { msoLogger.trace("getARbyId ") - String arLink = getARLinkbyId(execution, allottedResourceId) + AAIResourceUri arLink = getARLinkbyId(execution, allottedResourceId) String ar = null if (!isBlank(arLink)) { @@ -111,7 +117,7 @@ class AllottedResourceUtils { msoLogger.trace(" Exit GetARbyId - AR:" + ar) return ar; } - + public String getPSIFmARLink(DelegateExecution execution, String arLink) { // Path: /aai/{version}/business/customers/customer/{cust}/service-subscriptions/service-subscription/{subs}/service-instances/service-instance/{psiid}/allotted-resources/allotted-resource/{arid} @@ -129,39 +135,17 @@ class AllottedResourceUtils { msoLogger.trace("getARLinkbyId ") String arLink = null try { - AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) - String aaiNQUri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) - String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String aaiUrl = "${aaiNQUri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}" - - msoLogger.debug("getARLinkbyId url: \n" + aaiUrl) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, aaiUrl) - int responseCode = response.getStatusCode() - msoLogger.debug(" GET AR response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - msoLogger.debug("GET AR:" + aaiResponse) - if(responseCode == 200 || responseCode == 202){ - msoLogger.debug("GET AR Received a Good Response Code") - if(utils.nodeExists(aaiResponse, "result-data")){ - msoLogger.debug("Query for AllottedResource Url Response Does Contain Data" ) - arLink = utils.getNodeText(aaiResponse, "resource-link") - }else{ - msoLogger.debug("GET AR Response Does NOT Contain Data" ) - } - }else if(responseCode == 404){ - msoLogger.debug("GET AR received a Not Found (404) Response") - } - else{ - msoLogger.debug(" GET AR received a Bad Response: \n" + aaiResponse) - buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") - } - }catch(Exception e){ + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AaiUtil aaiUtil = new AaiUtil() + arLink = aaiUtil.createAaiUri(uri) + } catch (NotFoundException e) { + msoLogger.debug("GET AR received a Not Found (404) Response") + } catch(Exception e){ msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage()) } - msoLogger.trace(" Exit GetARLinkbyId - Link:" + arLink) + msoLogger.debug(" ***** Exit GetARLinkbyId ***** Link:" + arLink) return arLink } @@ -185,7 +169,7 @@ class AllottedResourceUtils { } arUrl = "${aai_endpoint}" + arEndpoint - + msoLogger.debug("GET AR Aai Path is: \n" + arUrl) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl) @@ -229,13 +213,13 @@ class AllottedResourceUtils { { execution.setVariable("aaiARGetResponse", ar) execution.setVariable("aaiARPath", arUrl) - + String resourceVersion = null if (utils.nodeExists(ar, "resource-version")) { resourceVersion = utils.getNodeText(ar, "resource-version") execution.setVariable("aaiARResourceVersion", resourceVersion) } - + String orchStatus = null if (utils.nodeExists(ar, "orchestration-status")) { orchStatus= utils.getNodeText(ar, "orchestration-status") @@ -285,7 +269,7 @@ class AllottedResourceUtils { } msoLogger.trace("Exit updateAROrchStatus ") } - + //Sets Variable "wasDeleted" public void deleteAR(DelegateExecution execution, String aaiARPath){ msoLogger.trace(" deleteAR - aaiARPath:" + aaiARPath) @@ -294,14 +278,14 @@ class AllottedResourceUtils { APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, aaiARPath) int responseCode = response.getStatusCode() execution.setVariable("deleteARResponseCode", responseCode) - + msoLogger.debug(" Delete AR response code:" + responseCode) String aaiResponse = response.getResponseBodyAsString() execution.setVariable("aaiARDeleteResponse", aaiResponse) msoLogger.debug("Delete AR Response:" + aaiResponse) - + //Process Response if(responseCode == 204){ msoLogger.debug(" Delete AR Received a Good Response") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index bcd740eae9..c309c3bb68 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -7,9 +7,9 @@ * 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. @@ -19,15 +19,20 @@ */ package org.onap.so.bpmn.common.scripts +import javax.ws.rs.core.UriBuilder + import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.rest.APIResponse +import org.onap.aai.domain.yang.VolumeGroup +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ConfirmVolumeGroupName.class); - + def Prefix="CVGN_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -37,7 +42,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ execution.setVariable("CVGN_volumeGroupName",null) execution.setVariable("CVGN_aicCloudRegion", null) execution.setVariable("CVGN_volumeGroupGetEndpoint",null) - + // ConfirmVolumeGroupName workflow response variable placeholders execution.setVariable("CVGN_volumeGroupNameMatches", false) execution.setVariable("CVGN_queryVolumeGroupResponseCode",null) @@ -51,43 +56,31 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ def volumeGroupId = execution.getVariable("ConfirmVolumeGroupName_volumeGroupId") def volumeGroupName= execution.getVariable("ConfirmVolumeGroupName_volumeGroupName") def aicCloudRegion = execution.getVariable("ConfirmVolumeGroupName_aicCloudRegion") - + initProcessVariables(execution) execution.setVariable("CVGN_volumeGroupId", volumeGroupId) execution.setVariable("CVGN_volumeGroupName", volumeGroupName) execution.setVariable("CVGN_aicCloudRegion", aicCloudRegion) - - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getCloudInfrastructureCloudRegionUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - msoLogger.debug("AAI URI: " + aai_uri) - execution.setVariable("CVGN_volumeGroupGetEndpoint","${aai_uri}/${aicCloudRegion}/volume-groups/volume-group/" + - volumeGroupId) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + execution.setVariable("CVGN_volumeGroupGetEndpoint", uri) } - + // send a GET request to AA&I to retrieve the Volume information based on volume-group-id // expect a 200 response with the information in the response body or a 404 if the volume group id does not exist public void queryAAIForVolumeGroupId(DelegateExecution execution) { - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("CVGN_volumeGroupGetEndpoint") - + AAIResourceUri resourceUri = execution.getVariable("CVGN_volumeGroupGetEndpoint") + try { - msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) - msoLogger.debug("queryAAIForVolumeGroupId() endpoint-" + endPoint) - msoLogger.debug("ConfirmVolumeGroup sending GET call to AAI Endpoint: " + endPoint) - - AaiUtil aaiUtil = new AaiUtil(this) - APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) - def responseData = response.getResponseBodyAsString() - def responseStatusCode = response.getStatusCode() - execution.setVariable("CVGN_queryVolumeGroupResponseCode", responseStatusCode) - execution.setVariable("CVGN_queryVolumeGroupResponse", responseData) - - msoLogger.debug("Response code:" + responseStatusCode) - msoLogger.debug("Response:" + responseData) - msoLogger.debug("Response code:" + responseStatusCode) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + Optional volumeGroupOp = getAAIClient().get(VolumeGroup.class, resourceUri) + if(volumeGroupOp.isPresent()){ + execution.setVariable("CVGN_queryVolumeGroupResponseCode", 200) + execution.setVariable("CVGN_queryVolumeGroupResponse", volumeGroupOp.get()) + }else{ + execution.setVariable("CVGN_queryVolumeGroupResponseCode", 404) + execution.setVariable("CVGN_queryVolumeGroupResponse", "Volume Group not Found!") + } } catch (Exception ex) { - // ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) execution.setVariable("CVGN_queryVolumeGroupResponseCode", 500) execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage()) @@ -100,17 +93,17 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ public void checkAAIQueryResult(DelegateExecution execution) { def result = execution.getVariable("CVGN_queryVolumeGroupResponse") - if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 404) { + def actualVolumeGroupName = "" + if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 404) { msoLogger.debug('volumeGroupId does not exist in AAI') } else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 200) { + VolumeGroup volumeGroup = execution.getVariable("CVGN_queryVolumeGroupResponse") + if(volumeGroup.getVolumeGroupName()!=null){ + actualVolumeGroupName = volumeGroup.getVolumeGroupName() + } msoLogger.debug("volumeGroupId exists in AAI") } - def xml = execution.getVariable("CVGN_queryVolumeGroupResponse") - def actualVolumeGroupName = "" - if (utils.nodeExists(xml, "volume-group-name")) { - actualVolumeGroupName = utils.getNodeText(xml, "volume-group-name") - } execution.setVariable("CVGN_volumeGroupNameMatches", false) def volumeGroupName = execution.getVariable("CVGN_volumeGroupName") @@ -134,4 +127,10 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated) } -} \ No newline at end of file + // sends a successful WorkflowResponse + public void reportSuccess(DelegateExecution execution) { + msoLogger.debug("Sending 200 back to the caller") + def responseXML = "" + execution.setVariable("WorkflowResponse", responseXML) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index c0ed81c553..13904c372d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -7,9 +7,9 @@ * 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. @@ -37,6 +37,10 @@ import org.w3c.dom.NodeList import org.xml.sax.InputSource import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.constants.Defaults /** * Vnf Module Subflow for confirming the volume group belongs @@ -63,13 +67,10 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ String incomingGroupName = execution.getVariable("volumeGroupName") String incomingTenantId = execution.getVariable("tenantId") def aicCloudRegion = execution.getVariable("aicCloudRegion") - String aai = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getCloudInfrastructureCloudRegionUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String path = aai + "${aai_uri}/${aicCloudRegion}/volume-groups/volume-group/" + volumeGroupId + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + String path = aaiUriUtil.createAaiUri(uri) APIResponse queryAAIForVolumeGroupResponse = aaiUriUtil.executeAAIGetCall(execution, path) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index 84dd70682d..3bbc4bd110 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -22,6 +22,10 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -67,8 +71,6 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_deleteGenericVnfResponse","") execution.setVariable("CAAIVfMod_deleteVfModuleResponseCode",null) execution.setVariable("CAAIVfMod_deleteVfModuleResponse","") -// execution.setVariable("CAAIVfMod_ResponseCode",null) -// execution.setVariable("CAAIVfMod_ErrorResponse","") execution.setVariable("CreateAAIVfModuleResponse","") execution.setVariable("RollbackData", null) @@ -158,38 +160,38 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_moduleModelName",execution.getVariable("vfModuleModelName")) AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiNamespace = aaiUriUtil.getNamespace() msoLogger.debug('AAI namespace is: ' + aaiNamespace) - - execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") - if (vnfId == null || vnfId.isEmpty()) { - // TBD - assert that the vnfName is not empty - execution.setVariable("CAAIVfMod_genericVnfGetEndpoint", - "${aai_uri}/?vnf-name=" + - UriUtils.encode(vnfName,"UTF-8") + "&depth=1") - } else { - execution.setVariable("CAAIVfMod_genericVnfGetEndpoint", - "${aai_uri}/" + UriUtils.encode(vnfId,"UTF-8") + "?depth=1") - } + execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") - msoLogger.debug("CreateAAIVfModule VNF PUT Endpoint: ${aai_uri}/") - execution.setVariable("CAAIVfMod_genericVnfPutEndpoint","${aai_uri}/") } // send a GET request to AA&I to retrieve the Generic VNF/VF Module information based on a Vnf Name // expect a 200 response with the information in the response body or a 404 if the Generic VNF does not exist public void queryAAIForGenericVnf(DelegateExecution execution) { - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("CAAIVfMod_genericVnfGetEndpoint") + + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri + + def vnfId = execution.getVariable("CAAIVfMod_vnfId") + def vnfName = execution.getVariable("CAAIVfMod_vnfName") + + if (vnfId == null || vnfId.isEmpty()) { + uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "") + uri.queryParam("vnf-name", vnfName) + } else { + uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + } + + uri.depth(Depth.ONE) + String endPoint = aaiUtil.createAaiUri(uri) try { msoLogger.debug("queryAAIForGenericVnf() endpoint-" + endPoint) msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) msoLogger.debug("CreateAAIVfModule sending GET call to AAI Endpoint: " + endPoint) - AaiUtil aaiUtil = new AaiUtil(this) APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) def responseData = response.getResponseBodyAsString() def statusCode = response.getStatusCode() @@ -238,18 +240,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ public void createGenericVnf(DelegateExecution execution) { // TBD - is this how we want to generate the Id for the new Generic VNF? def newVnfId = UUID.randomUUID().toString() - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + - execution.getVariable("CAAIVfMod_genericVnfPutEndpoint") + newVnfId - // update the flow execution with the new Vnf Id execution.setVariable("CAAIVfMod_vnfId",newVnfId) - - // AaiUriUtil aaiUriUtil = new AaiUriUtil(this) - // def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - // msoLogger.debug('AAI URI is: ' + aai_uri) - // String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - // msoLogger.debug('AAI namespace is: ' + namespace) - - + String payload = """ ${MsoUtils.xmlEscape(newVnfId)} ${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfName"))} @@ -262,11 +254,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload) try { + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, newVnfId) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug("createGenericVnf() endpoint-" + endPoint) msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) msoLogger.debug("Sending PUT call to AAI with Endpoint /n" + endPoint + " with payload /n" + payload) - AaiUtil aaiUtil = new AaiUtil(this); APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload); def responseData = response.getResponseBodyAsString() def responseStatusCode = response.getStatusCode() @@ -293,10 +288,9 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ if (newModuleId == null || newModuleId.isEmpty()) { newModuleId = UUID.randomUUID().toString() } - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("CAAIVfMod_genericVnfPutEndpoint") - // need to append the existing Vnf Id or the one generated in createGenericVnf() to the url - endPoint = endPoint + UriUtils.encode(execution.getVariable("CAAIVfMod_vnfId"), "UTF-8") + - "/vf-modules/vf-module/" + newModuleId; + + String vnfId = execution.getVariable("CAAIVfMod_vnfId") + int moduleIndex = 0 if (!isBaseModule) { def aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") @@ -342,11 +336,15 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_createVfModulePayload", payload) try { + + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug("createVfModule() endpoint-" + endPoint) msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) msoLogger.debug("CreateAAIVfModule sending PUT call to AAI with endpoint /n" + endPoint + " with payload /n " + payload) - AaiUtil aaiUtil = new AaiUtil(this) APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload) def responseData = response.getResponseBodyAsString() def statusCode = response.getStatusCode() @@ -554,9 +552,6 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ msoLogger.debug("RollbackData:" + rollbackData) AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - msoLogger.debug("CreateAAIVfModule rollback AAI URI: " + aai_uri) if (rollbackData != null) { if (rollbackData.hasType("VFMODULE")) { @@ -566,9 +561,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def isBaseModule = rollbackData.get("VFMODULE", "isBaseModule") execution.setVariable("DAAIVfMod_vnfId", vnfId) execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) - execution.setVariable("DAAIVfMod_genericVnfEndpoint", "${aai_uri}/" + vnfId) - execution.setVariable("DAAIVfMod_vfModuleEndpoint", "${aai_uri}/" + vnfId + - "/vf-modules/vf-module/" + vfModuleId) + DeleteAAIVfModule dvm = new DeleteAAIVfModule() // query A&AI to get the needed information for the delete(s) dvm.queryAAIForGenericVnf(execution) @@ -581,13 +574,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ if (isOneOf(responseCode, 200, 204)) { msoLogger.debug("Received " + responseCode + " to VF Module rollback request") -// execution.setVariable("RollbackResult", "SUCCESS") } else { msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Received " + responseCode + " to VF Module rollback request", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, rollbackData + System.lineSeparator() + "Response: " + response); } // a new Generic VNF was created that needs to be rolled back if (isBaseModule.equals("true")) { + dvm.queryAAIForGenericVnf(execution) + dvm.parseForResourceVersion(execution) dvm.deleteGenericVnf(execution) responseCode = execution.getVariable("DAAIVfMod_deleteGenericVnfResponseCode") response = execution.getVariable("DAAIVfMod_deleteGenericVnfResponse") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy index ec691f299e..cc1be47029 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -23,6 +23,9 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.rest.APIResponse import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -76,6 +79,9 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def aicCloudRegion = getRequiredNodeText(execution, xml,'aic-cloud-region') execution.setVariable('CAAIVfModVG_aicCloudRegion', aicCloudRegion) + def cloudOwner = getRequiredNodeText(execution, xml,'cloud-owner') + execution.setVariable('CAAIVfModVG_cloudOwner', cloudOwner) + def volumeGroupId = getRequiredNodeText(execution, xml,'volume-group-id') execution.setVariable('CAAIVfModVG_volumeGroupId', volumeGroupId) @@ -105,12 +111,10 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('CAAIVfModVG_vnfId') def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') - // Construct endpoint AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + URLEncoder.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + URLEncoder.encode(vfModuleId, "UTF-8") - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUtil.createAaiUri(uri) + try { msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("aaiResponse GET TO AAI Endpoint: " + endPoint) @@ -166,17 +170,16 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { // Construct payload by creating a Volume Group relationhip and inserting it into the VF Module def aicCloudRegion = execution.getVariable('CAAIVfModVG_aicCloudRegion') + def cloudOwner = execution.getVariable('CAAIVfModVG_cloudOwner') def volumeGroupId = execution.getVariable('CAAIVfModVG_volumeGroupId') - def Node vgRelationshipNode = createVolumeGroupRelationshipNode(aicCloudRegion, volumeGroupId) + def Node vgRelationshipNode = createVolumeGroupRelationshipNode(cloudOwner, aicCloudRegion, volumeGroupId) insertVolumeGroupRelationshipNode(vfModuleNode, vgRelationshipNode) def payload = utils.nodeToString(vfModuleNode) - // Construct endpoint AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + URLEncoder.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + URLEncoder.encode(vfModuleId, "UTF-8") - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUtil.createAaiUri(uri) + try { msoLogger.debug("CreateAAIVfModuleVolume Sendind PUT to AAI Endpoint \n " + endPoint + " with payload \n " + payload) msoLogger.debug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) @@ -212,12 +215,12 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * @param volumeGroupId Volume Group ID to use in the Volume Group relationship * @return a Node representing the new Volume Group relationship */ - private Node createVolumeGroupRelationshipNode(String aicCloudRegion, String volumeGroupId) { + private Node createVolumeGroupRelationshipNode(String cloudOwner, String aicCloudRegion, String volumeGroupId) { def Node relatedTo = new Node(null, 'related-to', 'volume-group') def Node relationshipKeyCO = new Node(null, 'relationship-key', 'cloud-region.cloud-owner') - def Node relationshipValueCO = new Node(null, 'relationship-value', 'att-aic') + def Node relationshipValueCO = new Node(null, 'relationship-value', cloudOwner) def Node relationshipDataCO = new Node(null, 'relationship-data') relationshipDataCO.append(relationshipKeyCO) relationshipDataCO.append(relationshipValueCO) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy deleted file mode 100644 index 43d540cc74..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy +++ /dev/null @@ -1,283 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.common.scripts - -import static org.apache.commons.lang3.StringUtils.*; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.apache.commons.codec.binary.Base64 -import org.apache.commons.lang3.* - -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig - -import java.net.URLEncoder; -import org.springframework.web.util.UriUtils -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger - -/** - * This class supports the GenericPutService Sub Flow. - * This Generic sub flow can be used by any flow for the - * goal of creating a Service Instance or Service-Subscription in AAI. Upon successful completion of - * this sub flow the GENPS_SuccessIndicator will be true. - * The calling flow must set the GENPS_type variable as "service-instance" - * or "service-subscription". - * A MSOWorkflowException will be thrown Upon unsuccessful - * completion or if an error occurs within this flow. - * Please map variables to the corresponding variable names - * below. - * - * - * Incoming Required Variables: - * @param - GENPS_requestId - * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription - * @param - GENPS_globalSubscriberId - Required field - * @param - GENPS_serviceType - Required Field - * @param - GENPS_payload - Required Field This will be the payload that needs to be sent. - * - * @param - GENPS_serviceInstanceId - Conditional Field. Required for service-instance. - * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. - * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. - * - * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows - * should check if a service-instance or servic-subscription exists by calling the subflow GenericGetService. if it exists then resourceversion should be - * obtained from aai and sent as an input parameter. - * - * Outgoing Variables: - * @param - GENPS_SuccessIndicator - * @param - WorkflowException - * - * - */ - - -class CustomE2EPutService extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CustomE2EPutService.class); - - String Prefix = "GENPS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - - public void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PreProcessRequest Process") - - execution.setVariable("GENPS_SuccessIndicator", false) - - try{ - // Get Variables - String requestId = execution.getVariable("GENPS_requestId") - msoLogger.debug("Incoming GENPS_requestId is: " + requestId) - - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - String serviceType = execution.getVariable("GENPS_serviceType") - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - String type = execution.getVariable("GENPS_type") - - if(type != null){ - msoLogger.debug("Incoming GENPS_type is: " + type) - if(type.equalsIgnoreCase("service-instance")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - } - }else if(type.equalsIgnoreCase("service-subscription")){ - if(isBlank(serviceType) || isBlank(globalSubscriberId)){ - msoLogger.debug("Incoming ServiceType or GlobalSubscriberId is null. These variables are required to create a service-subscription.") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.") - }else{ - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - } - }else if(type.equalsIgnoreCase("allotted-resource")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - } - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId) || isBlank(tunnelXconnectId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENPS_type is null. Variable is Required.") - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PreProcessRequest method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericPutService PreProcessRequest") - - } - msoLogger.trace("COMPLETED GenericPutService PreProcessRequest Process ") - - } - - - - /** - * This method executes a Put call to AAI for the provided - * service instance. - * - * @param - execution - * - */ - public void putServiceInstance(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PutServiceInstance method") - try { - String type = execution.getVariable("GENPS_type") - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - msoLogger.debug('AAI namespace is: ' + namespace) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String serviceAaiPath = "" - String payload = execution.getVariable("GENPS_payload") - execution.setVariable("GENPS_payload", payload) - msoLogger.debug("Incoming GENPS_payload is: " + payload) - msoLogger.debug(payload) - - String serviceType = execution.getVariable("GENPS_serviceType") - msoLogger.debug(" Incoming GENPS_serviceType is: " + serviceType) - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - - // This IF clause is if we need to create a new Service Instance - if(type.equalsIgnoreCase("service-instance")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + URLEncoder.encode(serviceInstanceId,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") - - }else if(type.equalsIgnoreCase("service-subscription")){ - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") - }else if(type.equalsIgnoreCase("allotted-resource")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - msoLogger.debug(" Incoming GENPS_tunnelXconnectId is: " + tunnelXconnectId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + "/tunnel-xconnects/tunnel-xconnect/" + UriUtils.encode(tunnelXconnectId,"UTF-8") - } - - String resourceVersion = execution.getVariable("GENPS_serviceResourceVersion") - msoLogger.debug("Incoming Resource Version is: " + resourceVersion) - if(resourceVersion !=null){ - serviceAaiPath = serviceAaiPath +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") - } - - execution.setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath) - msoLogger.debug("PUT Service Instance AAI Path is: " + "\n" + serviceAaiPath) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload) - int responseCode = response.getStatusCode() - execution.setVariable("GENPS_putServiceInstanceResponseCode", responseCode) - msoLogger.debug(" Put Service Instance response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENPS_putServiceInstanceResponse", aaiResponse) - - - //Process Response - if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) - //200 OK 201 CREATED 202 ACCEPTED - { - msoLogger.debug("PUT Service Instance Received a Good Response") - execution.setVariable("GENPS_SuccessIndicator", true) - } - - else{ - msoLogger.debug("Put Generic Service Instance Received a Bad Response Code. Response Code is: " + responseCode) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PutServiceInstance method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Put Service Instance") - } - msoLogger.trace("COMPLETED GenericPutService PutServiceInstance Process") - } - - - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index bb9846c112..178b4d1695 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -22,6 +22,10 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse import org.onap.so.rest.RESTClient; import org.onap.so.rest.RESTConfig; @@ -41,8 +45,6 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_genVnfRsrcVer",null) execution.setVariable("DAAIVfMod_vfModuleId",null) execution.setVariable("DAAIVfMod_vfModRsrcVer",null) - execution.setVariable("DAAIVfMod_genericVnfEndpoint",null) - execution.setVariable("DAAIVfMod_vfModuleEndpoint",null) execution.setVariable("DAAIVfMod_moduleExists",false) execution.setVariable("DAAIVfMod_isBaseModule", false) execution.setVariable("DAAIVfMod_isLastModule", false) @@ -69,79 +71,55 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ def vfModuleId = utils.getNodeText(xml,"vf-module-id") execution.setVariable("DAAIVfMod_vnfId", vnfId) execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) - - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - execution.setVariable("DAAIVfMod_genericVnfEndpoint", "${aai_uri}/" + vnfId) - execution.setVariable("DAAIVfMod_vfModuleEndpoint", "${aai_uri}/" + vnfId + - "/vf-modules/vf-module/" + vfModuleId) } // send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id // expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist public void queryAAIForGenericVnf(DelegateExecution execution) { - def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "?depth=1" - msoLogger.debug("DeleteAAIVfModule endPoint: " + endPoint) - def aaiRequestId = utils.getRequestID() + + def vnfId = execution.getVariable("DAAIVfMod_vnfId") - RESTConfig config = new RESTConfig(endPoint); - msoLogger.debug("queryAAIForGenericVnf() endpoint-" + endPoint) - def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) - APIResponse response = client.httpGet() - msoLogger.debug("DeleteAAIVfModule - invoking httpGet to AAI") + AaiUtil aaiUriUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + response.getResponseBodyAsString()) - responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", response.getStatusCode()) - execution.setVariable("DAAIVfMod_queryGenericVnfResponse", responseData) - msoLogger.debug("AAI Response: " + responseData) - msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse", response.getResponseBodyAsString()) + } catch (Exception ex) { msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) execution.setVariable("DAAIVfMod_queryGenericVnfResponse", "AAI GET Failed:" + ex.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during queryAAIForGenericVnf") - } } // construct and send a DELETE request to A&AI to delete a Generic Vnf // note: to get here, all the modules associated with the Generic Vnf must already be deleted public void deleteGenericVnf(DelegateExecution execution) { - def aaiRequestId = utils.getRequestID() - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + - "/?resource-version=" + execution.getVariable("DAAIVfMod_genVnfRsrcVer") - msoLogger.debug("AAI endPoint: " + endPoint) - RESTConfig config = new RESTConfig(endPoint); - msoLogger.debug("deleteGenericVnf() endpoint-" + endPoint) - def responseData = "" + try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); + String vnfId = execution.getVariable("DAAIVfMod_vnfId") + String resourceVersion = execution.getVariable("DAAIVfMod_genVnfRsrcVer") - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - APIResponse response = client.httpDelete() + AaiUtil aaiUriUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.resourceVersion(resourceVersion) + String endPoint = aaiUriUtil.createAaiUri(uri) + + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, endPoint) - responseData = response.getResponseBodyAsString() + def responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", response.getStatusCode()) execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", responseData) msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + msoLogger.debug("Response:" + System.lineSeparator() + responseData) } catch (Exception ex) { ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage()) @@ -151,32 +129,25 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // construct and send a DELETE request to A&AI to delete the Base or Add-on Vf Module public void deleteVfModule(DelegateExecution execution) { - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("DAAIVfMod_vfModuleEndpoint") + - "/?resource-version=" + execution.getVariable("DAAIVfMod_vfModRsrcVer") - def aaiRequestId = utils.getRequestID() - - RESTConfig config = new RESTConfig(endPoint); - msoLogger.debug("deleteVfModule() endpoint-" + endPoint) def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); + String vnfId = execution.getVariable("DAAIVfMod_vnfId") + String vfModuleId = execution.setVariable("DAAIVfMod_vfModuleId") + String resourceVersion = execution.getVariable("DAAIVfMod_vfModRsrcVer") - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - APIResponse response = client.httpDelete() + AaiUtil aaiUriUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + uri.resourceVersion(resourceVersion) + String endPoint = aaiUriUtil.createAaiUri(uri) - msoLogger.debug("DeleteAAIVfModule - invoking httpDelete to AAI") + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, endPoint) responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", response.getStatusCode()) execution.setVariable("DAAIVfMod_deleteVfModuleResponse", responseData) msoLogger.debug("DeleteAAIVfModule - AAI Response" + responseData) msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + msoLogger.debug("Response:" + System.lineSeparator() + responseData) } catch (Exception ex) { ex.printStackTrace() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy index 7d4adaea58..3096bedda6 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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. @@ -31,11 +31,11 @@ import java.util.regex.Matcher import java.util.regex.Pattern class ExternalAPIUtil { - + String Prefix="EXTAPI_" public MsoUtils utils = new MsoUtils() - + ExceptionUtil exceptionUtil = new ExceptionUtil() private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExternalAPIUtil.class) @@ -71,16 +71,16 @@ class ExternalAPIUtil { "\t\t\t\"serviceCharacteristic\": [ \n" + "<_requestInputs_> \n" + "\t\t\t] \n" + - "\t\t}\n" + + "\t\t}\n" + "\t}]\n" + "}" - + public static final String RequestInputsTemplate = "{ \n" + "\t\"name\": , \n" + "\t\"value\": { \n" + "\t\t\"serviceCharacteristicValue\": \n" + - "\t} \n" + + "\t} \n" + "}" public ExternalAPIUtil() { @@ -93,11 +93,11 @@ class ExternalAPIUtil { // msoLogger.debug("ExternalAPIUtil.getUri: " + uri) // return uri // } -// +// // exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'ExternalAPI URI not find') // } - - public String setTemplate(String template, Map valueMap) { + + public String setTemplate(String template, Map valueMap) { msoLogger.debug("ExternalAPIUtil setTemplate", true); StringBuffer result = new StringBuffer(); @@ -143,7 +143,7 @@ class ExternalAPIUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } - apiResponse = client.get() + apiResponse = client.httpGet() msoLogger.debug( "======== COMPLETED Execute ExternalAPI Get Process ======== ") }catch(Exception e){ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index 5cdcd0d5bf..78d147e819 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -30,6 +30,10 @@ import org.springframework.web.util.UriUtils import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse; import org.onap.so.rest.RESTClient import org.onap.so.rest.RESTConfig @@ -73,11 +77,11 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ def vnfId = execution.getVariable('vnfId') def personaModelId = execution.getVariable('personaModelId') - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.depth(Depth.ONE) + String endPoint = aaiUtil.createAaiUri(uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy deleted file mode 100644 index 01d8e9b8d5..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy +++ /dev/null @@ -1,275 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common.scripts - -import org.onap.so.bpmn.core.UrnPropertiesReader -import static org.onap.so.bpmn.common.scripts.GenericUtils.*; - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger - - - - -/** - * TODO: Support getting vnf type = vpe - * - * This class supports the GenericGetVnf Sub Flow. - * This Generic sub flow can be used by any flow for accomplishing - * the goal of getting a Vnf Object (from AAI). The flow currently - * supports the querying of 2 types of Vnfs, generic-vnf and vce. The - * type must be provided by the calling flow and the type should - * be mapped to the variable GENGV_type. The type should either be - * "generic-vnf" or "vce". If the Vnf Id is not provided by the calling - * flow then this sub flow will execute the query to get the - * Vnf using the Vnf Name. Therefore, the calling flow must provide - * either the Vnf Id or Vnf Name. - * - * Upon successful completion of this sub flow the - * GENGV_SuccessIndicator will be true and the query response payload - * will be set to GENGV_vnf. An MSOWorkflowException will - * be thrown upon unsuccessful completion or if an error occurs - * at any time during this sub flow. Please map variables - * to the corresponding variable names below. - * - * Note - if this sub flow receives a Not Found (404) response - * from AAI at any time this will be considered an acceptable - * successful response however the GENGV_FoundIndicator - * set to false. This will allow the calling flow to distinguish - * between the two success scenarios, "Success where Vnf is found" - * and "Success where Vnf is NOT found". - * - * - * Variable Mapping Below - * - * In Mapping Variables: - * @param - GENGV_vnfId or @param - GENGV_vnfName - * @param - GENGV_type - * - * Out Mapping Variables: - * @param - GENGV_vnf - * @param - GENGV_SuccessIndicator - * @param - GENGV_FoundIndicator - * @param - WorkflowException - * - * - */ -class GenericGetVnf extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenericGetVnf.class); - - - String Prefix = "GENGV_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - /** - * This method validates the incoming variables and - * determines the subsequent event based on which - * variables the calling flow provided. - * - * @param - execution - */ - public void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericGetVnf PreProcessRequest Process") - - execution.setVariable("GENGV_getVnfByName", false) - execution.setVariable("GENGV_SuccessIndicator", false) - execution.setVariable("GENGV_FoundIndicator", false) - - try{ - // Get Variables - String vnfId = execution.getVariable("GENGV_vnfId") - msoLogger.debug("Incoming Vnf Id is: " + vnfId) - String vnfName = execution.getVariable("GENGV_vnfName") - msoLogger.debug("Incoming Vnf Name is: " + vnfName) - - if(isBlank(vnfId) && isBlank(vnfName)){ - msoLogger.debug("Incoming Vnf Name and Vnf Id are null. At least one is required!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Vnf Name and Vnf Id are null. At least one is required.") - }else{ - if(isBlank(vnfId)){ - execution.setVariable("GENGV_getVnfByName", true) - } - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.debug(" Error encountered within GenericGetVnf PreProcessRequest method!" + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericGetVnf PreProcessRequest") - - } - msoLogger.trace("COMPLETED GenericGetVnf PreProcessRequest Process ") - } - - /** - * This method executes a GET call to AAI to obtain the - * Vnf using the Vnf Name - * - * @param - execution - */ - public void getVnfByName(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericGetVnf GetVnfByName Process") - try { - String vnfName = execution.getVariable("GENGV_vnfName") - msoLogger.debug("Getting Vnf by Vnf Name: " + vnfName) - String type = execution.getVariable("GENGV_type") - msoLogger.debug("Type of Vnf Getting is: " + type) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - - //Determine Type of Vnf Querying For. - def aai_uri = "" - if(type.equals("generic-vnf")){ - aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - }else if(type.equals("vce")){ - aai_uri = aaiUriUtil.getNetworkVceUri(execution) - }else{ - msoLogger.debug("Invalid Incoming GENGV_type") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENGV_type") - } - - String getVnfPath = "${aai_endpoint}${aai_uri}?vnf-name=" + UriUtils.encode(vnfName, "UTF-8") + "&depth=1" - - execution.setVariable("GENGV_getVnfPath", getVnfPath) - msoLogger.debug("Get Vnf Url is: " + getVnfPath) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) - int responseCode = response.getStatusCode() - execution.setVariable("GENGV_getVnfResponseCode", responseCode) - msoLogger.debug(" GET Vnf response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENGV_getVnfResponse", aaiResponse) - - //Process Response - if(responseCode == 200){ - msoLogger.debug("GET Vnf Received a Good Response") - if(utils.nodeExists(aaiResponse, type)){ - msoLogger.debug("GET Vnf Response Contains a Vnf") - execution.setVariable("GENGV_FoundIndicator", true) - execution.setVariable("GENGV_vnf", aaiResponse) - execution.setVariable("WorkflowResponse", aaiResponse) - }else{ - msoLogger.debug("GET Vnf Response Does NOT Contain a Vnf") - } - - }else if(responseCode == 404){ - msoLogger.debug("GET Vnf Received a Not Found (404) Response") - }else{ - msoLogger.debug("GET Vnf Received a Bad Response: \n" + aaiResponse) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericGetVnf GetVnfByName method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfByName") - } - msoLogger.trace("COMPLETED GenericGetVnf GetVnfByName Process") - } - - /** - * This method executes a GET call to AAI to obtain the - * Vnf using the Vnf Id - * - * @param - execution - */ - public void getVnfById(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericGetVnf GetVnfById Process") - try { - String vnfId = execution.getVariable("GENGV_vnfId") - msoLogger.debug("Getting Vnf by Vnf Id: " + vnfId) - String type = execution.getVariable("GENGV_type") - msoLogger.debug("Type of Vnf Getting is: " + type) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - - //Determine Type of Vnf Querying For. - def aai_uri = "" - if(type.equals("generic-vnf")){ - aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - }else if(type.equals("vce")){ - aai_uri = aaiUriUtil.getNetworkVceUri(execution) - }else if(type.equals("vpe")){ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "GenericGetVnf does not yet support getting type of vnf = vpe") - }else{ - msoLogger.debug("Invalid Incoming GENGV_type") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENGV_type") - } - msoLogger.debug("Using AAI Uri: " + aai_uri) - - String getVnfPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - msoLogger.debug("GET Vnf Endpoint is: " + getVnfPath) - - execution.setVariable("GENGV_getVnfPath", getVnfPath) - msoLogger.debug("Get Vnf Url is: " + getVnfPath) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) - int responseCode = response.getStatusCode() - execution.setVariable("GENGV_getVnfResponseCode", responseCode) - msoLogger.debug(" GET Vnf response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENGV_getVnfResponse", aaiResponse) - - //Process Response - if(responseCode == 200){ - msoLogger.debug("GET Vnf Received a Good Response") - if(utils.nodeExists(aaiResponse, type)){ - msoLogger.debug("GET Vnf Response Contains a Vnf") - execution.setVariable("GENGV_FoundIndicator", true) - execution.setVariable("GENGV_vnf", aaiResponse) - execution.setVariable("WorkflowResponse", aaiResponse) - }else{ - msoLogger.debug("GET Vnf Response Does NOT Contain a Vnf") - } - - }else if(responseCode == 404){ - msoLogger.debug("GET Vnf Received a Not Found (404) Response") - }else{ - msoLogger.debug("GET Vnf Received a BAD REST Response: \n" + aaiResponse) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericGetVnf GetVnfById method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfById") - } - msoLogger.trace("COMPLETED GenericGetVnf GetVnfById Process") - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy deleted file mode 100644 index 8cc756d412..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy +++ /dev/null @@ -1,282 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common.scripts - -import org.onap.so.bpmn.core.UrnPropertiesReader - -import static org.apache.commons.lang3.StringUtils.*; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.apache.commons.codec.binary.Base64 -import org.apache.commons.lang3.* - -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig - -import java.net.URLEncoder; -import org.springframework.web.util.UriUtils -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger - - - -/** - * This class supports the GenericPutService Sub Flow. - * This Generic sub flow can be used by any flow for the - * goal of creating a Service Instance or Service-Subscription in AAI. Upon successful completion of - * this sub flow the GENPS_SuccessIndicator will be true. - * The calling flow must set the GENPS_type variable as "service-instance" - * or "service-subscription". - * A MSOWorkflowException will be thrown Upon unsuccessful - * completion or if an error occurs within this flow. - * Please map variables to the corresponding variable names - * below. - * - * - * Incoming Required Variables: - * @param - GENPS_requestId - * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription - * @param - GENPS_globalSubscriberId - Required field - * @param - GENPS_serviceType - Required Field - * @param - GENPS_payload - Required Field This will be the payload that needs to be sent. - * - * @param - GENPS_serviceInstanceId - Conditional Field. Required for service-instance. - * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. - * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. - * - * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows - * should check if a service-instance or servic-subscription exists by calling the subflow. if it exists then resourceversion should be - * obtained from aai and sent as an input parameter. - * - * Outgoing Variables: - * @param - GENPS_SuccessIndicator - * @param - WorkflowException - * - * - */ - - -class GenericPutService extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenericPutService.class); - - - String Prefix = "GENPS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - - public void preProcessRequest(DelegateExecution execution) { - execution.setVariable("isDebugLogEnabled","true") - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PreProcessRequest Process") - - execution.setVariable("GENPS_SuccessIndicator", false) - - try{ - // Get Variables - String requestId = execution.getVariable("GENPS_requestId") - msoLogger.debug("Incoming GENPS_requestId is: " + requestId) - - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - String serviceType = execution.getVariable("GENPS_serviceType") - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - String type = execution.getVariable("GENPS_type") - - if(type != null){ - msoLogger.debug("Incoming GENPS_type is: " + type) - if(type.equalsIgnoreCase("service-instance")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - } - }else if(type.equalsIgnoreCase("service-subscription")){ - if(isBlank(serviceType) || isBlank(globalSubscriberId)){ - msoLogger.debug("Incoming ServiceType or GlobalSubscriberId is null. These variables are required to create a service-subscription.") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.") - }else{ - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - } - }else if(type.equalsIgnoreCase("allotted-resource")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - } - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId) || isBlank(tunnelXconnectId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENPS_type is null. Variable is Required.") - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PreProcessRequest method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericPutService PreProcessRequest") - - } - msoLogger.trace("COMPLETED GenericPutService PreProcessRequest Process ") - - } - - /** - * This method executes a Put call to AAI for the provided - * service instance. - * - * @param - execution - * - */ - public void putServiceInstance(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PutServiceInstance method") - try { - String type = execution.getVariable("GENPS_type") - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - msoLogger.debug('AAI namespace is: ' + namespace) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String serviceAaiPath = "" - String payload = execution.getVariable("GENPS_payload") - execution.setVariable("GENPS_payload", payload) - msoLogger.debug("Incoming GENPS_payload is: " + payload) - msoLogger.debug(payload) - - String serviceType = execution.getVariable("GENPS_serviceType") - msoLogger.debug(" Incoming GENPS_serviceType is: " + serviceType) - - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - - // This IF clause is if we need to create a new Service Instance - if(type.equalsIgnoreCase("service-instance")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + URLEncoder.encode(serviceInstanceId,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") - - }else if(type.equalsIgnoreCase("service-subscription")){ - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") - }else if(type.equalsIgnoreCase("allotted-resource")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - msoLogger.debug(" Incoming GENPS_tunnelXconnectId is: " + tunnelXconnectId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + "/tunnel-xconnects/tunnel-xconnect/" + UriUtils.encode(tunnelXconnectId,"UTF-8") - } - - String resourceVersion = execution.getVariable("GENPS_serviceResourceVersion") - msoLogger.debug("Incoming Resource Version is: " + resourceVersion) - if(resourceVersion !=null){ - serviceAaiPath = serviceAaiPath +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") - } - - execution.setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath) - msoLogger.debug("PUT Service Instance AAI Path is: " + "\n" + serviceAaiPath) - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload) - int responseCode = response.getStatusCode() - execution.setVariable("GENPS_putServiceInstanceResponseCode", responseCode) - msoLogger.debug(" Put Service Instance response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENPS_putServiceInstanceResponse", aaiResponse) - - //Process Response - if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) - //200 OK 201 CREATED 202 ACCEPTED - { - msoLogger.debug("PUT Service Instance Received a Good Response") - execution.setVariable("GENPS_SuccessIndicator", true) - } - - else{ - msoLogger.debug("Put Generic Service Instance Received a Bad Response Code. Response Code is: " + responseCode) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PutServiceInstance method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Put Service Instance") - } - msoLogger.trace("COMPLETED GenericPutService PutServiceInstance Process") - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy index 2e5499c158..1e8569c3e7 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy @@ -20,43 +20,29 @@ package org.onap.so.bpmn.common.scripts; -import org.apache.commons.lang3.* - -import groovy.xml.XmlUtil -import org.onap.so.bpmn.core.UrnPropertiesReader - +import javax.ws.rs.core.UriBuilder import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory import javax.xml.transform.Transformer import javax.xml.transform.TransformerFactory -import javax.xml.transform.TransformerException import javax.xml.transform.dom.DOMSource import javax.xml.transform.stream.StreamResult -import org.camunda.bpm.engine.delegate.BpmnError +import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.DelegateExecution -import org.w3c.dom.Document -import org.w3c.dom.Element - -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MsoLogger - -import org.onap.so.logger.MessageEnum - - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.w3c.dom.Document import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap import org.w3c.dom.Node import org.w3c.dom.NodeList; import org.xml.sax.InputSource +import groovy.xml.XmlUtil + /** * This groovy class supports the any Network processes that need the methods defined here. @@ -332,41 +318,9 @@ class NetworkUtils { return requestPayload } - - def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, tenantId, cloudRegion, namespace, modelCustomizationId) { - - String requestPayload = - """ - ${MsoUtils.xmlEscape(groupId)} - ${MsoUtils.xmlEscape(volumeName)} - - ${MsoUtils.xmlEscape(vnfType)} - Pending - ${MsoUtils.xmlEscape(modelCustomizationId)} - - - tenant - - tenant.tenant-id - ${MsoUtils.xmlEscape(tenantId)} - - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - ${MsoUtils.xmlEscape(cloudRegion)} - - - - """ - - return requestPayload - } - - def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) { - + + def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudOwner, cloudRegion, namespace, modelCustomizationId) { + String requestPayload = """ ${MsoUtils.xmlEscape(groupId)} @@ -391,7 +345,7 @@ class NetworkUtils { cloud-region.cloud-owner - att-aic + ${cloudOwner} cloud-region.cloud-region-id @@ -858,10 +812,8 @@ class NetworkUtils { if (utils.getNodeText(relationshipXml, 'related-to') == "cloud-region") { def relatedLink = utils.getNodeText(relationshipXml, 'related-link') if (relatedLink != null || relatedLink != "") { - lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/att-aic/")+9, relatedLink.length()) - if (lcpCloudRegion.contains('/')) { - lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/att-aic/")+9, relatedLink.length()-1) - } + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.CLOUD_REGION, UriBuilder.fromUri(relatedLink).build()) + lcpCloudRegion = aaiUri.getURIKeys().getOrDefault("cloud-region", "") } } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index a6f8ff469d..e182ae3300 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -7,9 +7,9 @@ * 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. @@ -22,8 +22,17 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.camunda.bpm.model.dmn.instance.OrganizationUnit +import org.hibernate.engine.jdbc.Size.LobMultiplier import org.onap.so.bpmn.core.WorkflowException +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse import org.onap.so.rest.RESTClient import org.onap.so.rest.RESTConfig @@ -36,12 +45,12 @@ import org.onap.so.logger.MsoLogger public class PrepareUpdateAAIVfModule extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, PrepareUpdateAAIVfModule.class); - + ExceptionUtil exceptionUtil = new ExceptionUtil() private MsoUtils utils = new MsoUtils() /** * Initialize the flow's variables. - * + * * @param execution The flow's execution instance. */ public void initProcessVariables(DelegateExecution execution) { @@ -58,11 +67,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', null) execution.setVariable('PUAAIVfMod_updateVfModuleResponse', '') execution.setVariable('PUAAIVfMod_outVfModule', null) - } - + } + /** * Check for missing elements in the received request. - * + * * @param execution The flow's execution instance. */ public void preProcessRequest(DelegateExecution execution) { @@ -75,15 +84,15 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { def xml = execution.getVariable('PrepareUpdateAAIVfModuleRequest') msoLogger.debug('Received request xml:\n' + xml) msoLogger.debug("PrepareUpdateAAIVfModule Request : " + xml) - + initProcessVariables(execution) - + def vnfId = getRequiredNodeText(execution, xml,'vnf-id') execution.setVariable('PUAAIVfMod_vnfId', vnfId) def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id') execution.setVariable('PUAAIVfMod_vfModuleId', vfModuleId) - + def orchestrationStatus = getRequiredNodeText(execution, xml,'orchestration-status') execution.setVariable('PUAAIVfMod_orchestrationStatus', orchestrationStatus) @@ -95,11 +104,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) } } - + /** * Using the received vnfId, query AAI to get the corresponding Generic VNF. * A 200 response is expected with the Generic VNF in the response body. - * + * * @param execution The flow's execution instance. */ public void getGenericVnf(DelegateExecution execution) { @@ -110,40 +119,16 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { try { def vnfId = execution.getVariable('PUAAIVfMod_vnfId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - - msoLogger.debug("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) + + try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - String aaiRequestId = utils.getRequestID() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/xml'). - addHeader('Accept','application/xml'); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') - APIResponse response = client.httpGet() - msoLogger.debug("PrepareUpdateAAIVfModule: - invoking httpGet to AAI") - - responseData = response.getResponseBodyAsString() - execution.setVariable('PUAAIVfMod_getVnfResponseCode', response.getStatusCode()) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE)) + GenericVnf responseData = wrapper.asBean(GenericVnf.class).get() + execution.setVariable('PUAAIVfMod_getVnfResponse', responseData) - - msoLogger.debug("PrepareUpdateAAIVfModule: AAI Response : " + responseData) - msoLogger.debug("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode()) - - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) + } catch (Exception ex) { msoLogger.error(ex); msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) @@ -158,13 +143,13 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage()) } } - + /** * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module * is the base VF Module and it's not the only VF Module for this Generic VNF, that we're not * attempting to delete it. - * + * * @param execution The flow's execution instance. */ public void validateVfModule(DelegateExecution execution) { @@ -172,22 +157,30 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + try { - def genericVnf = execution.getVariable('PUAAIVfMod_getVnfResponse') + GenericVnf genericVnf = execution.getVariable('PUAAIVfMod_getVnfResponse') def vnfId = execution.getVariable('PUAAIVfMod_vnfId') def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') - def vnfName = getNodeTextForce(genericVnf, 'vnf-name') + def vnfName = genericVnf.getVnfName() execution.setVariable('PUAAIVfMod_vnfName', vnfName) - def VfModule vfModule = findVfModule(genericVnf, vfModuleId) - if (vfModule == null) { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourcesClient resourceClient = new AAIResourcesClient() + + + + // def VfModule vfModule = findVfModule(genericVnf, vfModuleId) + if (!resourceClient.exists(uri)) { def String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\'' execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) execution.setVariable('PUAAIVfMod_vfModuleOK', false) } else { + AAIResultWrapper wrapper = resourceClient.get(uri) + org.onap.aai.domain.yang.VfModule vfModule = wrapper.asBean(org.onap.aai.domain.yang.VfModule.class) + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') - msoLogger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() +', isOnlyVfModule=' + vfModule.isOnlyVfModule() + ', new orchestration-status=' + orchestrationStatus) - if (vfModule.isBaseVfModule() && !vfModule.isOnlyVfModule() && orchestrationStatus.equals('pending-delete')) { + if (vfModule.isBaseVfModule && genericVnf.getVfModules().getVfModule().size() > 1 && vfModule.getOrchestrationStatus().equals('pending-delete')) { def String msg = 'Orchestration status for VF Module \'' + vfModuleId + '\' cannot be set to \'pending-delete\' since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\'' execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) @@ -197,7 +190,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { execution.setVariable('PUAAIVfMod_vfModuleOK', true) } } - + msoLogger.trace('Exited ' + method) } catch (BpmnError e) { throw e; @@ -206,10 +199,10 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) } } - + /** * Construct and send a PATCH request to AAI to update the VF Module. - * + * * @param execution The flow's execution instance. */ public void updateVfModule(DelegateExecution execution) { @@ -217,39 +210,33 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + try { // Construct payload - def VfModule vfModule = (VfModule) execution.getVariable('PUAAIVfMod_vfModule') - def Node newVfModuleNode = vfModule.getNode().clone() + org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('PUAAIVfMod_vfModule') + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') - def Node orchestrationStatusNode = utils.getChildNode(newVfModuleNode, 'orchestration-status') - if (orchestrationStatusNode == null) { - // Node doesn't exist, this should never happen, right? - new Node(newVfModuleNode, 'orchestration-status', orchestrationStatus) - } else { - // Node already exists, just give it a new value - orchestrationStatusNode.setValue(orchestrationStatus) - } - def VfModule newVfModule = new VfModule(newVfModuleNode, vfModule.isOnlyVfModule()) + + vfModule.setOrchestrationStatus(orchestrationStatus) + //def payload = utils.nodeToString(newVfModuleNode) - + // Construct endpoint def vnfId = execution.getVariable('PUAAIVfMod_vnfId') def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') - + def payload = """{ "vf-module-id": "${vfModuleId}", "orchestration-status": "${orchestrationStatus}" }""" - + msoLogger.debug("VfModule payload : " + payload) - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + uri.depth(Depth.ONE) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) try { @@ -275,16 +262,16 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { msoLogger.debug('Response:' + System.lineSeparator() + responseData) msoLogger.debug("PrepareUpdateAAIVfModule: AAI Response : " + responseData) msoLogger.debug("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode()) - + // Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for // backward compatibilty, the heat-stack-id is an output - execution.setVariable('PUAAIVfMod_outVfModule', newVfModule) + execution.setVariable('PUAAIVfMod_outVfModule', vfModule) def vnfName = execution.getVariable('PUAAIVfMod_vnfName') msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName) // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead - execution.setVariable('WorkflowResponse', newVfModule) - msoLogger.debug('Output PUAAIVfMod_outVfModule set for VF Module Id \'' + newVfModule.getElementText('vf-module-id') + '\'') - def heatStackId = newVfModule.getElementText('heat-stack-id') + execution.setVariable('WorkflowResponse', vfModule) + + def heatStackId = vfModule.getHeatStackId() execution.setVariable('PUAAIVfMod_heatStackId', heatStackId) msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'') } catch (Exception ex) { @@ -299,12 +286,12 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { } catch (Exception e) { msoLogger.error(e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage()) - } + } } - + /** * Generates a WorkflowException if the AAI query returns a response code other than 200. - * + * * @param execution The flow's execution instance. */ public void handleVnfNotFound(DelegateExecution execution) { @@ -318,13 +305,13 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { WorkflowException exception = new WorkflowException(processKey, 5000, execution.getVariable('PUAAIVfMod_getVnfResponse')) execution.setVariable('WorkflowException', exception) - + msoLogger.trace('Exited ' + method) } - + /** * Generates a WorkflowException if the VF Module does not pass validation. - * + * * @param execution The flow's execution instance. */ public void handleVfModuleValidationError(DelegateExecution execution) { @@ -332,21 +319,21 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + def String errorMsg = 'VF Module validation error: ' + execution.getVariable('PUAAIVfMod_vfModuleValidationError') msoLogger.error(errorMsg); msoLogger.debug("PrepareUpdateAAIVfModule: Error Message : " + errorMsg) - + String processKey = getProcessKey(execution); WorkflowException exception = new WorkflowException(processKey, 5000, errorMsg) execution.setVariable('WorkflowException', exception) msoLogger.trace('Exited ' + method) } - + /** * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. - * + * * @param execution The flow's execution instance. */ public void handleUpdateVfModuleFailure(DelegateExecution execution) { @@ -360,7 +347,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { WorkflowException exception = new WorkflowException(processKey, 5000, execution.getVariable('PUAAIVfMod_updateVfModuleResponse')) execution.setVariable('WorkflowException', exception) - + msoLogger.trace('Exited ' + method) } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 7d7b9e103f..3e7c4f2d49 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -24,6 +24,10 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum @@ -129,10 +133,10 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) + try { msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("Sending GET to AAI endpoint: " + endPoint) @@ -246,9 +250,8 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + String endPoint = aaiUriUtil.createAaiUri(uri) try { msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy index 68b2df213a..c455ae90ce 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -24,6 +24,9 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum @@ -104,12 +107,10 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('UAAIVfMod_vnfId') def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') - // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + UriUtils.encode(vfModuleId, "UTF-8") - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUriUtil.createAaiUri(uri) + try { msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("UpdateAAIVfModule sending GET to AAI endpoint: " + endPoint) @@ -202,12 +203,9 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } """ - - // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + UriUtils.encode(vfModuleId, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUriUtil.createAaiUri(uri) try { msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java index 01846681db..91cd2ad791 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java @@ -7,9 +7,9 @@ * 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. @@ -35,6 +35,8 @@ public class Candidate implements Serializable { private CandidateType candidateType; @JsonProperty("candidates") private List candidates; + @JsonProperty("cloudOwner") + private String cloudOwner; /** * list of candidates @@ -68,4 +70,20 @@ public class Candidate implements Serializable { this.candidateType = candidateType; } + /** + * The name of the cloud owner. Required if candidateType is cloudRegionId + */ + public String getCloudOwner(){ + return cloudOwner; + } + + /** + * The name of the cloud owner. Required if candidateType is cloudRegionId + */ + public void setCloudOwner(String cloudOwner){ + this.cloudOwner = cloudOwner; + } + + + } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java index 9540b9148e..40c76a3c92 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,6 @@ public enum CandidateType { return name; } - //TODO added to get PojoTest to work public String getName(){ return name; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index eb4f4ca0d5..769d3e4e89 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -101,7 +101,6 @@ public class BBInputSetup implements JavaDelegate { private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap"; private static final String GBB_INPUT_VAR_NAME = "gBBInput"; private static final String EXECUTE_BB_VAR_NAME = "buildingBlock"; - private static final String CLOUD_OWNER = "att-aic"; private static final String VOLUME_GROUP = "VolumeGroup"; private static final String VF_MODULE = "VfModule"; private static final String NETWORK = "Network"; @@ -384,7 +383,7 @@ public class BBInputSetup implements JavaDelegate { if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) { for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { String volumeGroupCustId = - this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); @@ -801,9 +800,8 @@ public class BBInputSetup implements JavaDelegate { requestContext.setAction(requestAction); requestContext.setMsoRequestId(executeBB.getRequestId()); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils - .getCloudRegion(requestDetails.getCloudConfiguration(), CLOUD_OWNER); - CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion, - CLOUD_OWNER); + .getCloudRegion(requestDetails.getCloudConfiguration()); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); outputBB.setOrchContext(orchContext); outputBB.setRequestContext(requestContext); outputBB.setCloudRegion(cloudRegion); @@ -981,9 +979,8 @@ public class BBInputSetup implements JavaDelegate { String requestAction, CloudConfiguration cloudConfiguration) throws Exception { ServiceInstance serviceInstance = gBB.getServiceInstance(); if (cloudConfiguration != null && requestAction.equalsIgnoreCase("deleteInstance")) { - org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration, - CLOUD_OWNER); - CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion, CLOUD_OWNER); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); gBB.setCloudRegion(cloudRegion); } if (bbName.contains(VNF)) { @@ -1030,7 +1027,7 @@ public class BBInputSetup implements JavaDelegate { this.mapCatalogVnf(vnf, vnfModelInfo, service); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId()); if (cloudConfiguration != null) { - String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()) .getModelCustomizationId(); ModelInfo volumeGroupModelInfo = new ModelInfo(); @@ -1116,6 +1113,7 @@ public class BBInputSetup implements JavaDelegate { String vfModuleId = lookupKeyMap.get(ResourceKey.VF_MODULE_ID); CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId()); + cloudConfig.setCloudOwner(cloudRegion.getCloudOwner()); this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null, vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig); } @@ -1193,9 +1191,8 @@ public class BBInputSetup implements JavaDelegate { } } if(cloudConfiguration != null) { - org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration, - CLOUD_OWNER); - return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion, CLOUD_OWNER); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration); + return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); } else { msoLogger.debug("Could not find any cloud configuration for this request."); return null; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 0c7eb0973f..6c399ddbbb 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -351,14 +351,12 @@ public class BBInputSetupMapperLayer { return context; } - protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion, String cloudOwner) { + protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) { CloudRegion cloudRegion = new CloudRegion(); if(cloudConfiguration != null) cloudRegion = modelMapper.map(cloudConfiguration, CloudRegion.class); if(aaiCloudRegion != null) modelMapper.map(aaiCloudRegion, cloudRegion); - if(cloudOwner != null) - cloudRegion.setCloudOwner(cloudOwner); return cloudRegion; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 84ecfc7576..4617fc4710 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -163,13 +163,14 @@ public class BBInputSetupUtils { } } - protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration, String cloudOwner) { + protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration) { if (cloudConfiguration != null) { String cloudRegionId = cloudConfiguration.getLcpCloudRegionId(); - if (cloudRegionId != null && !cloudRegionId.isEmpty()) { + String cloudOwner = cloudConfiguration.getCloudOwner(); + if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) { return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, - cloudConfiguration.getLcpCloudRegionId())).orElse(null); + cloudRegionId)).orElse(null); } else { return null; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java index f87ec91440..89eff5f65a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java @@ -182,7 +182,7 @@ public class ApplicationControllerClient { commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); - commonHeader.setSubRequestId(requestId); + commonHeader.setSubRequestId(UUID.randomUUID().toString()); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn deleted file mode 100644 index f519bc9dbe..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn +++ /dev/null @@ -1,201 +0,0 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_5 - - - - SequenceFlow_4 - SequenceFlow_5 - - - - - SequenceFlow_3 - SequenceFlow_4 - - - - - SequenceFlow_1 - SequenceFlow_3 - - - - - - SequenceFlow_6 - - - - - SequenceFlow_7 - - - SequenceFlow_6 - SequenceFlow_7 - - - - - - - SequenceFlow_9 - - - - - SequenceFlow_9 - SequenceFlow_10 - - - - SequenceFlow_10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn deleted file mode 100644 index 5784c10d3e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn +++ /dev/null @@ -1,212 +0,0 @@ - - - - - SequenceFlow_1 - - - SequenceFlow_1 - SequenceFlow_2 - - - - - - SequenceFlow_2 - noVnfId - haveVnfId - - - - - - - noVnfId - SequenceFlow_9 - - - - - SequenceFlow_9 - SequenceFlow_10 - SequenceFlow_7 - - - - haveVnfId - SequenceFlow_10 - - - - - - SequenceFlow_12 - - - - SequenceFlow_11 - SequenceFlow_12 - - - - - SequenceFlow_11 - - - - - - SequenceFlow_7 - SequenceFlow_8 - - - - - SequenceFlow_8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn deleted file mode 100644 index 2d18f38c16..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn +++ /dev/null @@ -1,201 +0,0 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_5 - - - - SequenceFlow_4 - SequenceFlow_5 - - - - - SequenceFlow_3 - SequenceFlow_4 - - - - - SequenceFlow_1 - SequenceFlow_3 - - - - - - SequenceFlow_6 - - - - - SequenceFlow_7 - - - SequenceFlow_6 - SequenceFlow_7 - - - - - - - SequenceFlow_9 - - - - - SequenceFlow_9 - SequenceFlow_10 - - - - SequenceFlow_10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy index 79caf5b9ac..05b1c5e6ed 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -47,11 +47,11 @@ import org.camunda.bpm.engine.repository.ProcessDefinition @RunWith(MockitoJUnitRunner.class) @Ignore class AaiUtilTest extends MsoGroovyTest { - + @Rule public WireMockRule wireMockRule = new WireMockRule(8090); - + @Rule public ExpectedException thrown = ExpectedException.none @@ -127,275 +127,6 @@ class AaiUtilTest extends MsoGroovyTest { } - @Test - public void testGetUriDefaultVersion() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetUriFlowAndResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.CreateAAIVfModule.aai.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v6/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetNetworkGenericVnfEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) - } - - @Test - public void testGetNetworkGenericVnfUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) - assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) - } - - @Test - public void testGetNetworkVpnBindingUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) - assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) - } - - @Test - public void testGetNetworkPolicyUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn('/aai/v8/network/network-policies/network-policy') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkPolicyUri(mockExecution) - assertEquals('/aai/v8/network/network-policies/network-policy', uri) - } - - @Test - public void testGetNetworkTableReferencesUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.route-table-reference.uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) - assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) - } - - @Test - public void testGetNetworkVceUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vce.uri")).thenReturn('/aai/v8/network/vces/vce') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVceUri(mockExecution) - assertEquals('/aai/v8/network/vces/vce', uri) - } - - @Test - public void testGetNetworkL3NetworkUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetBusinessCustomerUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getBusinessCustomerUri(mockExecution) - assertEquals('/aai/v8/business/customers/customer', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureTenantUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.tenant.uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) - } - - @Test - public void testGetSearchNodesQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) - assertEquals('/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchNodesQueryEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchGenericQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-query.uri")).thenReturn('/aai/v8/search/generic-query') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) - assertEquals('/aai/v8/search/generic-query', uri) - } - - @Test - public void testGetNamespaceFromUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('6') - when(mockExecution.getVariable("mso.workflow.default.aai.v6.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class - def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v6', ns) - } - @Test public void testExecuteAAIGetCall() { ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') @@ -419,40 +150,6 @@ class AaiUtilTest extends MsoGroovyTest { def uri = aaiUtil.executeAAIPutCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId",aaiPaylod) } - @Test - public void testGetNamespaceFromUri2() { - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10') - when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class - def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v10', ns) - } - - @Test - public void testGetNamespaceFromUri3() { - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('100') - when(mockExecution.getVariable("mso.workflow.default.aai.v100.l3-network.uri")).thenReturn('/aai/v100/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class - def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v100', ns) - } - @Test public void testGetNamespaceFromUri_twoArguments() { // (execution, uri) ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy index e065ccd14f..a96127aa2d 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy @@ -20,151 +20,64 @@ package org.onap.so.bpmn.common.scripts -import com.github.tomakehurst.wiremock.junit.WireMockRule - import static org.mockito.Mockito.* -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService + +import javax.ws.rs.core.UriBuilder + +import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake import org.junit.Assert -import org.junit.Rule +import org.junit.Before import org.junit.Test -import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException - -import static com.github.tomakehurst.wiremock.client.WireMock.* +import org.mockito.MockitoAnnotations +import org.mockito.Spy +import org.onap.aai.domain.yang.VolumeGroup +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory -@RunWith(MockitoJUnitRunner.class) class ConfirmVolumeGroupNameTest extends MsoGroovyTest { + + @Spy + private ConfirmVolumeGroupName confirmVolumeGroupName; - private static final def AAA_URI = "uri_test" - private static final def AIC_CLOUD_REGION = "AicClReg_test" - private static final def VOLUME_GROUP_NAME = "volumeTestGName" - private static final def VOLUME_GROUP_ID = "vol_gr_id_test" - - @Captor - ArgumentCaptor captor= ArgumentCaptor.forClass(ExecutionEntity.class); - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - @Test - void preProcessRequestSuccessful() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("ConfirmVolumeGroupName_volumeGroupId")).thenReturn(VOLUME_GROUP_ID) - when(mockExecution.getVariable("ConfirmVolumeGroupName_volumeGroupName")).thenReturn(VOLUME_GROUP_NAME) - when(mockExecution.getVariable("ConfirmVolumeGroupName_aicCloudRegion")).thenReturn(AIC_CLOUD_REGION) + @Before + public void init() throws IOException { + super.init("ConfirmVolumeGroupName") + MockitoAnnotations.initMocks(this); + when(confirmVolumeGroupName.getAAIClient()).thenReturn(client) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('namespace_test') - when(mockExecution.getVariable("mso.workflow.ConfirmVolumeGroupName.aai.cloud-region.uri")).thenReturn(AAA_URI) - new ConfirmVolumeGroupName().preProcessRequest(mockExecution) - - verifyInitProcessVariables(mockExecution) - verify(mockExecution).setVariable("CVGN_volumeGroupId", VOLUME_GROUP_ID) - verify(mockExecution).setVariable("CVGN_volumeGroupName", "volumeTestGName") - verify(mockExecution).setVariable("CVGN_aicCloudRegion", AIC_CLOUD_REGION) - verify(mockExecution).setVariable("CVGN_volumeGroupGetEndpoint", - "${AAA_URI}/${AIC_CLOUD_REGION}/volume-groups/volume-group/" + VOLUME_GROUP_ID) - } - - private void verifyInitProcessVariables(ExecutionEntity mockExecution) { - verify(mockExecution).setVariable("prefix", "CVGN_") - verify(mockExecution).setVariable("CVGN_volumeGroupId", null) - verify(mockExecution).setVariable("CVGN_volumeGroupName", null) - verify(mockExecution).setVariable("CVGN_aicCloudRegion", null) - verify(mockExecution).setVariable("CVGN_volumeGroupGetEndpoint", null) - verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", false) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode", null) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse", "") - verify(mockExecution).setVariable("CVGN_ResponseCode", null) - verify(mockExecution).setVariable("RollbackData", null) - } - - @Test - void checkAAIQueryResult_volumeGroupNamesMatch() { - ExecutionEntity mockExecution = setupMock() - commonPartOfCheckAAIQueryTest(mockExecution, VOLUME_GROUP_NAME) - verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", true) - } - - @Test - void checkAAIQueryResult_volumeGroupNamesDoNotMatch() { - ExecutionEntity mockExecution = setupMock() - commonPartOfCheckAAIQueryTest(mockExecution, "grName2") - verify(mockExecution, Mockito.times(0)).setVariable("CVGN_volumeGroupNameMatches", true) - } - - private void commonPartOfCheckAAIQueryTest(ExecutionEntity mockExecution, def volumeGroupName) { - when(mockExecution.getVariable("CVGN_volumeGroupName")).thenReturn(VOLUME_GROUP_NAME) - def xml = "" + volumeGroupName + "" - when(mockExecution.getVariable("CVGN_queryVolumeGroupResponse")).thenReturn(xml) - new ConfirmVolumeGroupName().checkAAIQueryResult(mockExecution) - verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", false) } @Test public void testQueryAAIForVolumeGroupId() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090') - when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn('/aai/test/volume-groups/volume-group/testVolumeGroup') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - mockData() - - ConfirmVolumeGroupName confirmVolumeGroupName = new ConfirmVolumeGroupName() + AAIResourceUri resourceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build()); + when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn(resourceUri) + VolumeGroup volumeGroup = new VolumeGroup() + volumeGroup.setVolumeGroupId("Test") + when(client.get(VolumeGroup.class,resourceUri)).thenReturn(Optional.of(volumeGroup)) confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode",200) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse","") + Mockito.verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode",200) + Mockito.verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse",volumeGroup) } @Test public void testQueryAAIForVolumeGroupId_404() { - - ExecutionEntity mockExecution = setupMock() + AAIResourceUri resourceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build()); + when(client.get(VolumeGroup.class, resourceUri)).thenReturn(Optional.empty()) + DelegateExecution execution = new DelegateExecutionFake() try { - when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn('/aai/test/volume-groups/volume-group/testVolumeGroup') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - - mockData() - - ConfirmVolumeGroupName confirmVolumeGroupName = new ConfirmVolumeGroupName() - confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution) - } - catch(Exception ex){ - + execution.setVariable("CVGN_volumeGroupGetEndpoint", resourceUri) + confirmVolumeGroupName.queryAAIForVolumeGroupId(execution) } - Mockito.verify(mockExecution,times(4)).setVariable(captor.capture(),captor.capture()) - WorkflowException workflowException = captor.getValue() - Assert.assertEquals("AAI GET Failed",workflowException.getErrorMessage()) - Assert.assertEquals(500,workflowException.getErrorCode()) - } - private void mockData() { - stubFor(get(urlMatching("/aai/test/volume-groups/volume-group/testVolumeGroup")) - .willReturn(aResponse() - .withStatus(200))) - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("ConfirmVolumeGroupName") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("ConfirmVolumeGroupName") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("ConfirmVolumeGroupName") - when(mockExecution.getProcessInstanceId()).thenReturn("ConfirmVolumeGroupName") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - return mockExecution + catch(Exception ex){} + Assert.assertEquals(404, execution.getVariable("CVGN_queryVolumeGroupResponseCode")) + Assert.assertEquals("Volume Group not Found!", execution.getVariable("CVGN_queryVolumeGroupResponse")) + } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy deleted file mode 100644 index 879ef7ab4f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.runners.MockitoJUnitRunner - -import static org.mockito.Mockito.times -import static org.mockito.Mockito.when -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutServiceInstance - -/** - * @author sushilma - * @since January 10, 2018 - */ -@RunWith(MockitoJUnitRunner.class) -@Ignore -class CustomE2EPutServiceTest extends MsoGroovyTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Test - public void testPutServiceInstance(){ - ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EPutService','GENPS_') - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') - when(mockExecution.getVariable("GENPS_type")).thenReturn('service-instance') - when(mockExecution.getVariable("GENPS_payload")).thenReturn('') - when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26") - when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET") - when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn( "1234") - MockPutServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", "GenericFlows/getServiceInstance.xml"); - - CustomE2EPutService customE2EPutService = new CustomE2EPutService() - customE2EPutService.putServiceInstance(mockExecution); - Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture()) - Assert.assertEquals(200, captor.getAllValues().get(7)) - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy index c5baf8cc6c..3a408b3310 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -59,7 +59,7 @@ class GenerateVfModuleNameTest { when(mockExecution.getVariable("personaModelId")).thenReturn('personaModelId_test') when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') @@ -78,7 +78,7 @@ class GenerateVfModuleNameTest { when(mockExecution.getVariable("personaModelId")).thenReturn('personaModelId_test') when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy index 01e37f0cd7..3a2673c9ee 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy @@ -26,9 +26,40 @@ import org.camunda.bpm.engine.ProcessEngineServices import org.camunda.bpm.engine.RepositoryService import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Rule +import org.junit.rules.ExpectedException +import org.junit.runner.RunWith +import org.mockito.runners.MockitoJUnitRunner +import org.onap.aai.domain.yang.GenericVnf +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults +@RunWith(MockitoJUnitRunner.class) abstract class MsoGroovyTest { + @Rule + public ExpectedException thrown = ExpectedException.none() + + protected ExecutionEntity mockExecution + protected AAIResourcesClient client + protected AllottedResourceUtils allottedResourceUtils_MOCK + protected final String SEARCH_RESULT_AAI_WITH_RESULTDATA = + FileUtil.readResourceFile("__files/aai/searchResults.json") + protected static final String CLOUD_OWNER = Defaults.CLOUD_OWNER.toString(); + + protected void init(String procName){ + mockExecution = setupMock(procName) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + client = mock(AAIResourcesClient.class) + } + protected ExecutionEntity setupMock(String procName) { ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) when(mockProcessDefinition.getKey()).thenReturn(procName) @@ -64,5 +95,59 @@ abstract class MsoGroovyTest { return mockExecution } + protected Optional getAAIObjectFromJson(Class clazz , String file){ + String json = FileUtil.readResourceFile(file) + AAIResultWrapper resultWrapper = new AAIResultWrapper(json) + return resultWrapper.asBean(clazz) + } + + protected Optional mockAAIGenericVnf(String vnfId){ + return mockAAIGenericVnf(vnfId,"__files/aai/GenericVnf.json") + } + protected Optional mockAAIGenericVnf(String vnfId,String file){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + Optional genericVnf = getAAIObjectFromJson(GenericVnf.class,file); + when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) + return genericVnf + } + + protected Optional mockAAIGenericVnfByName(String vnfName){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + Optional genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnf.json"); + when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) + return genericVnf + } + + protected void mockAAIGenericVnfNotFound(String vnfId){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) + } + + protected void mockAAIGenericVnfByNameNotFound(String vnfName){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) + } + + protected AAIResultWrapper mockVolumeGroupWrapper(String region, String volumeGroupId, String file){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, region,volumeGroupId) + String json = FileUtil.readResourceFile(file) + AAIResultWrapper resultWrapper = new AAIResultWrapper(json) + when(client.get(resourceUri)).thenReturn(resultWrapper) + return resultWrapper + } + + void initAR(String procName){ + init(procName) + allottedResourceUtils_MOCK = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class))) + when(allottedResourceUtils_MOCK.getAAIClient()).thenReturn(client) + } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy index c5b8fab9eb..21441b9b73 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -57,7 +57,6 @@ class PrepareUpdateAAIVfModuleTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') @@ -75,7 +74,7 @@ class PrepareUpdateAAIVfModuleTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') @@ -105,7 +104,7 @@ class PrepareUpdateAAIVfModuleTest { when(mockExecution.getVariable("PUAAIVfMod_vfModule")).thenReturn(vfModule) when(mockExecution.getVariable("PUAAIVfMod_orchestrationStatus")).thenReturn("created") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') @@ -131,7 +130,7 @@ class PrepareUpdateAAIVfModuleTest { when(mockExecution.getVariable("PUAAIVfMod_vfModule")).thenReturn(vfModule) when(mockExecution.getVariable("PUAAIVfMod_orchestrationStatus")).thenReturn("created") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy index e0166f3602..5641c5e12f 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -65,7 +65,7 @@ class UpdateAAIGenericVnfTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') @@ -82,7 +82,7 @@ class UpdateAAIGenericVnfTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') @@ -107,7 +107,7 @@ class UpdateAAIGenericVnfTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") when(mockExecution.getVariable("UAAIGenVnf_getGenericVnfResponse")).thenReturn(getVfModuleResponse) - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') @@ -128,7 +128,7 @@ class UpdateAAIGenericVnfTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") when(mockExecution.getVariable("UAAIGenVnf_getGenericVnfResponse")).thenReturn(getVfModuleResponse) - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy index d2f9095e2d..407ffa2915 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -65,7 +65,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') @@ -84,7 +84,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') @@ -110,7 +110,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') @@ -131,7 +131,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java index 3b41ff8337..38be9f3790 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java @@ -984,31 +984,6 @@ public class StubResponseAAI { .willReturn(aResponse() .withStatus(404))); } - @Deprecated - public static void MockGENPSIPutServiceInstance(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml"))); - } - - @Deprecated - public static void MockGENPSIPutServiceSubscription(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml"))); - } - @Deprecated - public static void MockGENPSIPutServiceInstance_get500(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET")) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/aaiFault.xml"))); - } @Deprecated public static void MockGetGenericVnfById(){ diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 33e1390b9c..e5138b394c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -561,7 +561,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapLocationContext() { CloudRegion expected = new CloudRegion(); - expected.setCloudOwner("att-aic"); + expected.setCloudOwner("test-owner-name"); expected.setLcpCloudRegionId("cloudRegionId"); expected.setComplex("complexName"); expected.setTenantId("tenantId"); @@ -570,11 +570,11 @@ public class BBInputSetupMapperLayerTest { cloudConfig.setLcpCloudRegionId("cloudRegionId"); cloudConfig.setAicNodeClli("aicNodeClli"); org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion(); - cloudRegion.setCloudOwner("att-aic"); + cloudRegion.setCloudOwner("test-owner-name"); cloudRegion.setCloudRegionId("cloudRegionId"); cloudRegion.setComplexName("complexName"); - CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic"); + CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion); assertThat(actual, sameBeanAs(expected)); } @@ -582,7 +582,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapCloudRegion() { CloudRegion expected = new CloudRegion(); - expected.setCloudOwner("att-aic"); + expected.setCloudOwner("test-owner-name"); expected.setLcpCloudRegionId("cloudRegionId"); expected.setTenantId("tenantId"); expected.setCloudRegionVersion("cloudRegionVersion"); @@ -593,11 +593,11 @@ public class BBInputSetupMapperLayerTest { cloudConfig.setAicNodeClli("aicNodeClli"); org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion(); - cloudRegion.setCloudOwner("att-aic"); + cloudRegion.setCloudOwner("test-owner-name"); cloudRegion.setCloudRegionId("cloudRegionId"); cloudRegion.setCloudRegionVersion("cloudRegionVersion"); - CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic"); + CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion); assertThat(actual, sameBeanAs(expected)); } @@ -606,7 +606,7 @@ public class BBInputSetupMapperLayerTest { public void testMapCloudRegionWithNullCheck() { CloudRegion expected = new CloudRegion(); - CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null, null); + CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null); assertThat(actual, sameBeanAs(expected)); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index d0ecedf878..eed4b1411f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -84,6 +84,7 @@ import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.constants.Defaults; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; @@ -317,6 +318,9 @@ public class BBInputSetupTest { RequestInfo requestInfo = new RequestInfo(); requestInfo.setSuppressRollback(true); requestDetails.setRequestInfo(requestInfo); + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + cloudConfiguration.setLcpCloudRegionId("myRegionId"); + requestDetails.setCloudConfiguration(cloudConfiguration); doReturn(requestDetails).when(SPY_bbInputSetupUtils).getRequestDetails(executeBB.getRequestId()); Map lookupKeyMap = new HashMap<>(); String resourceId = "123"; @@ -351,7 +355,7 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId"); doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType); @@ -404,7 +408,7 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId"); doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType); @@ -448,7 +452,7 @@ public class BBInputSetupTest { doReturn(service).when(SPY_bbInputSetupUtils) .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject()); doReturn(owningEntity).when(bbInputSetupMapperLayer) .mapRequestOwningEntity(requestDetails.getOwningEntity()); @@ -497,7 +501,7 @@ public class BBInputSetupTest { .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelVersionAndModelInvariantUUID( requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId()); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject()); doReturn(owningEntity).when(bbInputSetupMapperLayer) .mapRequestOwningEntity(requestDetails.getOwningEntity()); @@ -543,7 +547,7 @@ public class BBInputSetupTest { .getURIKeysFromServiceInstance(resourceId); doReturn(service).when(SPY_bbInputSetupUtils) .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId); doReturn(serviceSubscription).when(SPY_bbInputSetup).getServiceSubscription(requestDetails, customer); @@ -769,7 +773,7 @@ public class BBInputSetupTest { orchestrationContext.setIsRollbackEnabled(false); CloudRegion cloudRegion = new CloudRegion(); - cloudRegion.setCloudOwner("att-aic"); + cloudRegion.setCloudOwner("test-owner-name"); cloudRegion.setLcpCloudRegionId("lcpCloudRegionId"); cloudRegion.setComplex("complexName"); cloudRegion.setTenantId("tenantId"); @@ -792,11 +796,10 @@ public class BBInputSetupTest { doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),uriKeys.get("service-type")); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails); doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails); - doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion, - "att-aic"); + doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -1769,11 +1772,12 @@ public class BBInputSetupTest { new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class); CloudConfiguration cloudConfig = null; org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion(); + aaiCloudRegion.setCloudOwner("test-owner-name"); Resources resources = serviceMacro.getResources(); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class), eq("att-aic")); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class)); CloudRegion expected = new CloudRegion(); expected.setLcpCloudRegionId("mdt1"); - expected.setCloudOwner("att-aic"); + expected.setCloudOwner("test-owner-name"); expected.setTenantId("88a6ca3ee0394ade9403f075db23167e"); CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources); @@ -2124,8 +2128,7 @@ public class BBInputSetupTest { cloudConfig.setLcpCloudRegionId("lcpCloudRegionId"); requestDetails.setCloudConfiguration(cloudConfig); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), - "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB"); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); @@ -2273,14 +2276,13 @@ public class BBInputSetupTest { any(Service.class), any(String.class)); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), - "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("volumeGroupId"); gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup); org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup(); aaiVolumeGroup.setModelCustomizationId("modelCustId"); - doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup("att-aic", + doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(Defaults.CLOUD_OWNER.toString(), cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); executeBB.getBuildingBlock().setBpmnFlowName("UnassignVolumeGroupBB"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index eb74ab804e..e1efe1c9c5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -174,27 +174,25 @@ public class BBInputSetupUtilsTest { @Test public void testGetCloudRegion() { - String cloudOwner = "cloudOwnerId"; CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId("lcpCloudRegionId"); Optional expected = Optional.of(new org.onap.aai.domain.yang.CloudRegion()); - expected.get().setCloudOwner(cloudOwner); + expected.get().setCloudOwner("cloudOwner"); expected.get().setCloudRegionId("lcpCloudRegionId"); doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class, - AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, + AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())); - AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, + AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId()); - bbInputSetupUtils.getCloudRegion(cloudConfig, cloudOwner); + bbInputSetupUtils.getCloudRegion(cloudConfig); verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri); } @Test public void testGetCloudRegionExceptionTest() { - String cloudOwner = "cloudOwnerId"; - + CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId("lcpCloudRegionId"); @@ -203,33 +201,29 @@ public class BBInputSetupUtilsTest { doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class)); - CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig, cloudOwner); + CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig); assertNull(cloudRegion); } @Test public void testGetCloudRegionEmptyId() { - String cloudOwner = "cloudOwnerId"; - CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId(""); RequestDetails requestDetails = new RequestDetails(); requestDetails.setCloudConfiguration(cloudConfig); - CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig, cloudOwner); + CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig); assertNull(cloudRegion); } @Test public void testGetCloudRegionEmptyConfiguration() { - String cloudOwner = "cloudOwnerId"; - RequestDetails requestDetails = new RequestDetails(); - CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration(), cloudOwner); + CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration()); assertNull(cloudRegion); } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json new file mode 100644 index 0000000000..f05449a96f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json @@ -0,0 +1,6 @@ +{ + "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, + "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, + "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, + "licenseInfo" : {"licenseDemands":[]} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json index 4c4c9b3f00..6977224ffa 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json @@ -1,6 +1,6 @@ { "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : [] + "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedModelInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedModelInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedModelInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, + "licenseInfo" : {"licenseDemands":[]} } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json new file mode 100644 index 0000000000..877c6e7e74 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json @@ -0,0 +1,6 @@ +{ + "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, + "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, + "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, + "licenseInfo" : {"licenseDemands":[]} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index 8cd04fdd8e..d3698771bf 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -13,6 +13,7 @@ "is-rollback-enabled": true }, "cloudRegion": { + "lcp-cloud-region-id" : "myRegionId", "cloud-owner": "att-aic" }, "userInput": null, diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index 9b021ae1e7..cf65143c9a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -17,7 +17,7 @@ }, "cloudRegion": { "lcp-cloud-region-id": "lcpCloudRegionId", - "cloud-owner": "att-aic", + "cloud-owner": "test-owner-name", "tenant-id": "tenantId", "complex": "complexName" }, diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json index 3f07e8d526..de20a5a963 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json @@ -49,6 +49,7 @@ }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", + "cloudOwner" : "test-owner-name", "tenantId": "88a6ca3ee0394ade9403f075db23167e" }, "instanceName": "vmxnjr001_AVPN_base_vRE_BV_expansion_001", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json index 4c29f96361..c4ad0ac047 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json @@ -24,6 +24,7 @@ }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", + "cloudOwner" : "test-owner-name", "tenantId": "88a6ca3ee0394ade9403f075db23167e" }, "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml deleted file mode 100644 index e2db499929..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - 9a7b327d9-287aa00-82c4b0-105757 - fqdn123 - slowburn - 145878989 - - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml deleted file mode 100644 index 2126ae7464..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - skask - lukewarm - pdk1 - 78987 - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml deleted file mode 100644 index 5232e530e9..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - DEV-VF-0011 - UPDATE_VF_MODULE - PORTAL - - - skask - supercool - pcrf-capacity - PCRF::module-0 - - serviceIdUUID - MDTWNJ21 - fba1bd1e195a404cacb9ce17a9b2b421 - 78987 - introvert - 3.14 - myhost.appl.edu - introvert - 3.14 - - - VLAN-OAM-1323 - slcp34246vbc246ceb - 970cd2b9-7f09-4a12-af47-182ea38ba1f0 - 545cc2c3-1930-4100-b534-5d82d0e12bb6 - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml deleted file mode 100644 index c86a4aaa73..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml +++ /dev/null @@ -1,38 +0,0 @@ - - skask - STMTN5MMSC20 - pcrf-capacity - SDN-MOBILITY - vPCRF - pending-create - false - false - introvert - 2.0 - 0000020 - - - lukewarm - PCRF::module-0-0 - introvert - 2.0 - true - fastburn - pending-create - 0000074 - - - supercool - PCRF::module-1-0 - extrovert - 2.0 - false - slowburn - pending-create - 0000075 - - - - - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml deleted file mode 100644 index 65f235cf4b..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - skask - supercool - pending-delete - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml deleted file mode 100644 index f40b6bc991..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - 9a7b327d9-287aa00-82c4b0-105757 - GN_EVPN_Test - 195159195 - 14567890 - - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml deleted file mode 100644 index 4cab6c6615..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml deleted file mode 100644 index 7d3d0e54d1..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml deleted file mode 100644 index 7d3d0e54d1..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml deleted file mode 100644 index dbd55b0cf4..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - bd1b3789-6474-4935-94b2-90b656e035d0 - - bd1b3789-6474-4935-94b2-90b656e035d0 - - 9ddf628a-9eca-430e-8974-22d520a31be1 - assign - https://localhost:8443/adapters/rest/SDNCNotify - - - notsurewecare - bd1b3789-6474-4935-94b2-90b656e035d0 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - - PendingCreate - - - VNN1CA52LCP - ZVNNMOGX01_base - afd0f02a-1ddb-43bb-aded-5113e46e82ae - ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 - ZVNN1MOGX01 - 33d209df14ac4c08ad60747185d2f3e0 - bd1b3789-6474-4935-94b2-90b656e035d0 - ZVNN1MOGX01 - VF AUG 1::module-0 - - - - - mog_exn - 03dbd833-785c-40c0-bf32-37594b5334bc - MNS-25180-P-VNNYCA01_exn_protected_net_1 - - - 6f82d234-41a4-48e9-a9e8-415667a72929 - - filter1 - - - filter2 - - - - mog_oam - 3f181cde-9380-4c20-9d3a-e1a4ee74f994 - MNS-25180-P-VNNYCA01_oam_protected_net_1 - - - 713b6770-13fa-4949-8dbb-a1288c5e5932 - - - mog_cor_B - 821a550a-3f50-4725-995b-f212d5caec7c - MNS-25180-P-VNNYCA01_cor_direct_net_1 - - - 18926e56-12b6-4a4d-98b6-37e0c05626ee - - - mog_cor_A - 3dabf5c0-cffb-420c-8960-8499c74eb25f - MNS-25180-P-VNNYCA01_cor_direct_net_2 - - - 35530b29-a4de-48ff-a014-111110ccc652 - - - mog_gn - 3ce97321-6e7f-49af-bd12-f833e377c310 - MNS-25180-P-VNNYCA01_gn_direct_net_1 - - - 32bfdd2c-28e1-4895-87a6-373bf12c3129 - - - mog_dmz - d43ca910-02a5-47dc-8510-100a68a3c9e0 - MNS-25180-P-VNNYCA01_dmz_protected_net_1 - - - cb9500fb-943f-412e-aea6-458711564a75 - - - nova - - - ps - - ZVNN1MOGX01MPS001 - - - ZVNN1MOGX01MPS002 - - - ZVNN1MOGX01MPS003 - - - ZVNN1MOGX01MPS004 - - 4 - - mog_cor_B - - 107.224.36.251 - - - 107.224.36.252 - - - 107.224.36.253 - - - 107.224.36.254 - - N - - - - cm - - ZVNN1MOGX01MCM001 - - - ZVNN1MOGX01OAM002 - - 1 - - mog_cor_B - - 107.224.36.249 - - - 107.224.36.250 - - N - - - mog_oam - - 107.239.167.250 - - - 107.239.167.251 - - N - - - - oam - - ZVNN1MOGX01OAM001 - - - ZVNN1MOGX01OAM002 - - 2 - - mog_oam - - 107.239.167.252 - - - 107.239.167.251 - - N - - - mog_cor_B - - 107.224.36.249 - - - 107.224.36.250 - - N - - - - pd - - ZVNN1MOGX01MPD001 - - - ZVNN1MOGX01MPD002 - - 2 - - mog_dmz - - 107.225.25.253 - - - 107.225.25.254 - - N - 107.225.254.253 - - - mog_oam - - 107.239.167.254 - - - 107.239.167.253 - - N - 107.239.167.249 - - - mog_exn - - 107.224.46.253 - - - 107.224.46.254 - - N - 107.224.46.252 - - - mog_cor_B - - 107.224.36.247 - - - 107.224.36.248 - - N - 107.224.41.252 - - - mog_gn - - 107.224.41.253 - - - 107.224.41.254 - - N - 107.224.41.252 - - - mog_cor_A - - 107.224.38.253 - - - 107.224.38.254 - - N - - - - sm - - ZVNN1MOGX01MSM001 - - - ZVNN1MOGX01MSM002 - - - ZVNN1MOGX01MSM003 - - - ZVNN1MOGX01MSM004 - - 4 - - mog_cor_B - - 107.224.36.243 - - - 107.224.36.244 - - - 107.224.36.245 - - - 107.224.36.246 - - N - - - - - ZVNNMOGX01_base - SDN-MOBILITY - ZVNN1MOGX01 - VF AUG 1::module-0 - ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 - ZVNN1MOGX01 - - - - 9ddf628a-9eca-430e-8974-22d520a31be1 - - PORTAL - VNFActivateRequest - - - - 200 - Y - synccomplete - 2016-08-05T16:15:19.398Z - vnf-topology-operation - VNFActivateRequest - assign - - - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml deleted file mode 100644 index e8a69da0f8..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - 28455973-1ee5-4ad1-8d35-c4732679743a - - 200 - Y - synccomplete - 2016-06-08T19:44:59.138Z - vnf-topology-operation - VNFActivateRequest - assign - - - 28455973-1ee5-4ad1-8d35-c4732679743 - - notsurewecare - 28455973-1ee5-4ad1-8d35-c4732679743a - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - - 5e168556-a5c6-4813-bff3-cc03007afbbc - http://localhost:28080/adapters/rest/SDNCNotify - assign - - - AAIAIC25 - MSOTEST06-vSAMP3::base::module-0 - 91ad7ab0-9ffd-471d-971c-3eb913a2cc75 - Test/vSAMP3 1 - MSOTEST06 - 4ae1d3446a4c48b2bec44b6cfba06d68 - 28455973-1ee5-4ad1-8d35-c4732679743a - vSAMP3::base::module-0 - - - PendingCreate - - - - image - Ubuntu_Perf - - - flavor - m1.small - - - - int_imbl - 680b7453-0ec4-4d96-b355-280d981d418f - Nimbus-25193-T-Willows2_int_imbl_net_1 - default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_int_imbl_net_1 - - 775607fb-e16a-45ef-94a7-82fba0d16eec - 640d07fb-e16a-45ef-94a7-82fba0d169bf - - filter1 - - - filter2 - - - - sgi_protected - f9039ce9-e3cf-4716-b2d1-ec7912178ea4 - Nimbus-25193-T-Willows2_sgi_protected_net_1 - default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_sgi_protected_net_1 - b9999ce9-e3cf-4716-b2d1-ec791217678c - - bf11bba8-b971-4ab5-8281-215b3fedcd3c - - - cm - - ZVNN1MOGX01MCM001 - - - ZVNN1MOGX01OAM002 - - 1 - - mog_cor_B - - 107.224.36.249 - - - 107.224.36.250 - - - 2606:ae00:2e01:800::67 - - N - 107.224.41.252 - 2001:1890:1001:2B32::29:C - - - mog_oam - - 107.239.167.250 - - - 107.239.167.251 - - - aa::aa::aa::aa::aa::aa - - - bb::bb::bb::bb::bb::bb - - - 1.2.3.4/26 - - - 2002::/64 - - N - 1111:1890:1001:2B32::29:D - - - - nova - - - - MSOTEST06-vSAMP3::base::module-0 - SDN-MOBILITY - vSAMP3::base::module-0 - Test/vSAMP3 1 - MSOTEST06 - - - - 5e168556-a5c6-4813-bff3-cc03007afbbc - - SoapUI-bns-vf-base-vSAMP3-9001 - VNFActivateRequest - - - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml deleted file mode 100644 index 77528ccf61..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml deleted file mode 100644 index 3e7c6503f4..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - skask - introvert - 3.14 - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml deleted file mode 100644 index 8a690403c4..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml +++ /dev/null @@ -1,10 +0,0 @@ - - skask - supercool - slowburn - complete - 78987 - introvert - 3.14 - myhost.appl.com - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml deleted file mode 100644 index 0dc1b1d410..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - DEV-VF-0011 - UPDATE_VF_MODULE - PORTAL - - - skask - supercool - pcrf-capacity - PCRF::module-0 - - serviceIdUUID - MDTWNJ21 - fba1bd1e195a404cacb9ce17a9b2b421 - 78987 - introvert - 3.14 - myhost.appl.edu - introvert - 3.14 - - - VLAN-OAM-1323 - slcp34246vbc246ceb - 970cd2b9-7f09-4a12-af47-182ea38ba1f0 - 545cc2c3-1930-4100-b534-5d82d0e12bb6 - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml deleted file mode 100644 index 49ecd0bf3f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml +++ /dev/null @@ -1,55 +0,0 @@ - - skask - supercool - slowburn - true - - - key1 - value1 - - - key2 - value2 - - -server1_private_ip -192.168.28.3 - - -contrail-service-instance-fqdn -default-domain:MSOTest:MsoNW-RA - - -policyKey1_contrail_network_policy_fqdn -MSOTest:DefaultPolicyFQDN1 - - -policyKey2_contrail_network_policy_fqdn -MSOTest:DefaultPolicyFQDN2 - - -oam_management_v6_address -2000:abc:bce:1111 - - -oam_management_v4_address -127.0.0.1 - - - - skask - supercool - slowburn - true - tenantId - cloudSiteId - - requestId - serviceInstanceId - - {{MESSAGE-ID}} - - {{MESSAGE-ID}} - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml deleted file mode 100644 index c602dd9667..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml +++ /dev/null @@ -1,16 +0,0 @@ - - skask - supercool - slowburn - - - key1 - value1 - - - key2 - value2 - - - {{MESSAGE-ID}} - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml deleted file mode 100644 index 830d2e2237..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml +++ /dev/null @@ -1,15 +0,0 @@ - - 78987 - slowburn - - - key1 - value1 - - - key2 - value2 - - - {{MESSAGE-ID}} - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml deleted file mode 100644 index b882c4c6f4..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml +++ /dev/null @@ -1,10 +0,0 @@ - - lukewarm - PCRF::module-1 - slowburn - pending-create - true - 330-90 - introvert - 2.0 - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml deleted file mode 100644 index 3b8bea4e4e..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml +++ /dev/null @@ -1,9 +0,0 @@ - - b37d96db-7d2c-47ce-bf61-a6c7b82fe161 - PCRF::module-0-2 - 00000000-0000-0000-0000-000000000000 - 1.0 - false - pending-create - 330-90 - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml deleted file mode 100644 index 5a2b7300b1..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ /dev/null @@ -1,27 +0,0 @@ - - supercool - PCRF::module-2 - fastburn - pending-create - false - 330-89 - introvert - 2.0 - - - volume-group - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - pdk1 - - - volume-group.volume-group-id - 78987 - - - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml deleted file mode 100644 index 7e913dd418..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml +++ /dev/null @@ -1,25 +0,0 @@ - - 78987 - Volume_2 - slowburn - pcrf-capacity - Active - 0000020 - - - tenant - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - MDTWNJ21 - - - tenant.tenant-id - fba1bd1e195a404cacb9ce17a9b2b421 - - - - \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index 236d435cb7..dea3f17f8e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@ -115,30 +115,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: diff --git a/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java b/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java index fc6266d917..c9dd6303bc 100644 --- a/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java +++ b/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java @@ -350,15 +350,6 @@ public class RESTClient { return this; } - /** - * Alias for httpGet(). - * - * @see RESTClient#httpGet() - */ - public APIResponse get() throws RESTException { - return httpGet(); - } - /** * Sends an http GET request using the parameters and headers previously * set. diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java index 17ede2f2ff..a79f0aa536 100644 --- a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java @@ -7,9 +7,9 @@ * 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. @@ -49,11 +49,11 @@ public class RESTClientTest { private JSONObject jsonResponse; private String jsonObjectAsString; private String jsonResponseAsString; - + @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + + @Before public void before() throws Exception { jsonPayload = new JSONObject(); @@ -62,135 +62,123 @@ public class RESTClientTest { jsonObjectAsString = jsonPayload.toString(); jsonResponse = new JSONObject(); jsonResponse.put("response", "responseValue"); - jsonResponseAsString = jsonResponse.toString(); + jsonResponseAsString = jsonResponse.toString(); restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example", "localhost", wireMockRule.port()); - } - + } + @Test public void testHeadersParameters() throws Exception { restClient.setHeader("name", "value"); restClient.setParameter("name", "value"); - assertEquals("[value]", restClient.getParameters().get("name").toString()); + assertEquals("[value]", restClient.getParameters().get("name").toString()); assertEquals("[value]", restClient.getHeaders().get("name").toString()); restClient.setHeader("name", "value2"); assertEquals("[value2]", restClient.getHeaders().get("name").toString()); restClient.setParameter("name", "value2"); assertEquals("[value2]", restClient.getParameters().get("name").toString()); - restClient.addParameter("name", "value"); + restClient.addParameter("name", "value"); assertEquals(1, restClient.getParameters().size()); - restClient.addAuthorizationHeader("token"); - assertEquals("[token]", restClient.getHeaders().get("Authorization").toString()); + restClient.addAuthorizationHeader("token"); + assertEquals("[token]", restClient.getHeaders().get("Authorization").toString()); assertEquals("http://localhost:" + wireMockRule.port() + "/example", restClient.getURL()); restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example1"); assertEquals("http://localhost:" + wireMockRule.port() + "/example1", restClient.getURL()); } - + @Test public void testHttpPost() throws Exception { RESTClient restClientMock = mock(RESTClient.class); restClientMock = spy(restClient); wireMockRule.stubFor(post(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClientMock.httpPost(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); verify(restClientMock, times(2)).getURL(); - } - + } + @Test public void testPost() throws Exception { wireMockRule.stubFor(post(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.post(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpPut() throws Exception { wireMockRule.stubFor(put(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); restClient.setParameter("name", "value"); APIResponse apiResponse = restClient.httpPut(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - - } - + + } + @Test public void testHttpPatch() throws Exception { wireMockRule.stubFor(patch(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpPatch(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } + } @Test public void testPatch_withParameter() throws Exception { wireMockRule.stubFor(patch(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); restClient.setParameter("name", "value"); APIResponse apiResponse = restClient.patch(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpDelete_withPayload() throws Exception { wireMockRule.stubFor(delete(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpDelete(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpDelete() throws Exception { wireMockRule.stubFor(delete(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpDelete(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testDelete() throws Exception { wireMockRule.stubFor(delete(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.delete(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpGet() throws Exception { wireMockRule.stubFor(get(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpGet(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - - @Test - public void testGet_withParameter() throws Exception { - wireMockRule.stubFor(get(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); - restClient.setParameter("name", "value"); - restClient.setParameter("type", "valueType"); - APIResponse apiResponse = restClient.get(); - assertEquals(200, apiResponse.getStatusCode()); - assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); - assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java deleted file mode 100644 index 10c0640b17..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVceByNameWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_500; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByNameWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVceById; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; - -/** - * Please describe the GenericGetVnfTest.java class - * - */ - -public class GenericGetVnfIT extends BaseIntegrationTest { - - @Test - - public void testGenericGetVnf_success_genericVnf() throws Exception{ - MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml"); - - Map variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - - public void testGenericGetVnf_success_vce() throws Exception{ - MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml"); - - Map variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "vce"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - - public void testGenericGetVnf_success_genericVnfByName() throws Exception{ - MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml"); - - Map variables = new HashMap<>(); - setVariables(variables, "", "testVnfName123", "generic-vnf"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - - public void testGenericGetVnf_success_vceByName() throws Exception{ - MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml"); - - Map variables = new HashMap<>(); - setVariables(variables, null, "testVnfName123", "vce"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - - - @Test - public void testGenericGetVnf_error_genericVnf500() throws Exception{ - - MockGetGenericVnfById_500("testVnfId123_500"); - - Map variables = new HashMap<>(); - setVariables(variables, "testVnfId123_500", "testVnfId123_500", "generic-vnf"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetVnf,errorCode=500,errorMessage=Received a bad response from AAI,workStep=*]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", byName); - - assertEquals(expectedWorkflowException, workflowException); - } - - private void setVariables(Map variables, String vnfId, String vnfName, String type) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGV_vnfId", vnfId); - variables.put("GENGV_vnfName",vnfName); - variables.put("GENGV_type", type); - variables.put("mso-request-id", UUID.randomUUID().toString()); - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..e2db499929 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + fqdn123 + slowburn + 145878989 + + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml new file mode 100644 index 0000000000..747d424f9c --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml @@ -0,0 +1,7 @@ + + skask + lukewarm + pdk1 + test-owner + 78987 + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml new file mode 100644 index 0000000000..5232e530e9 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml @@ -0,0 +1,29 @@ + + + DEV-VF-0011 + UPDATE_VF_MODULE + PORTAL + + + skask + supercool + pcrf-capacity + PCRF::module-0 + + serviceIdUUID + MDTWNJ21 + fba1bd1e195a404cacb9ce17a9b2b421 + 78987 + introvert + 3.14 + myhost.appl.edu + introvert + 3.14 + + + VLAN-OAM-1323 + slcp34246vbc246ceb + 970cd2b9-7f09-4a12-af47-182ea38ba1f0 + 545cc2c3-1930-4100-b534-5d82d0e12bb6 + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/GenericVnf.xml new file mode 100644 index 0000000000..c86a4aaa73 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/GenericVnf.xml @@ -0,0 +1,38 @@ + + skask + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + pending-create + false + false + introvert + 2.0 + 0000020 + + + lukewarm + PCRF::module-0-0 + introvert + 2.0 + true + fastburn + pending-create + 0000074 + + + supercool + PCRF::module-1-0 + extrovert + 2.0 + false + slowburn + pending-create + 0000075 + + + + + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml new file mode 100644 index 0000000000..65f235cf4b --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml @@ -0,0 +1,5 @@ + + skask + supercool + pending-delete + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..f40b6bc991 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 195159195 + 14567890 + + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml new file mode 100644 index 0000000000..4cab6c6615 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml new file mode 100644 index 0000000000..7d3d0e54d1 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml new file mode 100644 index 0000000000..7d3d0e54d1 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..dbd55b0cf4 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml @@ -0,0 +1,315 @@ + + + bd1b3789-6474-4935-94b2-90b656e035d0 + + bd1b3789-6474-4935-94b2-90b656e035d0 + + 9ddf628a-9eca-430e-8974-22d520a31be1 + assign + https://localhost:8443/adapters/rest/SDNCNotify + + + notsurewecare + bd1b3789-6474-4935-94b2-90b656e035d0 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + PendingCreate + + + VNN1CA52LCP + ZVNNMOGX01_base + afd0f02a-1ddb-43bb-aded-5113e46e82ae + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + 33d209df14ac4c08ad60747185d2f3e0 + bd1b3789-6474-4935-94b2-90b656e035d0 + ZVNN1MOGX01 - VF AUG 1::module-0 + + + + + mog_exn + 03dbd833-785c-40c0-bf32-37594b5334bc + MNS-25180-P-VNNYCA01_exn_protected_net_1 + + + 6f82d234-41a4-48e9-a9e8-415667a72929 + + filter1 + + + filter2 + + + + mog_oam + 3f181cde-9380-4c20-9d3a-e1a4ee74f994 + MNS-25180-P-VNNYCA01_oam_protected_net_1 + + + 713b6770-13fa-4949-8dbb-a1288c5e5932 + + + mog_cor_B + 821a550a-3f50-4725-995b-f212d5caec7c + MNS-25180-P-VNNYCA01_cor_direct_net_1 + + + 18926e56-12b6-4a4d-98b6-37e0c05626ee + + + mog_cor_A + 3dabf5c0-cffb-420c-8960-8499c74eb25f + MNS-25180-P-VNNYCA01_cor_direct_net_2 + + + 35530b29-a4de-48ff-a014-111110ccc652 + + + mog_gn + 3ce97321-6e7f-49af-bd12-f833e377c310 + MNS-25180-P-VNNYCA01_gn_direct_net_1 + + + 32bfdd2c-28e1-4895-87a6-373bf12c3129 + + + mog_dmz + d43ca910-02a5-47dc-8510-100a68a3c9e0 + MNS-25180-P-VNNYCA01_dmz_protected_net_1 + + + cb9500fb-943f-412e-aea6-458711564a75 + + + nova + + + ps + + ZVNN1MOGX01MPS001 + + + ZVNN1MOGX01MPS002 + + + ZVNN1MOGX01MPS003 + + + ZVNN1MOGX01MPS004 + + 4 + + mog_cor_B + + 107.224.36.251 + + + 107.224.36.252 + + + 107.224.36.253 + + + 107.224.36.254 + + N + + + + cm + + ZVNN1MOGX01MCM001 + + + ZVNN1MOGX01OAM002 + + 1 + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + N + + + mog_oam + + 107.239.167.250 + + + 107.239.167.251 + + N + + + + oam + + ZVNN1MOGX01OAM001 + + + ZVNN1MOGX01OAM002 + + 2 + + mog_oam + + 107.239.167.252 + + + 107.239.167.251 + + N + + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + N + + + + pd + + ZVNN1MOGX01MPD001 + + + ZVNN1MOGX01MPD002 + + 2 + + mog_dmz + + 107.225.25.253 + + + 107.225.25.254 + + N + 107.225.254.253 + + + mog_oam + + 107.239.167.254 + + + 107.239.167.253 + + N + 107.239.167.249 + + + mog_exn + + 107.224.46.253 + + + 107.224.46.254 + + N + 107.224.46.252 + + + mog_cor_B + + 107.224.36.247 + + + 107.224.36.248 + + N + 107.224.41.252 + + + mog_gn + + 107.224.41.253 + + + 107.224.41.254 + + N + 107.224.41.252 + + + mog_cor_A + + 107.224.38.253 + + + 107.224.38.254 + + N + + + + sm + + ZVNN1MOGX01MSM001 + + + ZVNN1MOGX01MSM002 + + + ZVNN1MOGX01MSM003 + + + ZVNN1MOGX01MSM004 + + 4 + + mog_cor_B + + 107.224.36.243 + + + 107.224.36.244 + + + 107.224.36.245 + + + 107.224.36.246 + + N + + + + + ZVNNMOGX01_base + SDN-MOBILITY + ZVNN1MOGX01 - VF AUG 1::module-0 + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + + + + 9ddf628a-9eca-430e-8974-22d520a31be1 + + PORTAL + VNFActivateRequest + + + + 200 + Y + synccomplete + 2016-08-05T16:15:19.398Z + vnf-topology-operation + VNFActivateRequest + assign + + + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml new file mode 100644 index 0000000000..e8a69da0f8 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml @@ -0,0 +1,141 @@ + + + 28455973-1ee5-4ad1-8d35-c4732679743a + + 200 + Y + synccomplete + 2016-06-08T19:44:59.138Z + vnf-topology-operation + VNFActivateRequest + assign + + + 28455973-1ee5-4ad1-8d35-c4732679743 + + notsurewecare + 28455973-1ee5-4ad1-8d35-c4732679743a + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + 5e168556-a5c6-4813-bff3-cc03007afbbc + http://localhost:28080/adapters/rest/SDNCNotify + assign + + + AAIAIC25 + MSOTEST06-vSAMP3::base::module-0 + 91ad7ab0-9ffd-471d-971c-3eb913a2cc75 + Test/vSAMP3 1 + MSOTEST06 + 4ae1d3446a4c48b2bec44b6cfba06d68 + 28455973-1ee5-4ad1-8d35-c4732679743a + vSAMP3::base::module-0 + + + PendingCreate + + + + image + Ubuntu_Perf + + + flavor + m1.small + + + + int_imbl + 680b7453-0ec4-4d96-b355-280d981d418f + Nimbus-25193-T-Willows2_int_imbl_net_1 + default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_int_imbl_net_1 + + 775607fb-e16a-45ef-94a7-82fba0d16eec + 640d07fb-e16a-45ef-94a7-82fba0d169bf + + filter1 + + + filter2 + + + + sgi_protected + f9039ce9-e3cf-4716-b2d1-ec7912178ea4 + Nimbus-25193-T-Willows2_sgi_protected_net_1 + default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_sgi_protected_net_1 + b9999ce9-e3cf-4716-b2d1-ec791217678c + + bf11bba8-b971-4ab5-8281-215b3fedcd3c + + + cm + + ZVNN1MOGX01MCM001 + + + ZVNN1MOGX01OAM002 + + 1 + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + + 2606:ae00:2e01:800::67 + + N + 107.224.41.252 + 2001:1890:1001:2B32::29:C + + + mog_oam + + 107.239.167.250 + + + 107.239.167.251 + + + aa::aa::aa::aa::aa::aa + + + bb::bb::bb::bb::bb::bb + + + 1.2.3.4/26 + + + 2002::/64 + + N + 1111:1890:1001:2B32::29:D + + + + nova + + + + MSOTEST06-vSAMP3::base::module-0 + SDN-MOBILITY + vSAMP3::base::module-0 + Test/vSAMP3 1 + MSOTEST06 + + + + 5e168556-a5c6-4813-bff3-cc03007afbbc + + SoapUI-bns-vf-base-vSAMP3-9001 + VNFActivateRequest + + + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml new file mode 100644 index 0000000000..77528ccf61 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml new file mode 100644 index 0000000000..3e7c6503f4 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml @@ -0,0 +1,5 @@ + + skask + introvert + 3.14 + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml new file mode 100644 index 0000000000..8a690403c4 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml @@ -0,0 +1,10 @@ + + skask + supercool + slowburn + complete + 78987 + introvert + 3.14 + myhost.appl.com + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml new file mode 100644 index 0000000000..0dc1b1d410 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml @@ -0,0 +1,35 @@ + + + DEV-VF-0011 + UPDATE_VF_MODULE + PORTAL + + + skask + supercool + pcrf-capacity + PCRF::module-0 + + serviceIdUUID + MDTWNJ21 + fba1bd1e195a404cacb9ce17a9b2b421 + 78987 + introvert + 3.14 + myhost.appl.edu + introvert + 3.14 + + + VLAN-OAM-1323 + slcp34246vbc246ceb + 970cd2b9-7f09-4a12-af47-182ea38ba1f0 + 545cc2c3-1930-4100-b534-5d82d0e12bb6 + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml new file mode 100644 index 0000000000..49ecd0bf3f --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml @@ -0,0 +1,55 @@ + + skask + supercool + slowburn + true + + + key1 + value1 + + + key2 + value2 + + +server1_private_ip +192.168.28.3 + + +contrail-service-instance-fqdn +default-domain:MSOTest:MsoNW-RA + + +policyKey1_contrail_network_policy_fqdn +MSOTest:DefaultPolicyFQDN1 + + +policyKey2_contrail_network_policy_fqdn +MSOTest:DefaultPolicyFQDN2 + + +oam_management_v6_address +2000:abc:bce:1111 + + +oam_management_v4_address +127.0.0.1 + + + + skask + supercool + slowburn + true + tenantId + cloudSiteId + + requestId + serviceInstanceId + + {{MESSAGE-ID}} + + {{MESSAGE-ID}} + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml new file mode 100644 index 0000000000..c602dd9667 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml @@ -0,0 +1,16 @@ + + skask + supercool + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml new file mode 100644 index 0000000000..830d2e2237 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml @@ -0,0 +1,15 @@ + + 78987 + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml new file mode 100644 index 0000000000..b882c4c6f4 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml @@ -0,0 +1,10 @@ + + lukewarm + PCRF::module-1 + slowburn + pending-create + true + 330-90 + introvert + 2.0 + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-new.xml new file mode 100644 index 0000000000..3b8bea4e4e --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-new.xml @@ -0,0 +1,9 @@ + + b37d96db-7d2c-47ce-bf61-a6c7b82fe161 + PCRF::module-0-2 + 00000000-0000-0000-0000-000000000000 + 1.0 + false + pending-create + 330-90 + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-supercool.xml new file mode 100644 index 0000000000..5a2b7300b1 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -0,0 +1,27 @@ + + supercool + PCRF::module-2 + fastburn + pending-create + false + 330-89 + introvert + 2.0 + + + volume-group + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + pdk1 + + + volume-group.volume-group-id + 78987 + + + + \ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VolumeGroup.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VolumeGroup.xml new file mode 100644 index 0000000000..7e913dd418 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VolumeGroup.xml @@ -0,0 +1,25 @@ + + 78987 + Volume_2 + slowburn + pcrf-capacity + Active + 0000020 + + + tenant + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + MDTWNJ21 + + + tenant.tenant-id + fba1bd1e195a404cacb9ce17a9b2b421 + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java index 2bec24e44b..62727b912e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java @@ -73,17 +73,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; @ContextConfiguration @AutoConfigureWireMock(port = 0) public abstract class BaseTest extends BuildingBlockTestDataSetup { - + protected Map variables = new HashMap<>(); protected TestRestTemplate restTemplate = new TestRestTemplate(); protected HttpHeaders headers = new HttpHeaders(); - - @Value("${wiremock.server.port") + + @Value("${wiremock.server.port}") protected String wireMockPort; - + @Autowired protected RuntimeService runtimeService; @@ -92,13 +92,13 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { /* * Mocked for injection via autowiring */ - + @Value("${mso.catalog.db.spring.endpoint}") protected String endpoint; - + @MockBean protected CatalogDbClient MOCK_catalogDbClient; - + @SpyBean protected InjectionHelper MOCK_injectionHelper; @@ -111,21 +111,20 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { protected NetworkAdapterClientImpl MOCK_networkAdapterClient; @SpyBean protected SDNCClient MOCK_sdncClient; - + @SpyBean protected AAIFlagTasks aaiFlagTasks; - + @SpyBean protected AAIVnfResources aaiVnfResources; - + @SpyBean protected ExceptionBuilder exceptionUtil; - + @SpyBean protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources; - - + @@ -138,8 +137,8 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { */ - - + + @SpyBean protected BBInputSetupMapperLayer SPY_bbInputSetupMapperLayer; @SpyBean @@ -148,38 +147,38 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { protected BBInputSetup SPY_bbInputSetup; @SpyBean protected SniroHomingV2 sniroHoming; - + @SpyBean protected SniroClient sniroClient; - + @SpyBean - protected SDNOHealthCheckTasks sdnoHealthCheckTasks; - + protected SDNOHealthCheckTasks sdnoHealthCheckTasks; + /* * Mocked for injection via the IntectionHelper */ - - + + @Before public void baseTestBefore() { variables.put("gBuildingBlockExecution", new DelegateExecutionImpl(new HashMap<>())); - - + + } @LocalServerPort private int port; - + protected String readFile(String path) throws IOException { return readFile(path, Charset.defaultCharset()); } - + protected String readFile(String path, Charset encoding) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return new String(encoded, encoding); } - + protected String readJsonFileAsString(String fileLocation) throws IOException{ ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(new File(fileLocation)); @@ -205,5 +204,5 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { .camundaClass(MockLoggerDelegate.class.getName()).endEvent().name("End Point").done(); repositoryService.createDeployment().addModelInstance(fileName + ".bpmn", modelInstance).deploy(); } - + } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java index 9e6cfdb686..22f85b4794 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java @@ -7,9 +7,9 @@ * 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. @@ -88,20 +88,20 @@ public class BuildingBlockTestDataSetup{ private int volumeGroupCounter; private int vpnBindingCounter; private int vpnBondingLinkCounter; - + protected BuildingBlockExecution execution; - + protected GeneralBuildingBlock gBBInput; - + protected HashMap lookupKeyMap; - + protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB(); - + @Rule public ExpectedException expectedException = ExpectedException.none(); - + protected DelegateExecution delegateExecution; - + @Before public void buildingBlockTestDataSetupBefore() { collectionCounter = 0; @@ -120,183 +120,183 @@ public class BuildingBlockTestDataSetup{ volumeGroupCounter = 0; vpnBindingCounter = 0; vpnBondingLinkCounter = 0; - + execution = new DelegateExecutionImpl(new ExecutionImpl()); execution.setVariable("testProcessKey", "testProcessKeyValue"); - + gBBInput = new GeneralBuildingBlock(); execution.setVariable("gBBInput", gBBInput); - + lookupKeyMap = new HashMap(); execution.setVariable("lookupKeyMap", lookupKeyMap); - + ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class); doReturn("test").when(mockExecutionImpl).getProcessInstanceId(); - + ExecutionImpl executionImpl = new ExecutionImpl(); executionImpl.setProcessInstance(mockExecutionImpl); - + delegateExecution = (DelegateExecution) executionImpl; delegateExecution.setVariable("testProcessKey", "testProcessKeyValue"); } - + public Map buildUserInput() { Map userInput = new HashMap<>(); userInput.put("testUserInputKey", "testUserInputValue"); - + return userInput; } - + public Map setUserInput() { Map userInput = buildUserInput(); - + gBBInput.setUserInput(userInput); - + return userInput; } - + public RequestContext buildRequestContext() { RequestContext requestContext = new RequestContext(); requestContext.setMsoRequestId(UUID.randomUUID().toString()); requestContext.setProductFamilyId("testProductFamilyId"); requestContext.setRequestorId("testRequestorId"); - + requestContext.setUserParams(new HashMap<>()); - + Map dataMap = new HashMap<>(); dataMap.put("vpnId","testVpnId"); dataMap.put("vpnRegion","testVpnRegion"); dataMap.put("vpnRt","testVpnRt"); dataMap.put("vpnName","vpnName"); dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"})); - + HashMap userParams = new HashMap<>(); userParams.put("vpnData",dataMap); - + List> userParamsList = new ArrayList<>(); userParamsList.add(userParams); - + RequestParameters requestParameters = new RequestParameters(); requestParameters.setUserParams(userParamsList); requestContext.setRequestParameters(requestParameters); - + return requestContext; } - + public RequestContext setRequestContext() { RequestContext requestContext = buildRequestContext(); - + gBBInput.setRequestContext(requestContext); - + return requestContext; } - + public CloudRegion buildCloudRegion() { CloudRegion cloudRegion = new CloudRegion(); cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId"); cloudRegion.setTenantId("testTenantId"); cloudRegion.setCloudOwner("testCloudOwner"); - + return cloudRegion; } - + public CloudRegion setCloudRegion() { CloudRegion cloudRegion = buildCloudRegion(); - + gBBInput.setCloudRegion(cloudRegion); - + return cloudRegion; } - + public OrchestrationContext buildOrchestrationContext() { OrchestrationContext orchestrationContext = new OrchestrationContext(); - + return orchestrationContext; } - + public OrchestrationContext setOrchestrationContext() { OrchestrationContext orchestrationContext = buildOrchestrationContext(); - + gBBInput.setOrchContext(orchestrationContext); - + return orchestrationContext; } - + public Collection buildCollection() { collectionCounter++; - + Collection collection = new Collection(); collection.setId("testId" + collectionCounter); collection.setInstanceGroup(buildInstanceGroup()); - + return collection; } - + public Configuration buildConfiguration() { configurationCounter++; - + Configuration configuration = new Configuration(); configuration.setConfigurationId("testConfigurationId" + configurationCounter); configuration.setConfigurationName("testConfigurationName" + configurationCounter); - + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter); modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter); modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter); - + configuration.setModelInfoConfiguration(modelInfoConfiguration); - + return configuration; } - + public OwningEntity buildOwningEntity() { owningEntityCounter++; - + OwningEntity owningEntity = new OwningEntity(); owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter); owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter); - + return owningEntity; } - + public Project buildProject() { projectCounter++; - + Project project = new Project(); project.setProjectName("testProjectName" + projectCounter); - + return project; } - + public ServiceSubscription buildServiceSubscription() { serviceSubscriptionCounter++; - + ServiceSubscription serviceSubscription = new ServiceSubscription(); serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter); serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter); - + return serviceSubscription; } - + public Customer buildCustomer() { customerCounter++; - + Customer customer = new Customer(); customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter); customer.setSubscriberType("testSubscriberType" + customerCounter); customer.setServiceSubscription(buildServiceSubscription()); - + return customer; } - + public ServiceInstance buildServiceInstance() { serviceInstanceCounter++; - + ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter); serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter); - + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter); modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter); @@ -304,30 +304,30 @@ public class BuildingBlockTestDataSetup{ modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter); modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter); serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - + serviceInstance.setProject(buildProject()); - + serviceInstance.setOwningEntity(buildOwningEntity()); - + serviceInstance.setCollection(buildCollection()); - + serviceInstance.getConfigurations().add(buildConfiguration()); - + return serviceInstance; } - + public ServiceInstance setServiceInstance() { ServiceInstance serviceInstance = buildServiceInstance(); - + if(gBBInput.getCustomer() == null) { gBBInput.setCustomer(buildCustomer()); } gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance); lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId()); - + return serviceInstance; } - + public Customer setCustomer() { if(gBBInput.getCustomer() != null) return gBBInput.getCustomer(); Customer customer = new Customer(); @@ -337,64 +337,64 @@ public class BuildingBlockTestDataSetup{ customer.setServiceSubscription(buildServiceSubscription()); gBBInput.setCustomer(customer); - + return customer; } - + public Collection setCollection() { Collection collection = new Collection(); collection.setId("testId"); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.setCollection(collection); - + return collection; } - + public InstanceGroup setInstanceGroup() { InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setId("testId"); instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction"); - + Collection collection = null; - + try { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); collection = serviceInstance.getCollection(); - + if (collection == null) { collection = setCollection(); } } catch(BBObjectNotFoundException e) { collection = setCollection(); } - + collection.setInstanceGroup(instanceGroup); - + return instanceGroup; } - + public VpnBinding buildVpnBinding() { vpnBindingCounter++; - + VpnBinding vpnBinding = new VpnBinding(); vpnBinding.setVpnId("testVpnId" + vpnBindingCounter); vpnBinding.setVpnName("testVpnName" + vpnBindingCounter); vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter); - + return vpnBinding; } - + public VpnBinding setVpnBinding() { VpnBinding vpnBinding = buildVpnBinding(); - + Customer customer = gBBInput.getCustomer(); if(customer == null){ @@ -403,106 +403,107 @@ public class BuildingBlockTestDataSetup{ customer.getVpnBindings().add(vpnBinding); lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId()); - + return vpnBinding; } - + public InstanceGroup buildInstanceGroup() { instanceGroupCounter++; - + InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setId("testId" + instanceGroupCounter); instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter); - + return instanceGroup; } - + public L3Network buildL3Network() { l3NetworkCounter++; - + L3Network network = new L3Network(); network.setNetworkId("testNetworkId" + l3NetworkCounter); network.setNetworkName("testNetworkName" + l3NetworkCounter); network.setNetworkType("testNetworkType" + l3NetworkCounter); - + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter); modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter); modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter); modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter); network.setModelInfoNetwork(modelInfoNetwork); - + return network; } - + public L3Network setL3Network() { L3Network network = buildL3Network(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getNetworks().add(network); lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId()); - + return network; } - + public GenericVnf buildGenericVnf() { genericVnfCounter++; - + GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId("testVnfId" + genericVnfCounter); genericVnf.setVnfName("testVnfName" + genericVnfCounter); genericVnf.setVnfType("testVnfType" + genericVnfCounter); - + Platform platform = new Platform(); platform.setPlatformName("testPlatformName"); genericVnf.setPlatform(platform); - + LineOfBusiness lob = new LineOfBusiness(); lob.setLineOfBusinessName("testLineOfBusinessName"); genericVnf.setLineOfBusiness(lob); - + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter); modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter); modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter); modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter); modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter); + modelInfoGenericVnf.setModelInstanceName("testModelInstanceName" + genericVnfCounter); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); - + return genericVnf; } - + public GenericVnf setGenericVnf() { GenericVnf genericVnf = buildGenericVnf(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getVnfs().add(genericVnf); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId()); - + return genericVnf; } - + public VfModule buildVfModule() { vfModuleCounter++; - + VfModule vfModule = new VfModule(); vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter); vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter); - + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter); modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter); @@ -510,128 +511,128 @@ public class BuildingBlockTestDataSetup{ modelInfoVfModule.setModelName("testModelName" + vfModuleCounter); modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter); vfModule.setModelInfoVfModule(modelInfoVfModule); - + return vfModule; } - + public VfModule setVfModule() { VfModule vfModule = buildVfModule(); - + GenericVnf genericVnf = null; - + try { genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); } catch(BBObjectNotFoundException e) { genericVnf = setGenericVnf(); } - + genericVnf.getVfModules().add(vfModule); lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); - + return vfModule; } - + public VolumeGroup buildVolumeGroup() { volumeGroupCounter++; - + VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter); volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter); volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter); - + return volumeGroup; } - + public VolumeGroup setVolumeGroup() { VolumeGroup volumeGroup = buildVolumeGroup(); - + GenericVnf genericVnf = null; - + try { genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); } catch(BBObjectNotFoundException e) { genericVnf = setGenericVnf(); } - + genericVnf.getVolumeGroups().add(volumeGroup); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - + return volumeGroup; } - + public Pnf buildPnf() { pnfCounter++; - + Pnf pnf = new Pnf(); pnf.setPnfId("testPnfId" + pnfCounter); pnf.setPnfName("testPnfName" + pnfCounter); - + return pnf; } - + public ServiceProxy buildServiceProxy() { serviceProxyCounter++; - + ServiceProxy serviceProxy = new ServiceProxy(); serviceProxy.setServiceInstance(buildServiceInstance()); serviceProxy.getServiceInstance().getVnfs().add(buildGenericVnf()); - + Pnf primaryPnf = buildPnf(); primaryPnf.setRole("Primary"); serviceProxy.getServiceInstance().getPnfs().add(primaryPnf); - + Pnf secondaryPnf = buildPnf(); secondaryPnf.setRole("Secondary"); serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf); - + return serviceProxy; } - + public VpnBondingLink buildVpnBondingLink() { vpnBondingLinkCounter++; - + VpnBondingLink vpnBondingLink = new VpnBondingLink(); vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter); - + Configuration vnrConfiguration = buildConfiguration(); - vnrConfiguration.setNetwork(buildL3Network()); + vnrConfiguration.setNetwork(buildL3Network()); vpnBondingLink.setVnrConfiguration(vnrConfiguration); vpnBondingLink.setVrfConfiguration(buildConfiguration()); - + vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy()); - + vpnBondingLink.setTransportServiceProxy(buildServiceProxy()); - + return vpnBondingLink; } - + public VpnBondingLink setVpnBondingLink() { VpnBondingLink vpnBondingLink = buildVpnBondingLink(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getVpnBondingLinks().add(vpnBondingLink); lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId()); return vpnBondingLink; } - + public Customer setAvpnCustomer() { Customer customer = buildCustomer(); - + gBBInput.setCustomer(customer); - + return customer; } - + public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) { ServiceProxy serviceProxy = new ServiceProxy(); serviceProxy.setId("testProxyId" + uniqueIdentifier); @@ -642,6 +643,7 @@ public class BuildingBlockTestDataSetup{ modelInfo.setModelName("testProxyModelName" + uniqueIdentifier); modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier); modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier); + modelInfo.setModelInstanceName("testProxyModelInstanceName" + uniqueIdentifier); serviceProxy.setModelInfoServiceProxy(modelInfo); @@ -653,13 +655,14 @@ public class BuildingBlockTestDataSetup{ ar.setId("testAllottedResourceId" + uniqueIdentifier); ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource(); - modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier); - modelInfo.setModelName("testProxyModelName" + uniqueIdentifier); - modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier); - modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier); - + modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier); + modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier); + modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier); + modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier); + modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier); + ar.setModelInfoAllottedResource(modelInfo); - + return ar; } } \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java index 4626615e6f..e36029c306 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java @@ -7,9 +7,9 @@ * 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. @@ -59,6 +59,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +//TODO this class should be in so-bpmn-tasks public class SniroHomingV2Test extends BaseTest{ private ServiceInstance serviceInstance; @@ -127,7 +128,7 @@ public class SniroHomingV2Test extends BaseTest{ sniroHoming.callSniro(execution); String request = FileUtil.readResourceFile(RESOURCE_PATH + "SniroManagerRequest1Vpn.json"); - request = request.replace("28080", wireMockPort); + //request = request.replace("28080", wireMockPort); ArgumentCaptor argument = ArgumentCaptor.forClass(SniroManagerRequest.class); verify(sniroClient, times(1)).postDemands(argument.capture()); @@ -148,7 +149,7 @@ public class SniroHomingV2Test extends BaseTest{ sniroHoming.callSniro(execution); String request = FileUtil.readResourceFile(RESOURCE_PATH + "SniroManagerRequest3Vpn.json"); - request = request.replace("28080", wireMockPort); + //request = request.replace("28080", wireMockPort); ArgumentCaptor argument = ArgumentCaptor.forClass(SniroManagerRequest.class); verify(sniroClient, times(1)).postDemands(argument.capture()); @@ -167,7 +168,7 @@ public class SniroHomingV2Test extends BaseTest{ sniroHoming.callSniro(execution); String request = FileUtil.readResourceFile(RESOURCE_PATH + "SniroManagerRequest3AR.json"); - request = request.replace("28080", wireMockPort); + //request = request.replace("28080", wireMockPort); ArgumentCaptor argument = ArgumentCaptor.forClass(SniroManagerRequest.class); verify(sniroClient, times(1)).postDemands(argument.capture()); diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml index 2d102afe9f..1aa046c0fb 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml @@ -126,30 +126,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy index d665de2ba7..bdb44ca3e2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy @@ -280,6 +280,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { String requestId = execution.getVariable("mso-request-id") String source = execution.getVariable(Prefix + "source") + String networkId = execution.getVariable("networkId") !=null ? execution.getVariable("networkId") : "" String msoCompletionRequest = """VID Network has been created successfully. + ${MsoUtils.xmlEscape(networkId)} BPMN Network action: CREATE """ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 6acabe14a0..ffac4c0174 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -186,6 +186,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable(prefix + 'cloudOwner', cloudOwner) + def tenantId = cloudConfiguration.tenantId execution.setVariable(prefix + 'tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index aa569655f4..965d178cce 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -109,6 +109,10 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { def lcpCloudRegionId = requestMap.requestDetails.cloudConfiguration.lcpCloudRegionId execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + // cloudOwner + def cloudOwner = requestMap.requestDetails.cloudConfiguration.cloudOwner + execution.setVariable('cloudOwner', cloudOwner) + // tenant def tenantId = requestMap.requestDetails.cloudConfiguration.tenantId execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index 2cbfeac239..7ddfdece9a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -7,9 +7,9 @@ * 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. @@ -30,11 +30,16 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils + import groovy.json.JsonSlurper /** @@ -135,7 +140,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { execution.setVariable('DELVfModVol_cloudRegion', utils.getNodeText(request, 'aic-cloud-region')) setBasicDBAuthHeader(execution, isDebugLogEnabled) - + msoLogger.debug('Request: ' + createVolumeIncoming) } @@ -184,12 +189,12 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_cloudRegion') - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable("DELVfModVol_queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(" DELVfModVol_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -229,8 +234,9 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) @@ -351,7 +357,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { def serviceId = execution.getVariable('DELVfModVol_serviceId') def messageId = execution.getVariable('DELVfModVol_messageId') - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host", execution) if ('true'.equals(useQualifiedHostName)) { notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) @@ -388,8 +394,9 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId).queryParam("resource-version", resourceVersion) + def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri) if(resourceVersion !=null){ deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8') @@ -436,7 +443,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { requestStatus = "FAILURE" progress = "" } - + String updateInfraRequest = """ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index b6a02f29e7..856ff6c063 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -152,26 +152,15 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { oStatus = "Created" } - String statusLine = isBlank(oStatus) ? "" : "${MsoUtils.xmlEscape(oStatus)}" - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - String serviceInstanceData = - """ - ${MsoUtils.xmlEscape(serviceInstanceId)} - ${MsoUtils.xmlEscape(serviceInstanceName)} - ${MsoUtils.xmlEscape(aaiServiceType)} - ${MsoUtils.xmlEscape(aaiServiceRole)} - ${statusLine} - ${MsoUtils.xmlEscape(modelInvariantUuid)} - ${MsoUtils.xmlEscape(modelUuid)} - ${MsoUtils.xmlEscape(uuiRequest)} - """.trim() - execution.setVariable("serviceInstanceData", serviceInstanceData) - msoLogger.debug(serviceInstanceData) - msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace) - msoLogger.info(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData) + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(aaiServiceType) + si.setServiceRole(aaiServiceRole) + si.setOrchestrationStatus(oStatus) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(modelUuid) + si.setInputParameters(uuiRequest) + execution.setVariable("serviceInstanceData", si) } catch (BpmnError e) { throw e; @@ -273,41 +262,35 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } //TODO use create if not exist - public void postProcessAAIPUT(DelegateExecution execution) { - msoLogger.trace("postProcessAAIPUT ") + public void createServiceInstance(DelegateExecution execution) { + msoLogger.trace("createServiceInstance ") String msg = "" + String serviceInstanceId = UUID.randomUUID().toString() try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - msoLogger.debug("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) - } + org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), serviceInstanceId) + client.create(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + + msg = "Exception in DoCreateServiceInstance.createServiceInstance. " + ex.getMessage() msoLogger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.trace("Exit postProcessAAIPUT ") + msoLogger.trace("Exit createServiceInstance ") } /** @@ -469,7 +452,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ") } - // if site location is in local Operator, create all resources in local ONAP; + // if site location is in local Operator, create all resources in local ONAP; // if site location is in 3rd Operator, only process sp-partner to create all resources in 3rd ONAP public void doProcessSiteLocation(DelegateExecution execution){ msoLogger.trace("======== Start doProcessSiteLocation Process ======== ") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 731d9c24de..51574f63f8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts; +import javax.ws.rs.core.UriBuilder + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -33,22 +35,27 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse; -import org.springframework.web.util.UriUtils -import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.AAIObjectPlurals 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.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.json.JSONObject +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse; +import org.springframework.web.util.UriUtils +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aai.domain.yang.RouteTarget + +import com.fasterxml.jackson.jaxrs.util.EndpointAsBeanProperty + import javax.ws.rs.NotFoundException import groovy.json.* import groovy.xml.XmlUtil - /** * This groovy class supports the DoCreateNetworkInstance.bpmn process. * @@ -360,8 +367,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // Prepare AA&I url with network-name String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryAAINameRequest = "${aai_endpoint}${aai_uri}" + "?network-name=" + networkName + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK) + uri.queryParam("network-name", networkName) + String queryAAINameRequest = aaiUriUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest) msoLogger.debug(Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest) @@ -429,15 +439,14 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { String networkInputs = execution.getVariable(Prefix + "networkInputs") String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) @@ -508,11 +517,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") - // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String queryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest) @@ -580,10 +589,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String requeryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) msoLogger.debug(Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest) @@ -660,91 +670,37 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "vpnCount", vpnCount) msoLogger.debug(Prefix + "vpnCount - " + vpnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - if (vpnCount > 0) { execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri) String routeTargets = "" // AII loop call using list vpnBindings - for (i in 0..vpnBindingUri.size()-1) { - + for(i in 0..vpnBindingUri.size()-1) { int counting = i+1 - // prepare url using vpnBinding - String queryVpnBindingAAIRequest = "" - String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) - - // Note: By default, the vpnBinding url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" - } - - } else { - // using uri value in URN mapping - String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) - if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { - vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) - } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" + String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) + if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { + vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) } - execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - msoLogger.debug(Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) - msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) - msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString) - - String routeTarget = "" - String routeRole = "" - if (utils.nodeExists(aaiResponseAsString, "route-targets")) { - String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) - def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) - def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} - for (j in 0..aaiRouteTarget.size()-1) { - routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") - routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") - routeTargets += "" + '\n' + - " " + routeTarget + "" + '\n' + - " " + routeRole + "" + '\n' + - "" + '\n' - } - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.TWO), NotFoundException.class) + + Optional binding = wrapper.asBean(VpnBinding.class) + + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "" + '\n' + + " " + routeTarget + "" + '\n' + + " " + routeRole + "" + '\n' + + "" + '\n' } } @@ -756,8 +712,8 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ @@ -771,9 +727,9 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } - } catch (BpmnError e) { - throw e; - + } catch (NotFoundException e) { + msoLogger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") } catch (Exception ex) { String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() msoLogger.debug(exceptionMessage) @@ -801,7 +757,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) msoLogger.debug(Prefix + "networkPolicyCount - " + networkPolicyCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) if (networkPolicyCount > 0) { @@ -814,31 +769,14 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 - // prepare url using vpnBinding - String queryNetworkPolicyAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - // Note: By default, the network policy url is found in 'related-link' of the response, // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) - println " networkPolicyId - " + networkPolicyId - if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { - networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) - } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" - } + URI uri = UriBuilder.fromUri(networkPolicyUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.NETWORK_POLICY, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(aaiUri) execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) msoLogger.debug(Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest) @@ -890,8 +828,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ @@ -949,30 +886,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 // prepare url using tableRef - String queryNetworkTableRefAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) - - if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { - networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) - } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" - - } + URI uri = UriBuilder.fromUri(networkTableRefUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ROUTE_TABLE_REFERENCE, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkTableRefAAIRequest = aaiUriUtil.createAaiUri(aaiUri) execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) msoLogger.debug(Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest) @@ -1024,8 +942,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ @@ -1066,16 +983,17 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") // Prepare url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String updateContrailAAIUrlRequest = aaiUriUtil.createAaiUri(uri) execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) msoLogger.debug(Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(updateContrailAAIUrlRequest) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index b44940eb20..38836c3650 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -40,10 +40,15 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils import groovy.json.* @@ -267,58 +272,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { if (siParamsXml == null) siParamsXml = "" execution.setVariable("siParamsXml", siParamsXml) - - //AAI PUT - String oStatus = execution.getVariable("initialStatus") ?: "Active" - if ("TRANSPORT".equalsIgnoreCase(serviceType)) - { - oStatus = "Created" - } - - String statusLine = isBlank(oStatus) ? "" : "${MsoUtils.xmlEscape(oStatus)}" - String serviceTypeLine = isBlank(serviceType) ? "" : "${MsoUtils.xmlEscape(serviceType)}" - String serviceRoleLine = isBlank(serviceRole) ? "" : "${MsoUtils.xmlEscape(serviceRole)}" - - //QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT - String environmentContext = "" - String workloadContext ="" - - try{ - String json = cutils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) - - msoLogger.debug("JSON IS: "+json) - - environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" - workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" - msoLogger.debug("Env Context is: "+ environmentContext) - msoLogger.debug("Workload Context is: "+ workloadContext) - }catch(BpmnError e){ - throw e - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - msoLogger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - //Create AAI Payload - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - String serviceInstanceData = - """ - ${MsoUtils.xmlEscape(serviceInstanceName)} - ${serviceTypeLine} - ${serviceRoleLine} - ${statusLine} - ${MsoUtils.xmlEscape(modelInvariantUuid)} - ${MsoUtils.xmlEscape(modelUuid)} - ${MsoUtils.xmlEscape(environmentContext)} - ${MsoUtils.xmlEscape(workloadContext)} - """.trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - msoLogger.debug(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData) - + } catch (BpmnError e) { throw e; } catch (Exception ex){ @@ -338,16 +292,17 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map msoLogger.debug(" ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - if (isBlank(aai_endpoint) || isBlank(aai_uri)) + + AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalCustomerId) + String getAAICustomerUrl = aaiUriUtil.createAaiUri(uri) + + if (isBlank(getAAICustomerUrl)) { - msg = "AAI URL is invalid. Endpoint:" + aai_endpoint + aai_uri + msg = "AAI URL is invalid. Endpoint:" + getAAICustomerUrl msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - String getAAICustomerUrl = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") msoLogger.debug("getAAICustomerById Url:" + getAAICustomerUrl) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getAAICustomerUrl) @@ -399,42 +354,75 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { } - public void postProcessAAIPUT(DelegateExecution execution) { + public void putServiceInstance(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - msoLogger.trace("postProcessAAIPUT") + msoLogger.trace("putServiceInstance") String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - msoLogger.debug("Error putting Service-instance in AAI", + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - msoLogger.debug("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else + + String serviceType = execution.getVariable("serviceType") + //AAI PUT + String oStatus = execution.getVariable("initialStatus") ?: "Active" + if ("TRANSPORT".equalsIgnoreCase(serviceType)) { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) + oStatus = "Created" } + + //QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT + String environmentContext = "" + String workloadContext ="" + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + + try{ + String json = cutils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + + msoLogger.debug("JSON IS: "+json) + + environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" + workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" + msoLogger.debug("Env Context is: "+ environmentContext) + msoLogger.debug("Workload Context is: "+ workloadContext) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceName(execution.getVariable("serviceInstanceName")) + si.setServiceType(serviceType) + si.setServiceRole(execution.getVariable("serviceRole")) + si.setOrchestrationStatus(oStatus) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(execution.getVariable("modelUuid")) + si.setEnvironmentContext(environmentContext) + si.setWorkloadContext(workloadContext) + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), serviceInstanceId) + client.create(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + + msg = "Exception in DoCreateServiceInstance.putServiceInstance. " + ex.getMessage() msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.trace("Exit postProcessAAIPUT") + msoLogger.trace("Exit putServiceInstance") } public void preProcessSDNCAssignRequest(DelegateExecution execution) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index da3ecbaef0..6783808826 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -7,9 +7,9 @@ * 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. @@ -27,6 +27,7 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.CatalogDbUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -41,11 +42,15 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.DecomposeJsonUtil import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -65,7 +70,7 @@ import com.fasterxml.jackson.databind.ObjectMapper public class DoCreateVfModule extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModule.class); - + String Prefix="DCVFM_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -81,7 +86,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable('prefix', Prefix) @@ -100,13 +105,13 @@ public class DoCreateVfModule extends VfModuleBase { if (request == null || request.isEmpty()) { // Building Block-type request - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + def serviceModelInfo = execution.getVariable("serviceModelInfo") msoLogger.debug("serviceModelInfo: " + serviceModelInfo) String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid) - + def vnfModelInfo = execution.getVariable("vnfModelInfo") //tenantId @@ -124,6 +129,11 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_cloudSiteId", cloudSiteId) rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId) msoLogger.debug("cloudSiteId: " + cloudSiteId) + //cloudOwner + def cloudOwner = execution.getVariable("cloudOwner") + execution.setVariable("DCVFM_cloudOwner", cloudOwner) + rollbackData.put("VFMODULE", "cloudOwner", cloudOwner) + msoLogger.debug("cloudOwner: " + cloudOwner) //vnfType def vnfType = execution.getVariable("vnfType") execution.setVariable("DCVFM_vnfType", vnfType) @@ -238,15 +248,15 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_usePreload", usePreload) msoLogger.debug("usePreload: " + usePreload) //aLaCarte - def aLaCarte = execution.getVariable("aLaCarte") + def aLaCarte = execution.getVariable("aLaCarte") execution.setVariable("DCVFM_aLaCarte", aLaCarte) msoLogger.debug("aLaCarte: " + aLaCarte) - + //get workload and environment context from parent SI String environmentContext = "" String workloadContext ="" String serviceType ="" - + try{ String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") @@ -257,7 +267,7 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - + try{ AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) AAIResourcesClient aaiRC = new AAIResourcesClient() @@ -265,14 +275,14 @@ public class DoCreateVfModule extends VfModuleBase { Map aaiJson = aaiRW.asMap() environmentContext = aaiJson.getOrDefault("environment-context","") workloadContext = aaiJson.getOrDefault("workload-context","") - + }catch (Exception ex) { msoLogger.debug("Error retreiving parent service instance information") } - + execution.setVariable("DCVFM_environmentContext",environmentContext) execution.setVariable("DCVFM_workloadContext",workloadContext) - + } else { // The info is inside the request - DEAD CODE @@ -400,7 +410,7 @@ public class DoCreateVfModule extends VfModuleBase { isBaseVfModule = utils.getNodeText(request, "is-base-vf-module") } execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule) - msoLogger.debug("isBaseVfModule: " + isBaseVfModule) + msoLogger.debug("isBaseVfModule: " + isBaseVfModule) //asdcServiceModelVersion def asdcServiceModelVersion = "" if (utils.nodeExists(request, "asdc-service-model-version")) { @@ -479,7 +489,7 @@ public class DoCreateVfModule extends VfModuleBase { } msoLogger.debug("sdncVersion: " + sdncVersion) execution.setVariable("DCVFM_sdncVersion", sdncVersion) - + execution.setVariable("DCVFM_uuid", uuid) execution.setVariable("DCVFM_baseVfModuleId", "") execution.setVariable("DCVFM_baseVfModuleHeatStackId", "") @@ -544,7 +554,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.sendResponse(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -554,7 +564,7 @@ public class DoCreateVfModule extends VfModuleBase { throw e; } catch (Exception e) { msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); - + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Internal Error') } } @@ -570,7 +580,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.getVfModule(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -614,7 +624,7 @@ public class DoCreateVfModule extends VfModuleBase { * @param execution The flow's execution instance. */ public void queryAAIVfModule(DelegateExecution execution) { - + def method = getClass().getSimpleName() + '.getVfModule(' + 'execution=' + execution.getId() + ')' @@ -625,10 +635,8 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleId = execution.getVariable('DCVFM_vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) try { RESTConfig config = new RESTConfig(endPoint); @@ -688,23 +696,23 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) } } - + /** - * Using the vnfId and vfModuleName provided in the inputs, + * Using the vnfId and vfModuleName provided in the inputs, * query AAI to get the corresponding VF Module info. - * A 200 response is expected with the VF Module info in the response body, - * or a 404 response if the module does not exist yet. Will determine VF Module's + * A 200 response is expected with the VF Module info in the response body, + * or a 404 response if the module does not exist yet. Will determine VF Module's * orchestration status if one exists * * @param execution The flow's execution instance. */ public void queryAAIVfModuleForStatus(DelegateExecution execution) { - + def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + execution.setVariable('DCVFM_orchestrationStatus', '') try { @@ -712,12 +720,8 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleName = execution.getVariable('DCVFM_vfModuleName') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + - "/vf-modules/vf-module?vf-module-name=" + UriUtils.encode(vfModuleName, "UTF-8") - msoLogger.debug("AAI endPoint: " + endPoint) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULES, vnfId).queryParam("vf-module-name",vfModuleName) + String endPoint = aaiUriUtil.createAaiUri(uri) try { RESTConfig config = new RESTConfig(endPoint); @@ -755,7 +759,7 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleId = utils.getNodeText(vfModuleText, "vf-module-id") execution.setVariable("DCVFM_vfModuleId", vfModuleId) msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus) - + } } } catch (Exception ex) { @@ -774,7 +778,7 @@ public class DoCreateVfModule extends VfModuleBase { public void preProcessSDNCAssignRequest(DelegateExecution execution){ - + execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessSDNCAssignRequest") def vnfId = execution.getVariable("DCVFM_vnfId") @@ -801,30 +805,30 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessSDNCAssignRequest") } public void preProcessSDNCGetRequest(DelegateExecution execution, String element){ - + String sdncVersion = execution.getVariable("DCVFM_sdncVersion") execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessSDNCGetRequest Process") try{ def serviceInstanceId = execution.getVariable('DCVFM_serviceInstanceId') - + String uuid = execution.getVariable('testReqId') // for junits if(uuid==null){ uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() } - + def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") msoLogger.debug("callbackUrl:" + callbackUrl) - + def vfModuleId = execution.getVariable('DCVFM_vfModuleId') - + def svcInstId = "" if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { svcInstId = vfModuleId @@ -832,7 +836,7 @@ public class DoCreateVfModule extends VfModuleBase { else { svcInstId = serviceInstanceId } - + def msoAction = "" if (!sdncVersion.equals("1707")) { msoAction = "mobility" @@ -840,33 +844,36 @@ public class DoCreateVfModule extends VfModuleBase { else { msoAction = "vfmodule" } - // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element - // in the response from GenericGetVnf + // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element // For VF Module, in 1707 serviceOperation will be retrieved from "object-path" element // in SDNC Assign Response // For VF Module for older versions, serviceOperation is constructed using vfModuleId - + String serviceOperation = "" if (element.equals("vnf")) { - def vnfQueryResponse = execution.getVariable("DCVFM_vnfQueryResponse") - serviceOperation = utils.getNodeText(vnfQueryResponse, "selflink") + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('DCVFM_vnfId')) + AAIResultWrapper wrapper = resourceClient.get(uri) + + Optional vnf = wrapper.asBean(GenericVnf.class) + serviceOperation = vnf.get().getSelflink() msoLogger.debug("VNF - service operation: " + serviceOperation) } else if (element.equals("vfmodule")) { String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") - msoLogger.debug("DCVFM_assignSDNCAdapterResponse is: \n" + response) - + msoLogger.debug("DCVFM_assignSDNCAdapterResponse is: \n" + response) + if (!sdncVersion.equals("1707")) { serviceOperation = "/VNF-API:vnfs/vnf-list/" + vfModuleId msoLogger.debug("VF Module with sdncVersion before 1707 - service operation: " + serviceOperation) } - else { - String data = utils.getNodeXml(response, "response-data") + else { + String data = utils.getNodeXml(response, "response-data") msoLogger.debug("responseData: " + data) serviceOperation = utils.getNodeText(data, "object-path") msoLogger.debug("VF Module with sdncVersion of 1707 - service operation: " + serviceOperation) - } - } + } + } //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE sleep(5000) @@ -890,7 +897,7 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process") @@ -901,7 +908,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.VNFAdapterCreateVfModule(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) //def xml = execution.getVariable("DoCreateVfModuleRequest") @@ -952,7 +959,7 @@ public class DoCreateVfModule extends VfModuleBase { String workloadContext = execution.getVariable("DCVFM_workloadContext") msoLogger.debug("workloadContext: " + workloadContext) msoLogger.debug("environmentContext: " + environmentContext) - + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() @@ -972,9 +979,9 @@ public class DoCreateVfModule extends VfModuleBase { String vfModuleSdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse') msoLogger.debug("sdncGetResponse: " + vfModuleSdncGetResponse) def sdncVersion = execution.getVariable("sdncVersion") - + if (!sdncVersion.equals("1707")) { - + vfModuleParams = buildVfModuleParams(vnfParamsMap, vfModuleSdncGetResponse, vnfId, vnfName, vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) } @@ -982,9 +989,9 @@ public class DoCreateVfModule extends VfModuleBase { //Get SDNC Response Data for Vnf Topology String vnfSdncGetResponse = execution.getVariable('DCVFM_getVnfSDNCAdapterResponse') msoLogger.debug("vnfSdncGetResponse: " + vnfSdncGetResponse) - + vfModuleParams = buildVfModuleParamsFromCombinedTopologies(vnfParamsMap, vnfSdncGetResponse, vfModuleSdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) + vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) } def svcInstId = "" @@ -1041,7 +1048,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.validateInfraRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) String processKey = getProcessKey(execution); @@ -1103,7 +1110,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.isVolumeGroupIdPresent(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) def request = execution.getVariable('DoCreateVfModuleRequest') @@ -1124,7 +1131,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.isVolumeGroupNamePresent(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) def request = execution.getVariable('DoCreateVfModuleRequest') @@ -1187,9 +1194,9 @@ public class DoCreateVfModule extends VfModuleBase { }else{ sdncVNFParamsXml = "" } - + String sdncRequest = "" - + if (!sdncVersion.equals("1707")) { sdncRequest = @@ -1231,10 +1238,10 @@ public class DoCreateVfModule extends VfModuleBase { """ - + } - else { - + else { + sdncRequest = """${MsoUtils.xmlEscape(serviceId)} ${serviceEcompModelInformation} ${MsoUtils.xmlEscape(svcInstId)} - ${MsoUtils.xmlEscape(globalSubscriberId)} - + ${MsoUtils.xmlEscape(globalSubscriberId)} + ${MsoUtils.xmlEscape(vnfId)} ${MsoUtils.xmlEscape(vnfType)} - ${vnfEcompModelInformation} + ${vnfEcompModelInformation} ${MsoUtils.xmlEscape(vfModuleId)} ${MsoUtils.xmlEscape(vfModuleModelName)} - ${vfModuleEcompModelInformation} + ${vfModuleEcompModelInformation} - + ${MsoUtils.xmlEscape(vfModuleName)} ${MsoUtils.xmlEscape(tenantId)} - ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(cloudSiteId)} ${sdncVNFParamsXml} """ - - + + /* sdncRequest = """ ${MsoUtils.xmlEscape(serviceId)} ${MsoUtils.xmlEscape(serviceId)} - ${serviceEcompModelInformation} + ${serviceEcompModelInformation} ${MsoUtils.xmlEscape(svcInstId)} ${MsoUtils.xmlEscape(globalSubscriberId)} ${MsoUtils.xmlEscape(vnfId)} ${MsoUtils.xmlEscape(vnfType)} - ${vnfEcompModelInformation} + ${vnfEcompModelInformation} ${MsoUtils.xmlEscape(vfModuleId)} ${MsoUtils.xmlEscape(vfModuleModelName)} - ${vfModuleEcompModelInformation} + ${vfModuleEcompModelInformation} - + ${MsoUtils.xmlEscape(vfModuleName)} ${MsoUtils.xmlEscape(tenantId)} - ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(cloudSiteId)} ${sdncVNFParamsXml} - + """ */ - + } msoLogger.debug("sdncRequest: " + sdncRequest) @@ -1338,7 +1345,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessSDNCActivateRequest Process") @@ -1370,7 +1377,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix",Prefix) try{ @@ -1458,7 +1465,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestOrch(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestOrch") @@ -1471,7 +1478,7 @@ public class DoCreateVfModule extends VfModuleBase { if (!contrailServiceInstanceFqdn.equals("")) { setContrailServiceInstanceFqdn = true } - + execution.setVariable("DCVFM_orchestrationStatus", "Created") String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, true, setContrailServiceInstanceFqdn) @@ -1481,18 +1488,18 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestOrch Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestOrch") } - + public void preProcessUpdateAAIVfModuleRequestStatus(DelegateExecution execution, String status) { def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleStatus(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessUpdateAAIVfModuleStatus") @@ -1521,7 +1528,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestGroup(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestGroup") @@ -1537,7 +1544,7 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestGroup Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestGroup") @@ -1545,7 +1552,7 @@ public class DoCreateVfModule extends VfModuleBase { } public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - + execution.setVariable("prefix",Prefix) msoLogger.debug("STARTED ValidateSDNCResponse Process") @@ -1578,7 +1585,7 @@ public class DoCreateVfModule extends VfModuleBase { } public void preProcessUpdateAfterCreateRequest(DelegateExecution execution){ - + execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessRequest Process") try{ @@ -1684,25 +1691,25 @@ public class DoCreateVfModule extends VfModuleBase { } return params } - + public String buildCompleteSDNCParamsXml(DelegateExecution execution){ - + String params = "" StringBuilder sb = new StringBuilder() Map paramsMap = execution.getVariable("DCVFM_vnfParamsMap") - + for (Map.Entry entry : paramsMap.entrySet()) { String paramsXml - String key = entry.getKey(); + String key = entry.getKey(); String value = entry.getValue() - paramsXml = """<${key}>$value""" + paramsXml = """<${key}>$value""" params = sb.append(paramsXml) } return params } public void queryCloudRegion (DelegateExecution execution) { - + execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED queryCloudRegion") @@ -1710,13 +1717,12 @@ public class DoCreateVfModule extends VfModuleBase { String cloudRegion = execution.getVariable("DCVFM_cloudSiteId") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable("DCVFM_queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug("DCVFM_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -1773,7 +1779,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepareCreateAAIVfModuleVolumeGroupRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED prepareCreateAAIVfModuleVolumeGroupRequest") @@ -1787,12 +1793,14 @@ public class DoCreateVfModule extends VfModuleBase { def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId") //def aicCloudRegion = execution.getVariable("DCVFM_cloudSiteId") def aicCloudRegion = execution.getVariable("DCVFM_cloudRegionForVolume") + def cloudOwner = execution.getVariable("DCVFM_cloudOwner") String createAAIVfModuleVolumeGroupRequest = """ ${MsoUtils.xmlEscape(vnfId)} ${MsoUtils.xmlEscape(vfModuleId)} ${MsoUtils.xmlEscape(volumeGroupId)} ${MsoUtils.xmlEscape(aicCloudRegion)} + ${MsoUtils.xmlEscape(cloudOwner)} """ createAAIVfModuleVolumeGroupRequest = utils.formatXml(createAAIVfModuleVolumeGroupRequest) @@ -1811,7 +1819,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.createNetworkPoliciesInAAI(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED createNetworkPoliciesInAAI") @@ -1825,109 +1833,81 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_networkPolicyFqdnCount", fqdnCount) msoLogger.debug("DCVFM_networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - if (fqdnCount > 0) { - - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - - int counting = i+1 - String fqdn = fqdnList[i] - - // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") - - def aaiRequestId = UUID.randomUUID().toString() - RESTConfig config = new RESTConfig(queryNetworkPolicyByFqdnAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() - int returnCode = response.getStatusCode() - execution.setVariable("DCVFM_aaiQqueryNetworkPolicyByFqdnReturnCode", returnCode) - msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (isOneOf(returnCode, 200, 201)) { - msoLogger.debug("The return code is: " + returnCode) - // This network policy FQDN already exists in AAI - execution.setVariable("DCVFM_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) - msoLogger.debug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) - - } else { - if (returnCode == 404) { - // This network policy FQDN is not in AAI yet. Add it now - msoLogger.debug("The return code is: " + returnCode) - msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn) - // Add the network policy with this FQDN to AAI - def networkPolicyId = UUID.randomUUID().toString() - msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId) - - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - msoLogger.debug('AAI namespace is: ' + aaiNamespace) - String payload = """ + + if (fqdnCount > 0) { + + // AII loop call over contrail network policy fqdn list + for (i in 0..fqdnCount-1) { + + int counting = i+1 + String fqdn = fqdnList[i] + + // Query AAI for this network policy FQDN + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + + AAIResourcesClient resourceClient = new AAIResourcesClient() + + + if (resourceClient.exists(uri)) { + + msoLogger.debug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting) + + } else { + // This network policy FQDN is not in AAI yet. Add it now + msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn) + // Add the network policy with this FQDN to AAI + def networkPolicyId = UUID.randomUUID().toString() + msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId) + + String aaiNamespace = aaiUriUtil.getNamespace() + msoLogger.debug('AAI namespace is: ' + aaiNamespace) + String payload = """ ${MsoUtils.xmlEscape(networkPolicyId)} ${MsoUtils.xmlEscape(fqdn)} ${MsoUtils.xmlEscape(execution.getVariable("DCVFM_heatStackId"))} """ as String - execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload) - - String addNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") - msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest) - - def aaiRequestIdPut = UUID.randomUUID().toString() - RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest); - RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) - APIResponse responsePut = clientPut.httpPut(payload) - int returnCodePut = responsePut.getStatusCode() - execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut) - msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut) - - String aaiResponseAsStringPut = responsePut.getResponseBodyAsString() - if (isOneOf(returnCodePut, 200, 201)) { - msoLogger.debug("The return code from adding network policy is: " + returnCodePut) - // This network policy was created in AAI successfully - execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut) - msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut) - rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") - rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) - execution.setVariable("rollbackData", rollbackData) - - } else { - // aai all errors - String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut - msoLogger.debug(putErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage) - } - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from createNetworkPoliciesInAAI - " + returnCode - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } + execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload) + + AAIResourceUri addUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + String addNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(addUri) + + msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest) + + def aaiRequestIdPut = UUID.randomUUID().toString() + RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest); + RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut) + .addHeader("X-FromAppId", "MSO") + .addHeader("Content-Type", "application/xml") + .addHeader("Accept","application/xml"); + msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) + APIResponse responsePut = clientPut.httpPut(payload) + int returnCodePut = responsePut.getStatusCode() + execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut) + msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut) + + String aaiResponseAsStringPut = responsePut.getResponseBodyAsString() + if (isOneOf(returnCodePut, 200, 201)) { + msoLogger.debug("The return code from adding network policy is: " + returnCodePut) + // This network policy was created in AAI successfully + execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut) + msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut) + rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") + rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) + execution.setVariable("rollbackData", rollbackData) + + } else { + // aai all errors + String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut + msoLogger.debug(putErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage) + } + + } - } // end loop + } // end loop } else { @@ -1955,7 +1935,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -2008,7 +1988,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.postProcessUpdateAAIGenericVnf(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -2040,37 +2020,37 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage()) } } - + public void queryCatalogDB (DelegateExecution execution) { - + String msg = "" msoLogger.trace("queryCatalogDB ") try { boolean twoPhaseDesign = false // check for input - + String vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") msoLogger.debug("vfModuleModelName: " + vfModuleModelName) def vnfModelInfo = execution.getVariable("vnfModelInfo") def vnfModelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") - - msoLogger.debug("vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) - + + msoLogger.debug("vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) + JSONArray vnfs = catalog.getAllVnfsByVnfModelCustomizationUuid(execution, vnfModelCustomizationUuid, "v2") - - msoLogger.debug("Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid) + + msoLogger.debug("Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid) // Only one match here if (vnfs != null) { JSONObject vnfObject = vnfs.get(0) if (vnfObject != null) { String vnfJson = vnfObject.toString() // - ObjectMapper om = new ObjectMapper(); + ObjectMapper om = new ObjectMapper(); VnfResource vnf = om.readValue(vnfJson, VnfResource.class); - + // Get multiStageDesign flag - + String multiStageDesignValue = vnf.getMultiStageDesign() msoLogger.debug("multiStageDesign value from Catalog DB is: " + multiStageDesignValue) if (multiStageDesignValue != null) { @@ -2080,10 +2060,10 @@ public class DoCreateVfModule extends VfModuleBase { } } } - + msoLogger.debug("setting twoPhaseDesign flag to: " + twoPhaseDesign) - - execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign) + + execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign) } catch (BpmnError e) { throw e; } catch (Exception e) { @@ -2091,13 +2071,13 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryCatalogDB(): ' + e.getMessage()) } } - - + + public void preProcessRollback (DelegateExecution execution) { msoLogger.trace("preProcessRollback") try { - + Object workflowException = execution.getVariable("WorkflowException"); if (workflowException instanceof WorkflowException) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index a0b7dabb32..a553127c5c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -28,6 +28,10 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -477,9 +481,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount) msoLogger.debug("networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) if (fqdnCount > 0) { // AII loop call over contrail network policy fqdn list @@ -489,8 +491,10 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ String fqdn = fqdnList[i] // Query AAI for this network policy FQDN + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri) - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) def aaiRequestId = UUID.randomUUID().toString() @@ -514,8 +518,9 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + delUri.resourceVersion(resourceVersion) + String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri) msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy index 5995b6b099..3b0707a529 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy @@ -7,9 +7,9 @@ * 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. @@ -38,6 +38,11 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.constants.Defaults import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.logger.MsoLogger @@ -46,14 +51,14 @@ import org.onap.so.logger.MessageEnum public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeRollback.class); - + String Prefix="DCVFMODVOLRBK_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) def className = getClass().getSimpleName() - + /** * This method is executed during the preProcessRequest task of the DoCreateVfModuleVolumeRollback.bpmn process. * @param execution @@ -80,7 +85,7 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor InitializeProcessVariables(execution) // rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudSiteId) RollbackData rollbackData = execution.getVariable("rollbackData") - + // String vnfId = rollbackData.get("DCVFMODULEVOL", "vnfid") // execution.setVariable("DCVFMODVOLRBK_vnfId", vnfId) // String vfModuleId = rollbackData.get("DCVFMODULEVOL", "vfmoduleid") @@ -107,47 +112,48 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor // execution.setVariable("DCVFMODVOLRBK_heatStackId", heatStackId) // String requestId = rollbackData.get("DCVFMODULEVOL", "msorequestid") // execution.setVariable("DCVFMODVOLRBK_requestId", requestId) - + String volumeGroupName = rollbackData.get("DCVFMODULEVOL", "volumeGroupName") execution.setVariable("DCVFMODVOLRBK_volumeGroupName", volumeGroupName) String lcpCloudRegionId = rollbackData.get("DCVFMODULEVOL", "aiccloudregion") execution.setVariable("DCVFMODVOLRBK_lcpCloudRegionId", lcpCloudRegionId) - + execution.setVariable("DCVFMODVOLRBK_rollbackVnfARequest", rollbackData.get("DCVFMODULEVOL", "rollbackVnfARequest")) execution.setVariable("DCVFMODVOLRBK_backoutOnFailure", rollbackData.get("DCVFMODULEVOL", "backoutOnFailure")) execution.setVariable("DCVFMODVOLRBK_isCreateVnfRollbackNeeded", rollbackData.get("DCVFMODULEVOL", "isCreateVnfRollbackNeeded")) execution.setVariable("DCVFMODVOLRBK_isAAIRollbackNeeded", rollbackData.get("DCVFMODULEVOL", "isAAIRollbackNeeded")) } - + /** * Query AAI volume group by name * @param execution * @param isDebugEnabled */ public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) { - + def volumeGroupName = execution.getVariable('DCVFMODVOLRBK_volumeGroupName') def cloudRegion = execution.getVariable('DCVFMODVOLRBK_lcpCloudRegionId') - + // This is for stub testing def testVolumeGroupName = execution.getVariable('test-volume-group-name') if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) { volumeGroupName = testVolumeGroupName } - + AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8') + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName) + def queryAAIVolumeNameRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query volume group by name return code: " + returnCode) msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString) @@ -171,31 +177,32 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor } } } - - - + + + public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) { callRESTQueryAAIVolGrpName(execution, isDebugEnabled) - + def queryAaiVolumeGroupResponse = execution.getVariable(prefix+'queryAAIVolGrpNameResponse') - + def volumeGroupId = utils.getNodeText(queryAaiVolumeGroupResponse, "volume-group-id") def resourceVersion = utils.getNodeText(queryAaiVolumeGroupResponse, "resource-version") def cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId") - + AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group" + '/' + volumeGroupId + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId).queryParam("resource-version", resourceVersion) + def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) - + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI delete volume group return code: " + returnCode) msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString) @@ -219,18 +226,18 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor // ******************************* - + public void processJavaException(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) - + try{ msoLogger.debug("Caught a Java Exception in " + Prefix) msoLogger.debug("Started processJavaException Method") msoLogger.debug("Variables List: " + execution.getVariables()) execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - + }catch(Exception e){ msoLogger.debug("Caught Exception during processJavaException Method: " + e) execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy index f87f32c610..cf5c214d3f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy @@ -37,10 +37,12 @@ import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIObjectPlurals 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.constants.Defaults import org.json.JSONObject import javax.ws.rs.NotFoundException @@ -82,7 +84,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { if (cloudSiteId == null) { String cloudConfiguration = execution.getVariable("cloudConfiguration") cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") + def cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.cloudOwner") execution.setVariable("lcpCloudRegionId", cloudSiteId) + execution.setVariable("cloudOwner", cloudOwner) } // Extract attributes from modelInfo @@ -171,10 +175,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { msoLogger.debug('Request cloud region is: ' + cloudRegion) AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion - msoLogger.debug(queryCloudRegionRequest) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -220,8 +223,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { } AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8') + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName) + def queryAAIVolumeNameRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) @@ -292,7 +296,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { def vnfType = execution.getVariable("vnfType") def tenantId = execution.getVariable("tenantId") def cloudRegion = execution.getVariable('lcpCloudRegionId') - + def cloudOwner = execution.getVariable('cloudOwner') msoLogger.debug("volumeGroupId: " + volumeGroupId) def testGroupId = execution.getVariable('test-volume-group-id') @@ -305,16 +309,17 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { msoLogger.debug("volumeGroupId to be used: " + volumeGroupId) AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") - String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def createAAIVolumeGrpNameUrlRequest = aaiUtil.createAaiUri(uri) + + String namespace = aaiUtil.getNamespaceFromUri(createAAIVolumeGrpNameUrlRequest) msoLogger.debug("AAI namespace is: " + namespace) msoLogger.debug("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest) NetworkUtils networkUtils = new NetworkUtils() - String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) + String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudOwner, cloudRegion, namespace, modelCustomizationId) String payloadXml = utils.formatXml(payload) msoLogger.debug("Request payload for PUT: " + payloadXml) @@ -541,10 +546,11 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { String cloudRegion = execution.getVariable("lcpCloudRegionId") AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String updateAAIVolumeGroupUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, 'UTF-8') - String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def updateAAIVolumeGroupUrlRequest = aaiUtil.createAaiUri(uri) + + String namespace = aaiUtil.getNamespaceFromUri(updateAAIVolumeGroupUrlRequest) msoLogger.debug("updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest) @@ -595,11 +601,11 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) - def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") - - msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + String queryAAIRequest = aaiUtil.createAaiUri(uri) + msoLogger.debug("AAI query generic vnf endpoint: " + queryAAIRequest) + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) String returnCode = response.getStatusCode() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 1585a7bb74..b35aab1176 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -24,6 +24,7 @@ import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -105,7 +106,13 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String vnfName = execution.getVariable("vnfName") if (vnfName.equals("") || vnfName.equals("null")) { - vnfName = null + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId")) + if(resourceClient.exists(uri)){ + exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.") + } + + } execution.setVariable("DoCVNF_vnfName", vnfName) msoLogger.debug("Incoming Vnf Name is: " + vnfName) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 3ee059cb02..3812c081f5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -7,9 +7,9 @@ * 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. @@ -33,6 +33,11 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse; @@ -44,7 +49,7 @@ import groovy.json.* public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstance.class); - + String Prefix= "DELNWKI_" String groovyClassName = "DoDeleteNetworkInstance" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -93,13 +98,13 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "deactivateSDNCResponse", "") execution.setVariable(Prefix + "deactivateSdncReturnCode", "") execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") - + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") execution.setVariable(Prefix + "isException", false) - + } - + // ************************************************** // Pre or Prepare Request Section // ************************************************** @@ -112,19 +117,19 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { // initialize flow variables InitializeProcessVariables(execution) - + try { // get incoming message/input execution.setVariable("action", "DELETE") String deleteNetwork = execution.getVariable("bpmnRequest") if (deleteNetwork != null) { if (deleteNetwork.contains("requestDetails")) { - // JSON format request is sent, create xml + // JSON format request is sent, create xml try { def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString()) msoLogger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork) - + } catch (Exception ex) { String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() msoLogger.debug(dataErrorMessage) @@ -132,26 +137,26 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } else { // XML format request is sent - + } } else { // vIPR format request is sent, create xml from individual variables deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution) } - + deleteNetwork = utils.formatXml(deleteNetwork) msoLogger.debug(deleteNetwork) execution.setVariable(Prefix + "networkRequest", deleteNetwork) msoLogger.debug(Prefix + "networkRequest - " + '\n' + deleteNetwork) - + // validate 'backout-on-failure' to override 'mso.rollback' boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork) execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) msoLogger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) - + String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","") execution.setVariable(Prefix + "networkInputs", networkInputs) - + // prepare messageId String messageId = execution.getVariable("testMessageId") // for testing if (messageId == null || messageId == "") { @@ -161,11 +166,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.debug(Prefix + "messageId, pre-assigned: " + messageId) } execution.setVariable(Prefix + "messageId", messageId) - + String source = utils.getNodeText(deleteNetwork, "source") execution.setVariable(Prefix + "source", source) msoLogger.debug(Prefix + "source - " + source) - + String networkId = "" if (utils.nodeExists(networkInputs, "network-id")) { networkId = utils.getNodeText(networkInputs, "network-id") @@ -188,7 +193,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) msoLogger.debug("lcpCloudRegion : " + lcpCloudRegion) - + String tenantId = null if (utils.nodeExists(networkInputs, "tenant-id")) { tenantId = utils.getNodeText(networkInputs, "tenant-id") @@ -199,18 +204,18 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } execution.setVariable(Prefix + "tenantId", tenantId) msoLogger.debug("tenantId : " + tenantId) - + String sdncVersion = execution.getVariable("sdncVersion") msoLogger.debug("sdncVersion? : " + sdncVersion) - + // PO Authorization Info / headers Authorization= String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - + try { def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValuePO",encodedString) execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - + } catch (IOException ex) { String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() msoLogger.debug(dataErrorMessage ) @@ -227,7 +232,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } - + } @@ -243,10 +248,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + + String queryAAIRequest = aaiUriUtil.createAaiUri(uri) msoLogger.debug(queryAAIRequest) execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest) msoLogger.debug(Prefix + "AAIRequest - " + "\n" + queryAAIRequest) @@ -279,7 +285,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) } else { - // verify if lcpCloudRegion was sent as input, if not get value from AAI Response + // verify if lcpCloudRegion was sent as input, if not get value from AAI Response if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) { String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString) execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) @@ -290,7 +296,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "tenantId", tenantId) msoLogger.debug(" Get AAI getTenantId() : " + tenantId) } - + } } msoLogger.debug(Prefix + "isVfRelationshipExist - " + isVfRelationshipExist) @@ -339,15 +345,13 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkInputs = execution.getVariable(Prefix + "networkInputs") // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug(queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) @@ -392,7 +396,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkType = utils.getNodeText(queryAAIResponse, "network-type") String networkId = utils.getNodeText(queryAAIResponse, "network-id") String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") - + String networkStackId = "" networkStackId = utils.getNodeText(queryAAIResponse, "heat-stack-id") if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { @@ -412,14 +416,14 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? - String modelCustomizationUuid = "" + String modelCustomizationUuid = "" if (utils.nodeExists(networkRequest, "networkModelInfo")) { String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") } else { modelCustomizationUuid = utils.getNodeText(networkRequest, "modelCustomizationId") } - + String deleteNetworkRequest = """ ${MsoUtils.xmlEscape(cloudSiteId)} @@ -515,7 +519,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { networkId = utils.getNodeText(deleteNetworkInput, "network-id") } if (networkId == 'null') {networkId = ""} - + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") // get/set 'msoRequestId' and 'mso-request-id' @@ -524,11 +528,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable("mso-request-id", requestId) } else { requestId = execution.getVariable("mso-request-id") - } + } execution.setVariable(Prefix + "requestId", requestId) msoLogger.debug(Prefix + "requestId " + requestId) String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -567,7 +571,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (networkId == 'null') {networkId = ""} String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -587,8 +591,8 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - - + + public void prepareRpcSDNCDeactivate(DelegateExecution execution) { execution.setVariable("prefix",Prefix) @@ -596,7 +600,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -607,7 +611,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } if (networkId == 'null') {networkId = ""} String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) @@ -622,7 +626,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + // ************************************************** // Post or Validate Response Section // ************************************************** @@ -640,7 +644,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.debug(" Network Adapter responseCode: " + returnCode) msoLogger.debug("Network Adapter Response - " + "\n" + networkResponse) msoLogger.debug(networkResponse) - + String errorMessage = "" if (returnCode == "200") { msoLogger.debug(" Network Adapter Response is successful - " + "\n" + networkResponse) @@ -658,9 +662,9 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String rollbackNetworkXml = utils.formatXml(rollbackNetwork) execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) msoLogger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) - } - - + } + + } else { // network error if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx if (networkResponse.contains("deleteNetworkError") ) { @@ -756,7 +760,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) { execution.setVariable("prefix",Prefix) @@ -764,7 +768,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -789,43 +793,43 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void prepareRollbackData(DelegateExecution execution) { execution.setVariable("prefix",Prefix) - + msoLogger.trace("Inside prepareRollbackData() of DoDeleteNetworkInstance ") - + try { - + Map rollbackData = new HashMap(); String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") if (rollbackNetworkRequest != null) { if (rollbackNetworkRequest != "") { rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) } - } + } String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") if (rollbackDeactivateSDNCRequest != null) { if (rollbackDeactivateSDNCRequest != "") { rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) } - } + } execution.setVariable("rollbackData", rollbackData) msoLogger.debug("** rollbackData : " + rollbackData) - + execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) msoLogger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) - + } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - + } - + } - + public void postProcessResponse (DelegateExecution execution) { execution.setVariable("prefix", Prefix) @@ -833,7 +837,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside postProcessResponse of DoDeleteNetworkInstance ") try { - + msoLogger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) if (execution.getVariable(Prefix + "isException") == false) { execution.setVariable(Prefix + "Success", true) @@ -841,10 +845,10 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (execution.getVariable(Prefix + "isSilentSuccess") == true) { execution.setVariable("rolledBack", false) } else { - execution.setVariable("rolledBack", true) + execution.setVariable("rolledBack", true) } prepareSuccessRollbackData(execution) // populate rollbackData - + } else { execution.setVariable(Prefix + "Success", false) execution.setVariable("rollbackData", null) @@ -864,25 +868,25 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } } - + // going to the Main flow: a-la-carte or macro msoLogger.debug(" ***** postProcessResponse(), BAD !!!") exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) throw new BpmnError("MSOWorkflowException") - - } - + + } + } catch(BpmnError b){ msoLogger.debug("Rethrowing MSOWorkflowException") throw b - + } catch (Exception ex) { // caught exception String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) throw new BpmnError("MSOWorkflowException") - + } } @@ -890,18 +894,18 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { public void prepareSuccessRollbackData(DelegateExecution execution) { execution.setVariable("prefix",Prefix) - + msoLogger.trace("Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ") - + try { - + if (execution.getVariable("sdncVersion") != '1610') { prepareRpcSDNCDeactivateRollback(execution) prepareRpcSDNCUnassignRollback(execution) } else { prepareSDNCRollback(execution) - } - + } + Map rollbackData = new HashMap(); String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") if (rollbackSDNCRequest != null) { @@ -914,26 +918,26 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (rollbackNetworkRequest != "") { rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) } - } + } String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") if (rollbackDeactivateSDNCRequest != null) { if (rollbackDeactivateSDNCRequest != "") { rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) } - } + } execution.setVariable("rollbackData", rollbackData) - + msoLogger.debug("** rollbackData : " + rollbackData) execution.setVariable("WorkflowException", null) - + } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - + } - + } public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) { @@ -943,7 +947,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -952,7 +956,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkId = utils.getNodeText(deleteSDNCResponse, "network-id") if (networkId == 'null') {networkId = ""} String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -962,7 +966,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) msoLogger.debug(Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString) msoLogger.debug(" Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) - + } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage() @@ -972,7 +976,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void prepareSDNCRollback (DelegateExecution execution) { execution.setVariable("prefix", Prefix) @@ -980,7 +984,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareSDNCRollback of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -990,7 +994,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { networkId = utils.getNodeText(deleteNetworkInput, "network-id") } if (networkId == 'null') {networkId = ""} - + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") // get/set 'msoRequestId' and 'mso-request-id' @@ -999,11 +1003,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable("mso-request-id", requestId) } else { requestId = execution.getVariable("mso-request-id") - } + } execution.setVariable(Prefix + "requestId", requestId) - + String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -1025,33 +1029,33 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void setExceptionFlag(DelegateExecution execution){ execution.setVariable("prefix",Prefix) - + msoLogger.trace("Inside setExceptionFlag() of DoDeleteNetworkInstance ") - + try { execution.setVariable(Prefix + "isException", true) - + if (execution.getVariable("SavedWorkflowException1") != null) { execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) } else { execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) } msoLogger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) - + } catch(Exception ex){ String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) } - + } - - + + // ******************************* // Build Error Section // ******************************* @@ -1065,7 +1069,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.debug("Variables List: " + execution.getVariables()) execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - + }catch(Exception e){ msoLogger.debug("Caught Exception during processJavaException Method: " + e) execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index b41b74e509..1a3e8aa4e6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -34,6 +34,10 @@ import org.onap.so.bpmn.common.scripts.VfModule import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -470,9 +474,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount) msoLogger.debug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) if (fqdnCount > 0) { // AII loop call over contrail network policy fqdn list @@ -482,10 +484,10 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ String fqdn = fqdnList[i] // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri) msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) int returnCode = response.getStatusCode() @@ -508,9 +510,10 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") - msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + delUri.resourceVersion(resourceVersion) + String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri) + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) msoLogger.debug("invoking DELETE call to AAI") @@ -644,11 +647,9 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def vfModuleId = execution.getVariable('vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUriUtil.createAaiUri(uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + - "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index 1024fc57da..d90c316832 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -33,6 +33,11 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -129,10 +134,9 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + + String endPoint = aaiUriUtil.createAaiUri(uri) msoLogger.debug("DoDeleteVfModuleFromVnf: AAI endPoint : " + endPoint) @@ -490,9 +494,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount) msoLogger.debug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) if (fqdnCount > 0) { // AII loop call over contrail network policy fqdn list @@ -503,10 +505,12 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { // Query AAI for this network policy FQDN - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri) + msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) int returnCode = response.getStatusCode() execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) @@ -528,8 +532,10 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + delUri.resourceVersion(resourceVersion) + String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri) + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) msoLogger.debug("invoking DELETE call to AAI") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index b1cef477be..03e47cf141 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -7,9 +7,9 @@ * 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. @@ -30,31 +30,35 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.constants.Defaults import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModuleVolumeV2.class); - + String prefix="DDVMV_" ExceptionUtil exceptionUtil = new ExceptionUtil() XmlParser xmlParser = new XmlParser() JsonUtils jsonUtil = new JsonUtils() - + @Override public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - preProcessRequest(execution, isDebugEnabled) + preProcessRequest(execution, isDebugEnabled) } - + /** * Set default variable values * @param execution * @param isDebugLogEnabled */ public void preProcessRequest (DelegateExecution execution, isDebugEnabled) { - + //Input: // msoRequestId // isDebugLogEnabled @@ -71,13 +75,13 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ // workflowException @TODO: actual variable name is WorkflowException // rolledBack // wasDeleted - + execution.setVariable('prefix', prefix) execution.setVariable('wasDeleted', 'false') - + def tenantId = execution.getVariable("tenantId") def cloudSiteId = execution.getVariable("lcpCloudRegionId") - + // if tenantId or lcpCloudregionId is not passed, get it from cloudRegionConfiguration variable if(!tenantId || !cloudSiteId) { def cloudConfiguration = execution.getVariable("cloudConfiguration") @@ -86,10 +90,12 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable("tenantId", tenantId) cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable("lcpCloudRegionId", cloudSiteId) + cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) } } - - + + /** * Set out 'wasDeleted' variable to 'true' * @param execution @@ -98,8 +104,8 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ public void postProcess(DelegateExecution execution, isDebugLogEnabled) { execution.setVariable('wasDeleted', 'true') } - - + + /** * Query and set cloud region to use for AAI calls * Output variables: prefix+'aicCloudRegion', prefix+'cloudRegion' @@ -107,14 +113,12 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ * @param isDebugEnabled */ public void callRESTQueryAAICloudRegion(DelegateExecution execution, isDebugEnabled) { - - String cloudRegion = execution.getVariable('lcpCloudRegionId') - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + + String cloudRegion = execution.getVariable('lcpCloudRegionId') AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug(queryCloudRegionRequest) - msoLogger.debug("AAI query cloud region URI - " + queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -125,14 +129,14 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ else{ execution.setVariable(prefix+"aicCloudRegion", cloudRegion) } - } + } else { msoLogger.debug("AAI Query Cloud Region Unsuccessful.") exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")) } } - - + + /** * Query AAI Volume Group * Output variables: prefix+'queryAAIVolGrpResponse'; prefix+'volumeGroupHeatStackId' @@ -140,9 +144,9 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ * @param isDebugLogEnabled */ public void callRESTQueryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) { - - def tenantId = execution.getVariable('tenantId') - def volumeGroupId = execution.getVariable('volumeGroupId') + + def tenantId = execution.getVariable('tenantId') + def volumeGroupId = execution.getVariable('volumeGroupId') if(volumeGroupId == null) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'volumeGroupId is not provided in the request') throw new Exception('volume-group-id is not provided in the request') @@ -150,8 +154,9 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) @@ -174,7 +179,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId) msoLogger.debug('Heat stack id from AAI response: ' + heatStackId) - + if(hasVfModuleRelationship(aaiResponseAsString)){ msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use') exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") @@ -182,12 +187,12 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) msoLogger.debug('Tenant ID from AAI response: ' + volumeGroupTenantId) - + if (volumeGroupTenantId == null) { msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") } - + if (volumeGroupTenantId != tenantId) { def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId msoLogger.debug("Error in DeleteVfModuleVolume: " + errorMessage) @@ -206,7 +211,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ } } } - + /** * Format VNF Adapter subflow request XML * Variables: prefix+'deleteVnfARequest' @@ -216,7 +221,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) { def cloudRegion = execution.getVariable(prefix+'aicCloudRegion') def tenantId = execution.getVariable('tenantId') // input parameter (optional) - see preProcessRequest - def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required) + def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required) def volumeGroupHeatStackId = execution.getVariable(prefix+'volumeGroupHeatStackId') // from AAI query volume group def requestId = execution.getVariable('msoRequestId') // input parameter (required) def serviceId = execution.getVariable('serviceInstanceId') // imput parameter (optional) @@ -247,30 +252,27 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable(prefix+'deleteVnfARequest', vnfAdapterRestRequest) msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) } - - + + /** * Delete volume group in AAI * @param execution * @param isDebugEnabled */ public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) { - + // get variables String queryAAIVolGrpIdResponse = execution.getVariable(prefix+"queryAAIVolGrpResponse") String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id") String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version") - + String messageId = UUID.randomUUID().toString() String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") - if(resourceVersion !=null){ - deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8') - } + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId).queryParam("resource-version", resourceVersion) + def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) msoLogger.debug("Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest) @@ -297,8 +299,8 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ } } } - - + + /** * Check if volume group has a relationship to vf-module * @param volumeGroupXml @@ -322,7 +324,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ return false } - + /** * Extract the Tenant Id from the Volume Group information returned by AAI. * @param volumeGroupXml Volume Group XML returned by AAI. diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy index 699e9bf40a..456a9cfabf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy @@ -27,12 +27,15 @@ import javax.xml.parsers.DocumentBuilderFactory import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.w3c.dom.Document @@ -80,8 +83,6 @@ class DoDeleteVnf extends AbstractServiceTaskProcessor { execution.setVariable("DoDVNF_vnfId", vnfId) msoLogger.debug("Incoming Vnf(Instance) Id is: " + vnfId) - // Setting for sub flow calls - execution.setVariable("DoDVNF_type", "generic-vnf") }catch(BpmnError b){ msoLogger.debug("Rethrowing MSOWorkflowException") throw b @@ -94,49 +95,42 @@ class DoDeleteVnf extends AbstractServiceTaskProcessor { } - public void processGetVnfResponse(DelegateExecution execution){ + public void getVnf(DelegateExecution execution){ execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED DoDeleteVnf processGetVnfResponse Process ") + msoLogger.trace("STARTED DoDeleteVnf getVnf Process ") try { - String vnf = execution.getVariable("DoDVNF_genericVnf") - String resourceVersion = utils.getNodeText(vnf, "resource-version") - execution.setVariable("DoDVNF_resourceVersion", resourceVersion) - - if(utils.nodeExists(vnf, "relationship")){ - InputSource source = new InputSource(new StringReader(vnf)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document vnfXml = docBuilder.parse(source) - - NodeList nodeList = vnfXml.getElementsByTagName("relationship") - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() - if(e.equals("volume-group") || e.equals("l3-network")){ - msoLogger.debug("Generic Vnf still has relationship to OpenStack.") - execution.setVariable("DoDVNF_vnfInUse", true) - }else{ - msoLogger.debug("Relationship NOT related to OpenStack") - } + + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + + if(resourceClient.exists(uri)){ + execution.setVariable("GENGV_FoundIndicator", true) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE)) + if(wrapper.getRelationships().isPresent()){ + List relationships = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + relationships.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK)) + if(!relationships.isEmpty()){ + execution.setVariable("DoDVNF_vnfInUse", true) + }else{ + msoLogger.debug("Relationship NOT related to OpenStack") } } - } - if(utils.nodeExists(vnf, "vf-module")){ - execution.setVariable("DoDVNF_vnfInUse", true) - msoLogger.debug("Generic Vnf still has vf-modules.") + Optional vnf = wrapper.asBean(GenericVnf.class) + if(!vnf.get().getVfModules().getVfModule().isEmpty()){ + execution.setVariable("DoDVNF_vnfInUse", true) + } + }else{ + execution.setVariable("GENGV_FoundIndicator", false) } - } catch (Exception ex) { - msoLogger.debug("Error Occured in DoDeleteVnf processGetVnfResponse Process " + ex.getMessage()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf processGetVnfResponse Process") + msoLogger.debug("Error Occured in DoDeleteVnf getVnf Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf getVnf Process") } - msoLogger.trace("COMPLETED DoDeleteVnf processGetVnfResponse Process ") + msoLogger.trace("COMPLETED DoDeleteVnf getVnf Process ") } /** diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index d448dd3e79..ddf2706635 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -39,6 +39,10 @@ import org.onap.so.bpmn.core.domain.ModuleResource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -255,10 +259,9 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) + msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy index cb50fbbee6..5b7fdb2c22 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy @@ -32,6 +32,11 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.springframework.web.util.UriUtils; import groovy.json.* @@ -269,11 +274,8 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("INFO","Entered " + method, isDebugEnabled) String msg = "" - utils.log("INFO"," ***** preProcessAAIPUT *****", isDebugEnabled) - String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion") - //execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion) //requestDetails.modelInfo.for AAI PUT servieInstanceData //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData @@ -285,71 +287,48 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceId(serviceInstanceId) + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(aaiServiceType) + si.setServiceRole(aaiServiceRole) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(modelUuid) - AaiUtil aaiUriUtil = new AaiUtil(this) - utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - utils.log("INFO","namespace: " + namespace, isDebugEnabled) - - //update target model to aai - String serviceInstanceData = - """ - ${MsoUtils.xmlEscape(serviceInstanceId)} - ${MsoUtils.xmlEscape(serviceInstanceName)} - ${MsoUtils.xmlEscape(aaiServiceType)} - ${MsoUtils.xmlEscape(aaiServiceRole)} - ${MsoUtils.xmlEscape(serviceInstanceVersion)} - ${MsoUtils.xmlEscape(modelInvariantUuid)} - ${MsoUtils.xmlEscape(modelUuid)} - """.trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled) - utils.logAudit(serviceInstanceData) - utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled) - utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) + execution.setVariable("serviceInstanceData", si) utils.log("INFO", "Exited " + method, isDebugEnabled) } - public void postProcessAAIPUT(DelegateExecution execution) { + public void updateServiceInstance(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled) + utils.log("INFO"," ***** createServiceInstance ***** ", isDebugEnabled) String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "serviceType", execution.getVariable("serviceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) - } + org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + client.update(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "serviceType", execution.getVariable("serviceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + + msg = "Exception in DoCreateServiceInstance.createServiceInstance. " + ex.getMessage() utils.log("INFO", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled) + utils.log("INFO"," *** Exit createServiceInstance *** ", isDebugEnabled) } public void preProcessRollback (DelegateExecution execution) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy index 257142e8bd..949a566711 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy @@ -25,9 +25,16 @@ import static org.apache.commons.lang3.StringUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MsoLogger import org.onap.so.bpmn.common.scripts.ExceptionUtil; import groovy.json.* @@ -210,61 +217,38 @@ public class DoUpdateE2EServiceInstanceRollback extends AbstractServiceTaskProce String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("model-version-id-original") - //AAI PUT - AaiUtil aaiUriUtil = new AaiUtil(this) - utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - utils.log("INFO","namespace: " + namespace, isDebugEnabled) - - String serviceInstanceData = - """ - ${MsoUtils.xmlEscape(serviceInstanceId)} - ${MsoUtils.xmlEscape(serviceInstanceName)} - ${MsoUtils.xmlEscape(aaiServiceType)} - ${MsoUtils.xmlEscape(aaiServiceRole)} - ${MsoUtils.xmlEscape(serviceInstanceVersion)} - ${MsoUtils.xmlEscape(modelInvariantUuid)} - ${MsoUtils.xmlEscape(modelUuid)} - """.trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - msoLogger.info("serviceInstanceData: " + serviceInstanceData) - msoLogger.debug(serviceInstanceData) - msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace) - msoLogger.info(" 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData) + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceId(serviceInstanceId) + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(aaiServiceType) + si.setServiceRole(aaiServiceRole) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(modelUuid) + + execution.setVariable("serviceInstanceData", si) msoLogger.info("Exited " + method) } - public void postProcessAAIPUT(DelegateExecution execution) { - msoLogger.trace("postProcessAAIPUT ") + public void updateServiceInstance(DelegateExecution execution) { + msoLogger.trace("updateServiceInstance ") String msg = "" try { String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - msoLogger.debug("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { + org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") - } + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + client.update(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + msg = "Exception in DoCreateServiceInstance.updateServiceInstance. " + ex.getMessage() msoLogger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.trace("Exit postProcessAAIPUT ") + msoLogger.trace("Exit updateServiceInstance ") } public void processRollbackException(DelegateExecution execution){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index d7f2087c05..dbacd48809 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts; +import javax.ws.rs.core.UriBuilder + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -33,17 +35,18 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils - -import org.onap.so.client.aai.AAIResourcesClient 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.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.json.JSONObject +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aai.domain.yang.RouteTarget import javax.ws.rs.NotFoundException import groovy.json.* @@ -352,16 +355,15 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { String networkInputs = execution.getVariable(Prefix + "networkInputs") String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") // Prepare AA&I url String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug(queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(" UPDNETI_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) @@ -407,10 +409,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkId", networkId) // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String queryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + msoLogger.debug(queryIdAAIRequest) execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest) @@ -474,10 +477,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String requeryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + msoLogger.debug(requeryIdAAIRequest) execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) msoLogger.debug(" UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest) @@ -557,93 +561,37 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "vpnCount", vpnCount) msoLogger.debug(" UPDNETI_vpnCount - " + vpnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - if (vpnCount > 0) { execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri) String routeTargets = "" // AII loop call using list vpnBindings - for (i in 0..vpnBindingUri.size()-1) { - + for(i in 0..vpnBindingUri.size()-1) { int counting = i+1 - // prepare url using vpnBinding - String queryVpnBindingAAIRequest = "" - String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) - - // Note: By default, the vpnBinding url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" - } - - } else { - // using uri value in URN mapping - String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) - if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { - vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) - } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" + String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) + if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { + vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) } - msoLogger.debug(queryVpnBindingAAIRequest) - execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - msoLogger.debug(" UPDNETI_queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) - msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - msoLogger.debug(aaiResponseAsString) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) - msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString) - - String routeTarget = "" - String routeRole = "" - if (utils.nodeExists(aaiResponseAsString, "route-targets")) { - String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) - def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) - def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} - for (j in 0..aaiRouteTarget.size()-1) { - routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") - routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") - routeTargets += "" + '\n' + - " " + routeTarget + "" + '\n' + - " " + routeRole + "" + '\n' + - "" + '\n' - } - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.TWO), NotFoundException.class) + + Optional binding = wrapper.asBean(VpnBinding.class) + + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "" + '\n' + + " " + routeTarget + "" + '\n' + + " " + routeRole + "" + '\n' + + "" + '\n' } } @@ -655,8 +603,8 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ @@ -670,9 +618,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } - } catch (BpmnError e) { - throw e; - + } catch (NotFoundException e) { + msoLogger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") } catch (Exception ex) { String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() msoLogger.debug(exceptionMessage) @@ -700,7 +648,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) msoLogger.debug(" UPDNETI_networkPolicyCount - " + networkPolicyCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) if (networkPolicyCount > 0) { @@ -713,31 +660,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 - // prepare url using vpnBinding - String queryNetworkPolicyAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) - println " networkPolicyId - " + networkPolicyId - if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { - networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) - } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" - - } + URI uri = UriBuilder.fromUri(networkPolicyUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.NETWORK_POLICY, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(aaiUri) msoLogger.debug(queryNetworkPolicyAAIRequest) execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) @@ -791,8 +718,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ @@ -850,30 +776,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 // prepare url using tableRef - String queryNetworkTableRefAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) - - if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { - networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) - } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" - - } + URI uri = UriBuilder.fromUri(networkTableRefUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ROUTE_TABLE_REFERENCE, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkTableRefAAIRequest = aaiUriUtil.createAaiUri(aaiUri) msoLogger.debug(queryNetworkTableRefAAIRequest) execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) @@ -927,8 +834,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ @@ -969,17 +875,17 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") // Prepare url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String updateContrailAAIUrlRequest = aaiUriUtil.createAaiUri(uri) msoLogger.debug(updateContrailAAIUrlRequest) execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) msoLogger.debug(" UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(updateContrailAAIUrlRequest) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) msoLogger.debug(payloadXml) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index 451e0293ef..bce19795ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -7,9 +7,9 @@ * 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. @@ -33,11 +33,15 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -111,56 +115,56 @@ public class DoUpdateVfModule extends VfModuleBase { def xml = getVariable(execution, 'DoUpdateVfModuleRequest') msoLogger.debug("DoUpdateVfModule request: " + xml) msoLogger.debug('Received request xml:\n' + xml) - + if (xml == null || xml.isEmpty()) { // Building Block-type request String cloudConfiguration = execution.getVariable("cloudConfiguration") String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - + def serviceModelInfo = execution.getVariable("serviceModelInfo") msoLogger.debug("serviceModelInfo: " + serviceModelInfo) String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid) def vnfModelInfo = execution.getVariable("vnfModelInfo") - + //tenantId def tenantId = execution.getVariable("tenantId") execution.setVariable("DOUPVfMod_tenantId", tenantId) - + //volumeGroupId def volumeGroupId = execution.getVariable("volumeGroupId") execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) - + //cloudSiteId def cloudSiteId = execution.getVariable("lcpCloudRegionId") execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId) - + msoLogger.debug("cloudSiteId: " + cloudSiteId) //vnfType def vnfType = execution.getVariable("vnfType") execution.setVariable("DOUPVfMod_vnfType", vnfType) - + msoLogger.debug("vnfType: " + vnfType) //vnfName def vnfName = execution.getVariable("vnfName") execution.setVariable("DOUPVfMod_vnfName", vnfName) - + msoLogger.debug("vnfName: " + vnfName) //vnfId def vnfId = execution.getVariable("vnfId") execution.setVariable("DOUPVfMod_vnfId", vnfId) - + msoLogger.debug("vnfId: " + vnfId) //vfModuleName def vfModuleName = execution.getVariable("vfModuleName") execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName) - + msoLogger.debug("vfModuleName: " + vfModuleName) //vfModuleModelName def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName) - + msoLogger.debug("vfModuleModelName: " + vfModuleModelName) //modelCustomizationUuid def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") @@ -168,7 +172,7 @@ public class DoUpdateVfModule extends VfModuleBase { modelCustomizationUuid = "" } execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) - + msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid) //vfModuleId def vfModuleId = execution.getVariable("vfModuleId") @@ -186,12 +190,12 @@ public class DoUpdateVfModule extends VfModuleBase { //serviceInstanceId def serviceInstanceId = execution.getVariable("serviceInstanceId") execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId) - + msoLogger.debug("serviceInstanceId: " + serviceInstanceId) //source - HARDCODED def source = "VID" execution.setVariable("DOUPVfMod_source", source) - + msoLogger.debug("source: " + source) //backoutOnFailure def disableRollback = execution.getVariable("disableRollback") @@ -239,16 +243,16 @@ public class DoUpdateVfModule extends VfModuleBase { String vnfQueryPath = execution.getVariable("vnfQueryPath") execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath) msoLogger.debug("vnfQueryPath: " + vnfQueryPath) - + Map vfModuleInputParams = execution.getVariable("vfModuleInputParams") if (vfModuleInputParams != null) { - execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) - } + execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) + } //get workload and environment context from parent SI String environmentContext = "" String workloadContext ="" String serviceType ="" - + try{ String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") @@ -259,7 +263,7 @@ public class DoUpdateVfModule extends VfModuleBase { msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - + try{ AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) AAIResourcesClient aaiRC = new AAIResourcesClient() @@ -267,11 +271,11 @@ public class DoUpdateVfModule extends VfModuleBase { Map aaiJson = aaiRW.asMap() environmentContext = aaiJson.getOrDefault("environment-context","") workloadContext = aaiJson.getOrDefault("workload-context","") - + }catch (Exception ex) { msoLogger.debug("Error retreiving parent service instance information") } - + execution.setVariable("DCVFM_environmentContext",environmentContext) execution.setVariable("DCVFM_workloadContext",workloadContext) } @@ -285,7 +289,7 @@ public class DoUpdateVfModule extends VfModuleBase { serviceInstanceId = '' } execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId) - + def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs') execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs) execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) @@ -306,14 +310,14 @@ public class DoUpdateVfModule extends VfModuleBase { execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) } msoLogger.debug("isBaseVfModule: " + isBaseVfModule) - + NetworkUtils networkUtils = new NetworkUtils() def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml) execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) - + def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id') execution.setVariable('DOUPVfMod_volumeGroupId', vgi) - + execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false)) } @@ -382,7 +386,7 @@ public class DoUpdateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + 'execution=' + execution.getId() + ')' - + def prefix = execution.getVariable("prefix") msoLogger.trace('Entered ' + method) @@ -391,14 +395,12 @@ public class DoUpdateVfModule extends VfModuleBase { String cloudRegion = execution.getVariable(prefix + "aicCloudRegion") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug("CloudRegion Request: " + queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion) @@ -427,9 +429,9 @@ public class DoUpdateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage()) } msoLogger.trace('Exited ' + method) - + } - + /** * Prepare a Request for invoking the SDNC Adapter subflow to perform * a VNF topology 'changeassign' operation. @@ -625,19 +627,19 @@ public class DoUpdateVfModule extends VfModuleBase { def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion') def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid') def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure") - + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) if ('true'.equals(useQualifiedHostName)) { notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) } - + String environmentContext = execution.getVariable("DOUPVEnvironment_context") String workloadContext = execution.getVariable("DOUPVWorkload_context") msoLogger.debug("workloadContext: " + workloadContext) msoLogger.debug("environmentContext: " + environmentContext) - + Map vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap") String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') @@ -791,7 +793,7 @@ public class DoUpdateVfModule extends VfModuleBase { ${personaModelCustomizationIdElement} """ - + msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest) updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest) @@ -846,7 +848,7 @@ public class DoUpdateVfModule extends VfModuleBase { if (!usePreload) { modelCustomizationUuidString = "" + modelCustomizationUuid + "" } - + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) @@ -974,10 +976,10 @@ public class DoUpdateVfModule extends VfModuleBase { def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index 6b42406883..afe01b9243 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -33,6 +33,11 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ModuleResource import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -152,10 +157,8 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy index 8673ee7662..f45e97fa6e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -190,6 +190,8 @@ public class ReplaceVnfInfra extends VnfCmBase { execution.setVariable('cloudConfiguration', cloudConfiguration) def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def cloudOwner = jsonUtils.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable('cloudOwner', cloudOwner) def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId") execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy index 416d0d6e60..566afb0d9c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy @@ -175,6 +175,10 @@ public class UpdateVfModuleInfra extends AbstractServiceTaskProcessor { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable(prefix + 'cloudOwner', cloudOwner) + def tenantId = cloudConfiguration.tenantId execution.setVariable(prefix + 'tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy index a926030924..0972ee184e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy @@ -191,6 +191,10 @@ public class UpdateVfModuleInfraV2 { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable(prefix + 'cloudOwner', cloudOwner) + def tenantId = cloudConfiguration.tenantId execution.setVariable(prefix + 'tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index 7b2d1b78e4..ce93db522e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -7,9 +7,9 @@ * 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. @@ -30,6 +30,10 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase; import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -39,10 +43,10 @@ import groovy.json.JsonSlurper class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolumeInfraV1.class); - + /** * Initialize the flow's variables. - * + * * @param execution The flow's execution instance. */ private void initProcessVariables(DelegateExecution execution) { @@ -62,7 +66,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_volumeGroupTenantId', null) execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false) } - + /** * Perform initial processing, such as request validation, initialization of variables, etc. @@ -72,33 +76,33 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") preProcessRequest(execution, isDebugEnabled) } - + public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) { initProcessVariables(execution) String jsonRequest = validateRequest(execution) - + def request = "" - + try { def jsonSlurper = new JsonSlurper() Map reqMap = jsonSlurper.parseText(jsonRequest) - + def serviceInstanceId = execution.getVariable('serviceInstanceId') def volumeGroupId = execution.getVariable('volumeGroupId') //def vnfId = execution.getVariable('vnfId') - + def vidUtils = new VidUtils(this) request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId) - + execution.setVariable('UPDVfModVol_Request', request) execution.setVariable("UPDVfModVol_isVidRequest", true) - + //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI - + def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: '' execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId) - + msoLogger.debug("modelInvariantId from request: " + modelInvariantId) msoLogger.debug("XML request:\n" + request) } @@ -106,15 +110,15 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { msoLogger.debug(" Request is in XML format.") // assume request is in XML format - proceed as usual to process XML request } - + def requestId = execution.getVariable('mso-request-id') - + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') execution.setVariable('UPDVfModVol_requestInfo', requestInfo) execution.setVariable('UPDVfModVol_requestId', requestId) //execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source')) - + def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs') execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs) execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id')) @@ -126,14 +130,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id')) setBasicDBAuthHeader(execution, isDebugLogEnabled) - + def volumeParams = utils.getNodeXml(request, 'volume-params') execution.setVariable('UPDVfModVol_volumeParams', volumeParams) } /** * Prepare and send the synchronous response. - * + * * @param execution The flow's execution instance. */ public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) { @@ -150,7 +154,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { startTime = System.currentTimeMillis() } def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') - + String xmlSyncResponse = """ @@ -167,20 +171,20 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def syncResponse = '' def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest') - + if(isVidRequest) { def volumeGroupId = execution.getVariable('volumeGroupId') syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() - } + } else { syncResponse = utils.formatXml(xmlSyncResponse) } - + msoLogger.debug('Sync response: ' + syncResponse) execution.setVariable('UPDVfModVol_syncResponseSent', true) sendWorkflowResponse(execution, 200, syncResponse) } - + /** * Prepare a Request for querying AAI for Volume Group information using the * Volume Group Id and Aic Cloud Region. @@ -192,31 +196,32 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(aicCloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") - + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri) + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query volume group by id return code: " + returnCode) msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString) - + msoLogger.debug("AAI Volume Group return code: " + returnCode) msoLogger.debug("AAI Volume Group response: " + aaiResponseAsString) - + ExceptionUtil exceptionUtil = new ExceptionUtil() - + if ((returnCode == '200') || (returnCode == '204')) { - + execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', aaiResponseAsString) //def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id') //execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId) - + def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) if (volumeGroupTenantId == null) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId @@ -228,42 +233,42 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def relatedVfModuleLink = getRelatedVfModuleRelatedLink(aaiResponseAsString) msoLogger.debug("Related VF Module link: " + relatedVfModuleLink) execution.setVariable('UPDVfModVol_relatedVfModuleLink', relatedVfModuleLink) - - } + + } else if (returnCode == '404') { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI") - } + } else { WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) throw new BpmnError("MSOWorkflowException") } } - + /** * Query AAI service instance * @param execution * @param isDebugEnabled */ public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) { - + def vnfId = execution.getVariable('vnfId') - + AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) - def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + String queryAAIRequest = aaiUtil.createAaiUri(uri) msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query generic vnf return code: " + returnCode) msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString) ExceptionUtil exceptionUtil = new ExceptionUtil() - + if (returnCode=='200') { msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.') execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', aaiResponseAsString) @@ -278,40 +283,40 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { } } } - + /** * Query AAI for VF Module using vf-module-id * @param execution * @param isDebugLogEnabled */ public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) { - + AaiUtil aaiUtil = new AaiUtil(this) String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink') execution.setVariable('UPDVfModVol_personaModelId', '') - + msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest) msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest) - + def aaiUrl = UrnPropertiesReader.getVariable("aai.endpoint", execution) msoLogger.debug('A&AI URL: ' + aaiUrl) - + def requestEndpoint = aaiUrl + queryAAIVfModuleRequest msoLogger.debug('A&AI request endpoint: ' + requestEndpoint) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query vf-module: " + returnCode) msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString) - + msoLogger.debug("AAI query vf-module:: " + returnCode) msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString) - + ExceptionUtil exceptionUtil = new ExceptionUtil() - + if ((returnCode == '200') || (returnCode == '204')) { def personaModelId = utils.getNodeText(aaiResponseAsString, 'model-invariant-id') if(personaModelId == null) { @@ -330,14 +335,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { } } /** - * + * */ public String getRelatedVfModuleRelatedLink(xml) { def list = new XmlSlurper().parseText(xml) def vfModuleRelationship = list.'**'.find { node -> node.'related-to'.text() == 'vf-module' } return vfModuleRelationship?.'related-link'?.text() ?: '' } - + /** * Prepare a Request for invoking the VnfAdapterRest subflow to do * a Volume Group update. @@ -345,11 +350,11 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { * @param execution The flow's execution instance. */ public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) { - + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') def tenantId = execution.getVariable('UPDVfModVol_tenantId') def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') - + def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse') def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id') def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name') @@ -358,21 +363,21 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { // Check old attribute name modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-persona-model-customization-id') } - + def vnfType = execution.getVariable('UPDVfModVol_vnfType') def vnfVersion = execution.getVariable('UPDVfModVol_vnfVersion') - + def aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse') def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id') def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name') - + def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams') def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml) - + def requestId = execution.getVariable('UPDVfModVol_requestId') def serviceId = execution.getVariable('UPDVfModVol_serviceId') - + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) @@ -425,7 +430,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest) msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) } - + /** * Prepare a Request for updating the DB for this Infra request. * @@ -435,7 +440,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def requestId = execution.getVariable('UPDVfModVol_requestId') ExceptionUtil exceptionUtil = new ExceptionUtil(); - + String updateInfraRequest = """ @@ -455,7 +460,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest) msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) } - + /** * Build a "CompletionHandler" request. * @param execution The flow's execution instance. @@ -471,14 +476,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { ${MsoUtils.xmlEscape(source)} BPMN VF Module Volume action: UPDATE - + """ content = utils.formatXml(content) msoLogger.debug('Request for Completion Handler:\n' + content) execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content) } - + /** * Build a "FalloutHandler" request. @@ -487,14 +492,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) { def requestId = execution.getVariable('UPDVfModVol_requestId') def source = execution.getVariable('UPDVfModVol_source') - + String requestInfo = """ ${MsoUtils.xmlEscape(requestId)} UPDATE ${MsoUtils.xmlEscape(source)} """ - + def WorkflowException workflowException = execution.getVariable("WorkflowException") def errorResponseCode = workflowException.getErrorCode() def errorResponseMsg = workflowException.getErrorMessage() @@ -507,55 +512,55 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { + xmlns:structuredtypes="http://org.onap/so/structured/types/v1"> ${requestInfo} ${MsoUtils.xmlEscape(encErrorResponseMsg)} ${MsoUtils.xmlEscape(errorResponseCode)} - + """ content = utils.formatXml(content) msoLogger.debug('Request for Fallout Handler:\n' + content) execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content) } - + /** * Create a WorkflowException for the error case where the Tenant Id from * AAI did not match the Tenant Id in the incoming request. * @param execution The flow's execution instance. */ public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) { - + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') def tenantId = execution.getVariable('UPDVfModVol_tenantId') def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId') - + def String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId + - " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion - + " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion + ExceptionUtil exceptionUtil = new ExceptionUtil() msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } - + /** * Create a WorkflowException for the error case where the Personal Model Id from * AAI did not match the model invariant ID in the incoming request. * @param execution The flow's execution instance. */ public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) { - + def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId') def personaModelId = execution.getVariable('UPDVfModVol_personaModelId') - + def String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId + " retrieved from AAI for Volume Group Id " - + ExceptionUtil exceptionUtil = new ExceptionUtil() msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } - + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy index f251dc46f8..548f521c33 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -170,6 +170,8 @@ public class UpdateVnfInfra extends VnfCmBase { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def cloudOwner = jsonUtils.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable('cloudOwner', cloudOwner) def tenantId = cloudConfiguration.tenantId execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 68d5c19b80..2c1b66ded5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -143,6 +143,8 @@ public class VnfInPlaceUpdate extends VnfCmBase { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable('cloudOwner', cloudOwner) def tenantId = cloudConfiguration.tenantId execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 85993d6c92..8a3dcbab5d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -146,6 +146,9 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { String lcpCloudRegionId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) msoLogger.debug("lcpCloudRegionId: "+ lcpCloudRegionId) + String cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) + msoLogger.debug("cloudOwner: "+ cloudOwner) String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") execution.setVariable("tenantId", tenantId) msoLogger.debug("tenantId: "+ tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java index c04c2dc15b..6062129a71 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java @@ -70,7 +70,7 @@ public class AAICreateResources { AAIResourcesClient aaiRC = new AAIResourcesClient(); return aaiRC.get(OwningEntities.class, AAIUriFactory - .createResourceUri(AAIObjectPlurals.OWNING_ENTITIES) + .createResourceUri(AAIObjectPlurals.OWNING_ENTITY) .queryParam("owning-entity-name", owningEntityName)) .orElseGet(() -> { msoLogger.debug("No Owning Entity matched by name"); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 5fe28b918b..e753f79ebd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -28,6 +28,8 @@ 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; @@ -45,17 +47,27 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.runtime.Execution; +import org.onap.aai.domain.yang.LogicalLink; +import org.onap.aai.domain.yang.LogicalLinks; +import org.onap.aai.domain.yang.PInterface; import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.bpmn.core.domain.ServiceDecomposition; import org.onap.so.bpmn.core.domain.Resource; +import org.onap.so.bpmn.core.domain.ServiceDecomposition; import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +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.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.bpmn.common.scripts.AaiUtil; +import org.springframework.web.util.UriUtils; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.springframework.web.util.UriUtils; public class ServicePluginFactory { @@ -307,8 +319,7 @@ public class ServicePluginFactory { @SuppressWarnings("unchecked") private void allocateCrossTPResources(DelegateExecution execution, Map serviceRequestInputs) { - AaiUtil aai = new AaiUtil(); - Map crossTPs = aai.getTPsfromAAI(execution); + Map crossTPs = this.getTPsfromAAI(); if(crossTPs == null || crossTPs.isEmpty()) { serviceRequestInputs.put("local-access-provider-id", ""); @@ -338,6 +349,106 @@ public class ServicePluginFactory { return; } + // This method returns Local and remote TPs information from AAI + public Map getTPsfromAAI() { + Map tpInfo = new HashMap<>(); + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK); + AAIResourcesClient client = new AAIResourcesClient(); + Optional 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 optRelationships = wrapper.getRelationships(); + List pInterfaces = new ArrayList<>(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + if (!relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty()) { + isRemoteLink = true; + } + pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE)); + } + + if (isRemoteLink) { + // find remote p interface + AAIResourceUri localTP = null; + AAIResourceUri remoteTP = null; + + AAIResourceUri pInterface0 = pInterfaces.get(0); + + if (isRemotePInterface(client, pInterface0)) { + remoteTP = pInterfaces.get(0); + localTP = pInterfaces.get(1); + } else { + localTP = pInterfaces.get(0); + remoteTP = pInterfaces.get(1); + } + + if (localTP != null && remoteTP != null) { + // give local tp + 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]); + tpInfo.put("local-access-client-id", networkRef[3]); + tpInfo.put("local-access-topology-id", networkRef[5]); + } + String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + 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(); + tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]); + + String[] networkRefRemote = intfRemote.getNetworkRef().split("/"); + + if (networkRefRemote.length == 6) { + tpInfo.put("remote-access-provider-id", networkRefRemote[1]); + tpInfo.put("remote-access-client-id", networkRefRemote[3]); + tpInfo.put("remote-access-topology-id", networkRefRemote[5]); + } + String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStrR.contains("-")) { + tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + return tpInfo; + } + } + } + } + return tpInfo; + } + + // this method check if pInterface is remote + private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) { + + Map keys = uri.getURIKeys(); + String uriString = uri.build().toString(); + AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, keys.get("pnf-name")); + + AAIResultWrapper wrapper = client.get(parent); + Optional optRelationships = wrapper.getRelationships(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + + return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty(); + } + + return false; + } + public String preProcessService(ServiceDecomposition serviceDecomposition, String uuiRequest) { // now only for sotn diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy index 4d5f506599..2f07842cb6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy @@ -85,6 +85,7 @@ class CreateNetworkInstanceTest { VID Network has been created successfully. + fb03f6f0-9012-41c4-87d8-1dbf3c22b889 BPMN Network action: CREATE """ @@ -272,6 +273,7 @@ String jsonIncomingRequest = when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable(Prefix + "dbReturnCode")).thenReturn("200") + when(mockExecution.getVariable("networkId")).thenReturn("fb03f6f0-9012-41c4-87d8-1dbf3c22b889") // postProcessResponse(DelegateExecution execution) CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy index 72f79c80d9..d8a82acfa7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -76,7 +76,6 @@ class DoCreateE2EServiceInstanceTest { when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') DoCreateE2EServiceInstance obj = new DoCreateE2EServiceInstance() obj.preProcessRequest(mockExecution) Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy index cc6f89865f..587abbee52 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -83,7 +83,6 @@ class DoCreateServiceInstanceTest { when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') DoCreateServiceInstance obj = new DoCreateServiceInstance() @@ -93,7 +92,7 @@ class DoCreateServiceInstanceTest { verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:28080/mso/SDNCAdapterCallbackService") } - + @Test void testGetAAICustomerById() { @@ -101,7 +100,6 @@ class DoCreateServiceInstanceTest { when(mockExecution.getVariable("prefix")).thenReturn(prefix) when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn("/aai/v9/business/customers/customer") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8') diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy index fcb0fb0940..447463a079 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -85,7 +85,7 @@ class DoDeleteVfModuleFromVnfTest { Mockito.verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:8090/SDNCAdapterCallback") } - + @Test void testDeleteNetworkPoliciesFromAAI() { @@ -106,7 +106,7 @@ class DoDeleteVfModuleFromVnfTest { Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) } - + @Test void testQueryAAIForVfModule() { ExecutionEntity mockExecution = setupMock() @@ -115,7 +115,6 @@ class DoDeleteVfModuleFromVnfTest { when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("mso.workflow.global.default.aai.namespace") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") @@ -126,7 +125,7 @@ class DoDeleteVfModuleFromVnfTest { Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 200) } - + private ExecutionEntity setupMock() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy index beaebceaf7..67b1c23ae1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -77,7 +77,7 @@ class DoUpdateVfModuleTest { Mockito.verify(mockExecution, atLeastOnce()).getVariable("mso.workflow.sdncadapter.callback") } - + @Test void testPrepConfirmVolumeGroupTenant() { @@ -100,7 +100,7 @@ class DoUpdateVfModuleTest { Mockito.verify(mockExecution).setVariable(prefix + "isCloudRegionGood", true) } - + @Test void testPrepSDNCTopologyChg() { ExecutionEntity mockExecution = setupMock() @@ -148,7 +148,7 @@ class DoUpdateVfModuleTest { XmlComparator.assertXMLEquals(sdncChangeAssignRequest, captor.getValue()) } - + @Test void testPrepSDNCTopologyQuery() { @@ -168,7 +168,7 @@ class DoUpdateVfModuleTest { XmlComparator.assertXMLEquals(sdncTopologyRequest, captor.getValue()) } - + @Test void testPrepVnfAdapterRest() { @@ -219,7 +219,7 @@ class DoUpdateVfModuleTest { XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl") } - + @Test void testPrepSDNCTopologyAct() { @@ -263,7 +263,6 @@ class DoUpdateVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy index ba54787dc1..a86029ea30 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -61,7 +61,7 @@ class DoUpdateVnfAndModulesTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("vnfId")).thenReturn("12345") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") @@ -78,7 +78,7 @@ class DoUpdateVnfAndModulesTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("vnfId")).thenReturn("12345") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy index 523c791efc..84da045450 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -576,6 +576,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") } @@ -594,6 +595,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") } @@ -612,6 +614,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy index b7c754938a..c2384b63a5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy @@ -145,6 +145,7 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("subscriptionServiceType", SVC) verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration")) verify(mex).setVariable("sdncVersion", "1707") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml index 96cdebcc1e..78ecd6ce88 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml +++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml @@ -1,334 +1,287 @@ -aai: - auth: 757A94191D685FD2092AC1490730A4FC - dme2: - timeout: '30000' - endpoint: http://localhost:${wiremock.server.port} -camunda: - bpm: - admin-user: - id: admin - password: admin - database: - type: h2 - history-level: FULL - metrics: - enabled: false - db-reporter-activate: false -canopi: - auth: 757A94191D685FD2092AC1490730A4FC -csi: - aots: - addincidentmanagement: - endpoint: http://localhost:${wiremock.server.port}/AddIncidentManagementTicketRequest - networkstatus: - endpoint: http://localhost:${wiremock.server.port}/SendManagedNetworkStatusNotification -entitymanager: - packagesToScan: com -mso: - correlation: - timeout: PT60S - logPath: logs - async: - core-pool-size: 50 - max-pool-size: 50 - queue-capacity: 500 - adapters: - completemsoprocess: - endpoint: http://localhost:30253/CompleteMsoProcess - db: - auth: 757A94191D685FD2092AC1490730A4FC - password: wLg4sjrAFUS8rfVfdvTXeQ== - endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter - spring: - endpoint: http://localhost:${wiremock.server.port} - network: - endpoint: http://localhost:30253/services/NetworkAdapter - rest: - endpoint: http://localhost:30253/services/rest/v1/networks - openecomp: - db: - endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter - po: - auth: 757A94191D685FD2092AC1490730A4FC - password: 3141634BF7E070AA289CF2892C986C0B - sdnc: - endpoint: http://localhost:${wiremock.server.port}/adapters/SDNCAdapter - rest: - endpoint: http://localhost:${wiremock.server.port}/adapters/rest/v1/sdnc - timeout: PT150S - tenant: - endpoint: http://localhost:30253/services/TenantAdapter - vnf: - endpoint: http://localhost:${wiremock.server.port}/services/VnfAdapter - rest: - endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs - volume-groups: - rest: - endpoint: http://localhost:30253/services/rest/v1/volume-groups - vnf-async: - endpoint: http://localhost:30253/services/VnfAdapterAsync - adiod: - vce: - service: - model: - invariant: - uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8 - version: '5.0' - bpmn: - process: - historyTimeToLive: '30' - callbackRetryAttempts: '5' - catalog: - db: - endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog - spring: - endpoint: http://localhost:30258 - csi: - pwd: 4EA237303511EFBBC37F17A351562131 - sendmanagednetworkstatusnotification: - applicationname: NetworkManagementEthernetOverFiber - version: '212' - usrname: mso - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= - default: - adapter: - namespace: http://com.att.mso - gateway: - service: - model: - name: HNGWaaS for DHV Test - healthcheck: - log: - debug: 'false' - infra: - customer: - id: testCustIdInfra - msoKey: 07a7159d3bf51a0e53be7a8f89699be7 - oam: - network: - role: - gateway: HngwOamNetVto.OAM - portal: HnportalOamNetVto.OAM - po: - timeout: PT60S - portal: - service: - model: - name: HNPortalaaS for DHV Test - request: - db: - endpoint: http://localhost:${wiremock.server.port}/ - rollback: 'true' - sdnc: - firewall: - yang: - model: - version: '2015-05-15' - password: 3141634BF7E070AA289CF2892C986C0B - timeout: - firewall: - minutes: '20' - ucpe: - async: - hours: '120' - minutes: '5' - site-name: CamundaEngine - sriov: - network: - role: - gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1 - gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2 - portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1 - portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2 - workflow: - sdnc: - replication: - delay: PT5S - aai: - distribution: - delay: PT5S - CreateGenericVNFV1: - aai: - volume-group: - uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group - DHVCreateService: - aai: - customer: - uri: /aai/v9/business/customers/customer - createvce: - delay: - seconds: '1' - default: - aai: - version: '8' - cloud-region: - version: '9' - generic-vnf: - version: '9' - v11: - customer: - uri: /aai/v11/business/customers/customer - generic-query: - uri: /aai/v11/search/generic-query - generic-vnf: - uri: /aai/v11/network/generic-vnfs/generic-vnf - l3-network: - uri: /aai/v11/network/l3-networks/l3-network - network-policy: - uri: /aai/v11/network/network-policies/network-policy - nodes-query: - uri: /aai/v11/search/nodes-query - route-table-reference: - uri: /aai/v11/network/route-table-references/route-table-reference - tenant: - uri: /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v11/network/vces/vce - vpn-binding: - uri: /aai/v11/network/vpn-bindings/vpn-binding - v8: - configuration: - uri: /aai/v11/network/configurations/configuration - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf - retry: - attempts: '1' - deleteCinderVolumeV1: - aai: - volume-group: - uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group - global: - default: - aai: - namespace: http://org.openecomp.aai.inventory/ - l3ToHigherLayerAddBonding: - model: - invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc - name: WAN Bonding v0.1 - version: '0.1' - versionid: 52dbec20-47aa-42e4-936c-331d8e350d44 - message: - endpoint: http://localhost:30252/mso/WorkflowMessage - notification: - name: GenericNotificationServiceATT - sdncadapter: - callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService - vnfadapter: - create: - callback: http://localhost:30253/mso/vnfAdapterNotify - delete: - callback: http://localhost:30253/mso/vnfAdapterNotify - query: - callback: http://localhost:30253/mso/vnfAdapterNotify - rollback: - callback: http://localhost:30253/mso/vnfAdapterNotify -policy: - auth: Basic dGVzdHBkcDphbHBoYTEyMw== - client: - auth: Basic bTAzNzQzOnBvbGljeVIwY2sk - endpoint: https://localhost:8081/pdp/api/ - environment: TEST -sdnc: - auth: Basic YWRtaW46YWRtaW4= - host: https://localhost:8443 - path: /restconf/operations/GENERIC-RESOURCE-API -sdno: - health-check: - dmaap: - password: eHQ1cUJrOUc - publisher: - topic: com.att.sdno.test-health-diagnostic-v02 - subscriber: - topic: com.att.sdno.test-health-diagnostic-v02 - username: testuser -pnf: - dmaap: - host: - port: -sniro: - conductor: - host: http://localhost:30253 - uri: /release - manager: - timeout: PT30M - host: http://localhost:${wiremock.server.port} - uri.v1: /sniro/api/v2/placement - uri.v2: /sniro/api/placement/v2 - headers.auth: Basic dGVzdDp0ZXN0cHdk - headers.patchVersion: 1 - headers.minorVersion: 1 - headers.latestVersion: 2 -server: - port: 8080 - tomcat: - max-threads: 50 - # ssl: - # key-store: /app/msoClientKeyStore.jks - # key-store-password: mso4you - # key-store-type: JKS - # trust-store: /app/msoTrustStore.jks - # trust-store-password: mso_Domain2.0_4you -spring: - h2: - console: - enabled: true - path: /h2 - datasource: - url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE - username: sa - password: sa - driverClassName: org.h2.Driver - security: - usercredentials: - - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPMN-Client -# Hibernate -hibernate: - dialect: org.hibernate.dialect.MySQL5Dialect - show_sql: false - -management: - security: - enabled: false - -security: - basic: - enabled: false - -appc: - client: - topic: - read: - name: APPC-TEST-AMDOCS2 - timeout: 360000 - write: APPC-TEST-AMDOCS1-IST - response: - timeout: 360000 - key: LSl8QKolmKcC0yJR - secret: lgjXraD1HutKxv8jEN6tVouu - service: ueb +aai: + auth: 757A94191D685FD2092AC1490730A4FC + dme2: + timeout: '30000' + endpoint: http://localhost:${wiremock.server.port} +camunda: + bpm: + admin-user: + id: admin + password: admin + database: + type: h2 + history-level: FULL + metrics: + enabled: false + db-reporter-activate: false +canopi: + auth: 757A94191D685FD2092AC1490730A4FC +csi: + aots: + addincidentmanagement: + endpoint: http://localhost:${wiremock.server.port}/AddIncidentManagementTicketRequest + networkstatus: + endpoint: http://localhost:${wiremock.server.port}/SendManagedNetworkStatusNotification +entitymanager: + packagesToScan: com +mso: + correlation: + timeout: PT60S + logPath: logs + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + adapters: + completemsoprocess: + endpoint: http://localhost:30253/CompleteMsoProcess + db: + auth: 757A94191D685FD2092AC1490730A4FC + password: wLg4sjrAFUS8rfVfdvTXeQ== + endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter + spring: + endpoint: http://localhost:${wiremock.server.port} + network: + endpoint: http://localhost:30253/services/NetworkAdapter + rest: + endpoint: http://localhost:30253/services/rest/v1/networks + openecomp: + db: + endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter + po: + auth: 757A94191D685FD2092AC1490730A4FC + password: 3141634BF7E070AA289CF2892C986C0B + sdnc: + endpoint: http://localhost:${wiremock.server.port}/adapters/SDNCAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/adapters/rest/v1/sdnc + timeout: PT150S + tenant: + endpoint: http://localhost:30253/services/TenantAdapter + vnf: + endpoint: http://localhost:${wiremock.server.port}/services/VnfAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs + volume-groups: + rest: + endpoint: http://localhost:30253/services/rest/v1/volume-groups + vnf-async: + endpoint: http://localhost:30253/services/VnfAdapterAsync + adiod: + vce: + service: + model: + invariant: + uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8 + version: '5.0' + bpmn: + process: + historyTimeToLive: '30' + callbackRetryAttempts: '5' + catalog: + db: + endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog + spring: + endpoint: http://localhost:30258 + csi: + pwd: 4EA237303511EFBBC37F17A351562131 + sendmanagednetworkstatusnotification: + applicationname: NetworkManagementEthernetOverFiber + version: '212' + usrname: mso + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + default: + adapter: + namespace: http://com.att.mso + gateway: + service: + model: + name: HNGWaaS for DHV Test + healthcheck: + log: + debug: 'false' + infra: + customer: + id: testCustIdInfra + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + oam: + network: + role: + gateway: HngwOamNetVto.OAM + portal: HnportalOamNetVto.OAM + po: + timeout: PT60S + portal: + service: + model: + name: HNPortalaaS for DHV Test + request: + db: + endpoint: http://localhost:${wiremock.server.port}/ + rollback: 'true' + sdnc: + firewall: + yang: + model: + version: '2015-05-15' + password: 3141634BF7E070AA289CF2892C986C0B + timeout: + firewall: + minutes: '20' + ucpe: + async: + hours: '120' + minutes: '5' + site-name: CamundaEngine + sriov: + network: + role: + gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1 + gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2 + portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1 + portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2 + workflow: + sdnc: + replication: + delay: PT5S + aai: + distribution: + delay: PT5S + CreateGenericVNFV1: + aai: + volume-group: + uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group + DHVCreateService: + aai: + customer: + uri: /aai/v9/business/customers/customer + createvce: + delay: + seconds: '1' + default: + aai: + version: '8' + cloud-region: + version: '9' + generic-vnf: + version: '9' + retry: + attempts: '1' + deleteCinderVolumeV1: + aai: + volume-group: + uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group + global: + default: + aai: + namespace: http://org.openecomp.aai.inventory/ + l3ToHigherLayerAddBonding: + model: + invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc + name: WAN Bonding v0.1 + version: '0.1' + versionid: 52dbec20-47aa-42e4-936c-331d8e350d44 + message: + endpoint: http://localhost:30252/mso/WorkflowMessage + notification: + name: GenericNotificationServiceATT + sdncadapter: + callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService + vnfadapter: + create: + callback: http://localhost:30253/mso/vnfAdapterNotify + delete: + callback: http://localhost:30253/mso/vnfAdapterNotify + query: + callback: http://localhost:30253/mso/vnfAdapterNotify + rollback: + callback: http://localhost:30253/mso/vnfAdapterNotify +policy: + auth: Basic dGVzdHBkcDphbHBoYTEyMw== + client: + auth: Basic bTAzNzQzOnBvbGljeVIwY2sk + endpoint: https://localhost:8081/pdp/api/ + environment: TEST +sdnc: + auth: Basic YWRtaW46YWRtaW4= + host: https://localhost:8443 + path: /restconf/operations/GENERIC-RESOURCE-API +sdno: + health-check: + dmaap: + password: eHQ1cUJrOUc + publisher: + topic: com.att.sdno.test-health-diagnostic-v02 + subscriber: + topic: com.att.sdno.test-health-diagnostic-v02 + username: testuser +pnf: + dmaap: + host: + port: +sniro: + conductor: + host: http://localhost:30253 + uri: /release + manager: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri.v1: /sniro/api/v2/placement + uri.v2: /sniro/api/placement/v2 + headers.auth: Basic dGVzdDp0ZXN0cHdk + headers.patchVersion: 1 + headers.minorVersion: 1 + headers.latestVersion: 2 +server: + port: 8080 + tomcat: + max-threads: 50 + # ssl: + # key-store: /app/msoClientKeyStore.jks + # key-store-password: mso4you + # key-store-type: JKS + # trust-store: /app/msoTrustStore.jks + # trust-store-password: mso_Domain2.0_4you +spring: + h2: + console: + enabled: true + path: /h2 + datasource: + url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: sa + driverClassName: org.h2.Driver + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPMN-Client +# Hibernate +hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + show_sql: false + +management: + security: + enabled: false + +security: + basic: + enabled: false + +appc: + client: + topic: + read: + name: APPC-TEST-AMDOCS2 + timeout: 360000 + write: APPC-TEST-AMDOCS1-IST + response: + timeout: 360000 + key: LSl8QKolmKcC0yJR + secret: lgjXraD1HutKxv8jEN6tVouu + service: ueb poolMembers: localhost:3904,localhost:3904,localhost:3904 \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn index 9b21b9309f..b35aa80b83 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn @@ -30,6 +30,7 @@ networkMod.processJavaException(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn index 3b49011c3e..7413e6df83 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn @@ -505,6 +505,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceBRG(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn index 06c517c12d..bfbdc25f18 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn @@ -475,6 +475,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceTXC(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn index eefc2ca12c..150d50232a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -32,6 +32,7 @@ + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn index dcdcdc9d26..c1e60ba46b 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -154,6 +154,7 @@ createVfModuleVolumeInfraV1.executeMethod('buildWorkflowException', execution, 2 + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn index 6af8c2248e..d7d4561364 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn @@ -37,6 +37,7 @@ createVnf.sendSyncResponse(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn index a62e16525d..827dfb034d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn @@ -30,6 +30,7 @@ networkMod.processJavaException(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn index 0d287ebca4..fd0d8ff27a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn @@ -240,6 +240,7 @@ DeleteVcpeResCustService.getServiceInstance(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn index 6a157eb7c0..25b4f5de7f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn @@ -362,6 +362,7 @@ uvfm.prepDoCreateVnfAndModules(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn index e5236f92bf..50600bd49f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn @@ -30,6 +30,7 @@ networkMod.processJavaException(execution) + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn index c35e7ece96..3c5fff2d24 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn @@ -122,6 +122,7 @@ uvfm.falloutHandlerPrep(execution, 'UPDVfModI_FalloutHandlerRequest') + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn index 1efb127e33..8d30679849 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn @@ -164,6 +164,7 @@ uvfm.vfFlagSet(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn index e50eb7f805..71fc966233 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn @@ -142,6 +142,7 @@ uvfm.postProcessRollback(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn index 9cf21ddc52..01040ba914 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1qiiycn @@ -12,21 +12,6 @@ def dcsi = new DoCreateE2EServiceInstance() dcsi.preProcessRequest(execution) ]]> - - - - - - - - - - - - SequenceFlow_1i7t9hq - SequenceFlow_129ih1g - - SequenceFlow_0tgrn11 @@ -67,51 +52,17 @@ dcsi.postProcessRollback(execution) - - SequenceFlow_129ih1g + + SequenceFlow_012h7yx SequenceFlow_1tkgqu3 +ddsi.createServiceInstance(execution)]]> - - - SequenceFlow_1e5j351 - SequenceFlow_1qctzm0 - - - - - - - ${CVFMI_dbAdapterEndpoint} - - - application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk - - - ${CVFMI_initResOperStatusRequest} - POST - ${statusCode} - ${response} - - http-connector - - - SequenceFlow_1qctzm0 - SequenceFlow_1s5aas9 - SequenceFlow_0w9t6tc - - SequenceFlow_012h7yx - - SequenceFlow_0xjwb45 SequenceFlow_012h7yx @@ -152,17 +103,41 @@ dcsi.prepareDecomposeService(execution)]]> - - SequenceFlow_1i7t9hq - - - - SequenceFlow_1hbesp9 + SequenceFlow_0yuzaen - - + + + SequenceFlow_1y9rkfr + SequenceFlow_0n7nbx3 + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0n7nbx3 + SequenceFlow_0ckto7v + + @@ -180,71 +155,62 @@ dcsi.prepareDecomposeService(execution)]]> - SequenceFlow_0bf6bzp - SequenceFlow_0d0c20n + SequenceFlow_0b1dsaj + SequenceFlow_0sphcy5 - - SequenceFlow_0p6ba92 - SequenceFlow_0bf6bzp + + SequenceFlow_022onug + SequenceFlow_0b1dsaj - - SequenceFlow_0d0c20n - SequenceFlow_0a6vgsu + + SequenceFlow_0sphcy5 + SequenceFlow_18gnns6 - - - - SequenceFlow_0a6vgsu + + SequenceFlow_18gnns6 - - - - SequenceFlow_1hbesp9 - SequenceFlow_1e5j351 + + SequenceFlow_0yuzaen + SequenceFlow_1y9rkfr - - SequenceFlow_1s5aas9 - SequenceFlow_0p6ba92 + + SequenceFlow_0ckto7v + SequenceFlow_022onug - - - + + + + + + + + - + - + - - - - + - - - - - - - @@ -278,7 +244,7 @@ dcsi.doTPResourcesAllocation(execution)]]> - + @@ -302,109 +268,77 @@ dcsi.doTPResourcesAllocation(execution)]]> - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - + - + - - + + + + - + - - - - + + + + - - - - - - - - - - - - - - - - + @@ -413,83 +347,98 @@ dcsi.doTPResourcesAllocation(execution)]]> - - - + + + + + - + - - + + + + + - - + + - - + + - - - + + + + + - + + + + + + + + + + + + + + - - - + + + - + - - + + + - + - - - - + + + + - + - - - + + + - + - - - - - - - - - + + + - + - - - + + + - + - - - + + + - + - + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn index 77c62e573d..c699f911d0 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn @@ -14,21 +14,6 @@ dcsi.preProcessRequest(execution) ]]> - - - - - - - - - - - - SequenceFlow_0zmz5am - SequenceFlow_129ih1g - - SequenceFlow_0tgrn11 @@ -70,7 +55,7 @@ dcsi.postProcessRollback(execution) - SequenceFlow_129ih1g + SequenceFlow_0zmz5am SequenceFlow_03fabby SequenceFlow_0zmz5am - + SequenceFlow_1rhn48b @@ -471,16 +456,6 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - - - - - - - - - - @@ -731,9 +706,9 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> - + - + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn index 2c6f5ee61d..e3f1d7721d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn @@ -1,6 +1,6 @@ - + SequenceFlow_1 @@ -12,7 +12,7 @@ def dcsi = new DoCreateServiceInstance() dcsi.getAAICustomerById(execution)]]> - + SequenceFlow_1 SequenceFlow_2 @@ -54,20 +54,6 @@ dcsi.postProcessSDNCAssign(execution)]]> - - - - - - - - - - - - SequenceFlow_3 - SequenceFlow_1jhzmzn - SequenceFlow_0tgrn11 @@ -120,12 +106,12 @@ dcsi.postProcessRollback(execution) - - SequenceFlow_1jhzmzn + + SequenceFlow_3 SequenceFlow_16sdyz9 +ddsi.putServiceInstance(execution)]]> @@ -142,7 +128,6 @@ dcsi.createProject(execution)]]> def dcsi = new DoCreateServiceInstance() dcsi.createOwningEntity(execution)]]> - @@ -189,26 +174,25 @@ dcsi.processJavaException(execution)]]> - - + - + - + - + - + - + - + @@ -218,29 +202,30 @@ dcsi.processJavaException(execution)]]> - - + + - + - - + + + + - + - - + + + + - + - - - @@ -274,31 +259,29 @@ dcsi.processJavaException(execution)]]> - + - + - - + + - + - + - + - - - - + + - + @@ -324,40 +307,33 @@ dcsi.processJavaException(execution)]]> - + - - + + - + - + - + - - - - - - - - - + + - + - - + + - + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn index 820d1174be..c16061edb2 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -400,13 +400,13 @@ doCreateVfModule.prepUpdateAAIGenericVnf(execution)]]> SequenceFlow_112los9 - + - SequenceFlow_0d00zqi + SequenceFlow_0m382su SequenceFlow_0g270u0 - - - - - - - - - - SequenceFlow_0m382su - SequenceFlow_0d00zqi - SequenceFlow_1y1ttqe @@ -1248,9 +1236,9 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') - + - + @@ -1276,13 +1264,6 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') - - - - - - - @@ -1292,9 +1273,6 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn index a093beae91..50436352ea 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -13,44 +13,8 @@ DoCreateVnf createVnf = new DoCreateVnf() createVnf.preProcessRequest(execution)]]> - - SequenceFlow_7 - vnfExistYes - vnfExistNo - - - - - - - - - - - - - - - - VnfNameSpecified1 - SequenceFlow_7 - - - - vnfExistYes - SequenceFlow_10 - - - - - SequenceFlow_10 - - - vnfExistNo - VnfNameNotSpecified1 + SequenceFlow_11b2sf3 SequenceFlow_11 - - SequenceFlow_1mvplyi - VnfNameNotSpecified1 - VnfNameSpecified1 - - - - - @@ -236,12 +191,12 @@ doCreateVnf.prepUpdateAAIGenericVnf(execution)]]> SequenceFlow_2 - SequenceFlow_1mvplyi + SequenceFlow_11b2sf3 - + @@ -265,62 +220,14 @@ createVnf.getServiceInstance(execution)]]> - - - - - - - - - - + - - - - - - - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -328,10 +235,10 @@ createVnf.getServiceInstance(execution)]]> - + - + @@ -454,27 +361,6 @@ createVnf.getServiceInstance(execution)]]> - - - - - - - - - - - - - - - - - - - - - @@ -555,13 +441,13 @@ createVnf.getServiceInstance(execution)]]> - + - - - + + + - + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn index 0d48719c6b..b5988538e3 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn @@ -36,6 +36,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> + @@ -71,6 +72,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> + @@ -123,6 +125,7 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn index d9596f0d14..da7fc652ed 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -12,44 +12,29 @@ DoDeleteVnf deleteVnf = new DoDeleteVnf() deleteVnf.preProcessRequest(execution)]]> - - - - - - - - - - - - SequenceFlow_2 - SequenceFlow_5 - - + - SequenceFlow_5 + SequenceFlow_0hbmag5 vnfFound notFound - - + + - - vnfFound - SequenceFlow_4 + + SequenceFlow_2 + SequenceFlow_0hbmag5 +deleteVnf.getVnf(execution)]]> - notFound - SequenceFlow_4 + vnfFound inUse notInUse @@ -110,6 +95,7 @@ exceptionUtil.processJavaException(execution)]]> DoDeleteVnf delete = new DoDeleteVnf() delete.deleteVnf(execution)]]> + @@ -133,67 +119,50 @@ delete.deleteVnf(execution)]]> - + - + - - - - + - + - + - - - - - - - - - - - - - - - + - - - + + + - + - - - + + + - + - + - + - - + + - + @@ -202,12 +171,12 @@ delete.deleteVnf(execution)]]> - + - + - + @@ -225,42 +194,42 @@ delete.deleteVnf(execution)]]> - + - + - + - + - - + + - + - - + + - + - + - + - - + + - + @@ -296,8 +265,16 @@ delete.deleteVnf(execution)]]> - + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn index 4d6d0006e3..7563c05e1f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn @@ -193,6 +193,7 @@ ddvam.validateSDNCResponse(execution, response, "unassign")]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn index ef3340e887..8383ccbd1f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn @@ -87,59 +87,33 @@ ddsi.preInitResourcesOperStatus(execution)]]> SequenceFlow_177wo8z - - - - - - - - - - - - + SequenceFlow_1kx5ke9 - SequenceFlow_0f76thv - - - SequenceFlow_0f76thv - SequenceFlow_0x0mhlj + SequenceFlow_1cur6kz +ddsi.updateServiceInstance(execution)]]> SequenceFlow_1demy08 - - SequenceFlow_0ku36oy + SequenceFlow_1cur6kz SequenceFlow_07aa121 - - SequenceFlow_0ku36oy - - SequenceFlow_07aa121 - SequenceFlow_1uu6uiu - - SequenceFlow_0x0mhlj - - - SequenceFlow_1muxopq @@ -180,7 +154,7 @@ dcsi.postProcessRollback(execution) def dcsi = new DoUpdateE2EServiceInstance() dcsi.preProcessAAIPUT(execution)]]> - + SequenceFlow_0yztz2p @@ -245,6 +219,7 @@ dcsi.preProcessAAIPUT(execution)]]> + @@ -341,11 +316,8 @@ dcsi.preProcessAAIPUT(execution)]]> - - - - + @@ -355,45 +327,27 @@ dcsi.preProcessAAIPUT(execution)]]> - + - - - - - - - - + - - - - - - - + - + - + - - - - - - - - - + + + + - + @@ -402,19 +356,6 @@ dcsi.preProcessAAIPUT(execution)]]> - - - - - - - - - - - - - @@ -429,55 +370,55 @@ dcsi.preProcessAAIPUT(execution)]]> - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - + @@ -579,6 +520,13 @@ dcsi.preProcessAAIPUT(execution)]]> + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn index b53e87d34a..23233abc03 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn @@ -190,31 +190,15 @@ csi.postProcessForAddResource(execution)]]> def dcsi = new DoUpdateE2EServiceInstanceRollback() dcsi.preProcessAAIPUT(execution)]]> - - - - - - - - - - - - + SequenceFlow_1lppnhy - SequenceFlow_0kbisn8 - - - SequenceFlow_0kbisn8 SequenceFlow_1azhgda +dcsi.updateServiceInstance(execution)]]> - - + rollback AAI SequenceFlow_08p4pkv @@ -562,11 +546,8 @@ rbk.postProcessRequest(execution)]]> - - - - + @@ -577,18 +558,9 @@ rbk.postProcessRequest(execution)]]> - - - - - - - - - - + - + @@ -719,10 +691,10 @@ rbk.postProcessRequest(execution)]]> - + - + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn index ae77461070..c77c684fa4 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn @@ -63,6 +63,7 @@ exceptionUtil.processJavaException(execution)]]> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json index dc4669e8d9..13dd32226f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json @@ -24,6 +24,7 @@ "cloudConfiguration": { "lcpCloudRegionId":"mdt1", + "cloudOwner" : "my-cloud-owner", "tenantId":"8b1df54faa3b49078e3416e21370a3ba" }, "requestParameters": diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json index dc4669e8d9..13dd32226f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json @@ -24,6 +24,7 @@ "cloudConfiguration": { "lcpCloudRegionId":"mdt1", + "cloudOwner" : "my-cloud-owner", "tenantId":"8b1df54faa3b49078e3416e21370a3ba" }, "requestParameters": diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml index 8a5ade6fb6..dc48c79ff9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml @@ -101,30 +101,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml index 007615e569..f214c61042 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml @@ -178,53 +178,6 @@ mso: version: '9' generic-vnf: version: '9' - v11: - customer: - uri: /aai/v11/business/customers/customer - generic-query: - uri: /aai/v11/search/generic-query - generic-vnf: - uri: /aai/v11/network/generic-vnfs/generic-vnf - l3-network: - uri: /aai/v11/network/l3-networks/l3-network - network-policy: - uri: /aai/v11/network/network-policies/network-policy - nodes-query: - uri: /aai/v11/search/nodes-query - route-table-reference: - uri: /aai/v11/network/route-table-references/route-table-reference - tenant: - uri: /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v11/network/vces/vce - vpn-binding: - uri: /aai/v11/network/vpn-bindings/vpn-binding - v8: - configuration: - uri: /aai/v11/network/configurations/configuration - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf retry: attempts: '1' deleteCinderVolumeV1: diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 3483aed8a7..d9b3ee57d8 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -29,7 +29,7 @@ org.onap.sdnc.northbound generic-resource-api-client - 1.4.0-SNAPSHOT + 1.4.0 javax.ws.rs diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index 7bc48519b0..0190f3df56 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -7,9 +7,9 @@ * 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. @@ -29,6 +29,7 @@ import java.util.UUID; import org.apache.commons.lang.SerializationUtils; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.json.JSONArray; import org.json.JSONObject; import org.onap.so.bpmn.common.BuildingBlockExecution; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java index bf429ee4fc..534e93637a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java @@ -29,6 +29,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.springframework.beans.factory.annotation.Autowired; @@ -55,10 +56,10 @@ public class AssignVnf { if(ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { instanceGroup.setInstanceGroupName(aaiObjectInstanceNameGenerator.generateInstanceGroupName(instanceGroup, vnf)); aaiInstanceGroupResources.createInstanceGroup(instanceGroup); - aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); } else if(ModelInfoInstanceGroup.TYPE_NETWORK_INSTANCE_GROUP.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { - aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.USES); } } } 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 e7d09f83e0..724dea6cf5 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 @@ -104,6 +104,7 @@ public class WorkflowAction { private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; private static final String HOMINGSOLUTION = "Homing_Solution"; + private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired @@ -177,6 +178,7 @@ public class WorkflowAction { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); } + orchFlows = filterOrchFlows(orchFlows, resourceType, execution); String key = ""; ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); if(modelInfo.getModelType().equals(ModelType.service)) { @@ -238,7 +240,7 @@ public class WorkflowAction { && (requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("unassignInstance") || requestAction.equalsIgnoreCase("deleteInstance") - || requestAction.equalsIgnoreCase("activateFabricConfiguration"))) { + || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE // Will never get user params with service, macro will have @@ -619,13 +621,13 @@ public class WorkflowAction { } - private List traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { + protected List traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { List configurations = new ArrayList<>(); try{ List cvnfcCustomizations = catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(vnfCustomizationUUID, vfModuleCustomizationUUID); for(CvnfcCustomization cvnfc : cvnfcCustomizations){ for(VnfVfmoduleCvnfcConfigurationCustomization customization : cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){ - if(customization.getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")){ + if(customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)){ configurations.add(customization.getConfigurationResource().getModelUUID()); } } @@ -964,6 +966,17 @@ public class WorkflowAction { } return listToExecute; } + + protected List filterOrchFlows(List orchFlows, WorkflowType resourceType, DelegateExecution execution) { + List result = new ArrayList<>(orchFlows); + if (resourceType.equals(WorkflowType.VFMODULE)) { + List fabricCustomizations = traverseCatalogDbForConfiguration((String)execution.getVariable("vnfId"), (String)execution.getVariable("vfModuleId")); + if (fabricCustomizations.isEmpty()) { + result = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList()); + } + } + return result; + } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { logger.error(msg, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 2b58b7bdd7..81c2107328 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -23,15 +23,18 @@ package org.onap.so.client.adapter.vnf.mapper; import static java.util.Arrays.asList; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; import javax.annotation.PostConstruct; -import javax.validation.Valid; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; @@ -303,6 +306,9 @@ public class VnfAdapterVfModuleObjectMapper { buildVfModuleSriovParameters(paramsMap, network, networkKey); // IPV4 and IPV6 Addresses buildVfModuleNetworkInformation(paramsMap, network, key, networkKey); + + buildVlanInformation(paramsMap, network, key, networkKey); + } } } @@ -315,6 +321,36 @@ public class VnfAdapterVfModuleObjectMapper { } } + protected void buildVlanInformation(Map paramsMap, + GenericResourceApiVmNetworkData network, String key, String networkKey) { + + String networkString = convertToString(network); + String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter"; + String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans"; + String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans"; + String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans"; + + if (network.getSegmentationId() != null) { + paramsMap.put(vlanFilterKey, network.getSegmentationId()); + } + + List privateVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id"); + List publicVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id"); + List concat = new ArrayList<>(privateVlans); + concat.addAll(publicVlans); + Collection guestVlans = new HashSet<>(concat); + + if (!privateVlans.isEmpty()) { + paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans)); + } + if (!publicVlans.isEmpty()) { + paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans)); + } + if (!guestVlans.isEmpty()) { + paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans)); + } + } + private void buildVfModuleVmNames(Map paramsMap, GenericResourceApiVmTopologyData vm, String key) { String values = ""; GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index 4c4edb7fe9..68f6e8ffa2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -26,6 +26,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -57,6 +58,12 @@ public class AAIInstanceGroupResources { injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI); } + public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf, AAIEdgeLabel aaiLabel) { + AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI, aaiLabel); + } + public boolean exists(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); return injectionHelper.getAaiClient().exists(instanceGroupUri); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index b5738dcb40..86dd22b65c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -107,7 +107,7 @@ public class AAIServiceInstanceResources { } public boolean existsOwningEntityName(String owningEntityName) { - AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITIES).queryParam("owning-entity-name", owningEntityName); + AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY).queryParam("owning-entity-name", owningEntityName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); return aaiRC.exists(owningEntityUri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java index 8bd55f0f90..092af30558 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java @@ -7,9 +7,9 @@ * 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. @@ -28,6 +28,7 @@ import org.onap.aai.domain.yang.VpnBindings; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; @@ -39,10 +40,10 @@ import org.springframework.stereotype.Component; public class AAIVpnBindingResources { @Autowired private InjectionHelper injectionHelper; - + @Autowired private AAIObjectMapper aaiObjectMapper; - + /** * @param customer */ @@ -56,10 +57,10 @@ public class AAIVpnBindingResources { * @return */ public Optional getVpnBindingByCustomerVpnId (String customerVpnId) { - AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDINGS) + AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VPN_BINDING) .queryParam("customer-vpn-id",customerVpnId); - return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri); - + return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri); + } /** diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java index 432399b1b8..3975b25356 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -86,8 +86,8 @@ public class GeneralTopologyObjectMapper { networkInformation.setFromPreload(null); networkInformation.setNetworkId(network.getNetworkId()); - //TODO fix this after network type filed included in L3Network object type - //networkInformation.setNetworkType(network.getNetwork); + networkInformation.setNetworkType(network.getNetworkType()); + networkInformation.setNetworkTechnology(network.getNetworkTechnology()); return networkInformation; } /* diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index 8944d1eaa4..1355151919 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -71,7 +71,7 @@ public class VnfTopologyOperationRequestMapper { vnfRequestInput.setTenant(cloudRegion.getTenantId()); vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - + if (StringUtils.isNotBlank(vnf.getVnfName())) { vnfRequestInput.setVnfName(vnf.getVnfName()); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java index e1b652a140..8382b9be72 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java @@ -33,6 +33,7 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.springframework.beans.factory.annotation.Autowired; public class AssignVnfTest extends BaseTaskTest { @@ -87,10 +88,10 @@ public class AssignVnfTest extends BaseTaskTest { assignVnf.createInstanceGroups(execution); verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1); verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf, AAIEdgeLabel.BELONGS_TO); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf, AAIEdgeLabel.BELONGS_TO); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf, AAIEdgeLabel.USES); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf, AAIEdgeLabel.USES); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java new file mode 100644 index 0000000000..b818b07c1f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -0,0 +1,158 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class WorkflowActionUnitTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/"; + + @Mock + private CatalogDbClient catalogDbClient; + @Mock + private BBInputSetup bbInputSetup; + @Mock + private BBInputSetupUtils bbInputSetupUtils; + @Mock + private ExceptionBuilder exceptionBuilder; + @Mock + private AAIConfigurationResources aaiConfigurationResources; + + @InjectMocks + @Spy + private WorkflowAction workflowAction; + + @Test + public void filterOrchFlowsHasFabricTest() { + + List flows = createFlowList( + "DeactivateFabricConfigurationBB", + "flow x", + "flow y", + "ActivateFabricConfigurationBB", + "flow z"); + doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class)); + + List result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + + assertThat(result, is(flows)); + } + + @Test + public void filterOrchFlowNoFabricTest() { + List flows = createFlowList( + "DeactivateFabricConfigurationBB", + "flow x", + "flow y", + "ActivateFabricConfigurationBB", + "flow z"); + doReturn(Arrays.asList()).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class)); + + List result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + List expected = createFlowList( + "flow x", + "flow y", + "flow z"); + + assertThat(result, is(expected)); + } + + @Test + public void traverseCatalogDbForConfigurationTest() { + + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + VnfVfmoduleCvnfcConfigurationCustomization vfModuleCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("my-uuid"); + vfModuleCustomization.setConfigurationResource(configuration); + cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization)); + List cvnfcCustomizations = Arrays.asList(cvnfcCustomization); + when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), any(String.class))) + .thenReturn(cvnfcCustomizations); + + List results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId"); + + assertThat(results, is(Arrays.asList("my-uuid"))); + + } + + @Test + public void verifyFilterOrchInvocation() throws Exception { + DelegateExecution execution = mock(DelegateExecution.class); + + when(execution.getVariable(eq("aLaCarte"))).thenReturn(true); + when(execution.getVariable(eq("bpmnRequest"))).thenReturn(getJson("ServiceMacroAssign.json")); + when(execution.getVariable(eq("requestUri"))).thenReturn("/v6/serviceInstances/123/vnfs/1234"); + + OrchestrationFlow flow = new OrchestrationFlow(); + flow.setFlowName("flow x"); + + List flows = Arrays.asList(flow); + doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean()); + workflowAction.selectExecutionList(execution); + + verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any()); + + flow = new OrchestrationFlow(); + flow.setFlowName("flow y"); + flows = Arrays.asList(flow); + when(execution.getVariable(eq("aLaCarte"))).thenReturn(false); + workflowAction.selectExecutionList(execution); + + verify(workflowAction, never()).filterOrchFlows(eq(flows), any(), any()); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename))); + } + + private List createFlowList(String... myList) { + + List result = new ArrayList<>(); + for (String name : myList) { + OrchestrationFlow flow = new OrchestrationFlow(); + flow.setFlowName(name); + result.add(flow); + } + + return result; + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 0c9e281fc7..a68afd811a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -22,17 +22,20 @@ package org.onap.so.client.adapter.vnf.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; +import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; @@ -770,4 +773,18 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); } + + @Test + public void networkCloudParamsTest() throws IOException { + + String json = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json"))); + GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class); + Map paramsMap = new HashMap<>(); + vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType"); + + assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans")); + assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans")); + assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans")); + assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter")); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java index aef25e5ded..621e275fdf 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @RunWith(MockitoJUnitRunner.class) @@ -86,6 +87,12 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup{ verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()))); } + @Test + public void connectInstanceGroupWithEdgeTest() throws Exception { + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); + verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())), eq(AAIEdgeLabel.BELONGS_TO)); + } + @Test public void existsTest() throws Exception { aaiInstanceGroupResources.exists(instanceGroup); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java index 298a3de9ba..ba7dc8d618 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -20,9 +20,11 @@ package org.onap.so.client.sdnc.mapper; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import java.util.HashMap; @@ -32,28 +34,31 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; - -public class GeneralTopologyObjectMapperTest extends TestDataSetup{ +public class GeneralTopologyObjectMapperTest extends TestDataSetup { @InjectMocks private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper(); @@ -222,4 +227,55 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup{ assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId()); assertNotNull(gcRequestInput.getVnfId()); } + + @Test + public void buildNetworkInformationTest() { + + L3Network network = new L3Network(); + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); + modelInfoNetwork.setModelInvariantUUID("my-uuid"); + modelInfoNetwork.setModelName("my-model-name"); + modelInfoNetwork.setModelVersion("my-model-version"); + modelInfoNetwork.setModelUUID("my-model-uuid"); + modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid"); + network.setModelInfoNetwork(modelInfoNetwork); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation(); + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + onapModelInformation.setModelInvariantUuid("my-uuid"); + onapModelInformation.setModelName("my-model-name"); + onapModelInformation.setModelVersion("my-model-version"); + onapModelInformation.setModelUuid("my-model-uuid"); + onapModelInformation.setModelCustomizationUuid("my-customization-uuid"); + networkInformation.setOnapModelInformation(onapModelInformation); + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } + + @Test + public void buildNetworkInformationNoModelTest() { + + L3Network network = new L3Network(); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json new file mode 100644 index 0000000000..e83f487a64 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json @@ -0,0 +1,73 @@ +{ + "network-role": "vmNetworkRole0", + "segmentation-id" : "my-segemntation-id", + "floating-ips": { + "floating-ip-v4": [ + "floatingIpV40", + "floatingIpV41" + ], + "floating-ip-v6": [ + "floatingIpV60", + "floatingIpV61" + ] + }, + "interface-route-prefixes": { + "interface-route-prefix": [ + "interfaceRoutePrefix0", + "interfaceRoutePrefix1" + ] + }, + "sriov-parameters": { + "heat-vlan-filters": { + "heat-vlan-filter": [ + "heatVlanFilter0", + "heatVlanFilter1" + ] + } + }, + "network-information-items": { + "network-information-item": [ + { + "network-ips": { + "network-ip": [ + "ip0", + "ip1" + ] + }, + "ip-version": "ipv4" + }, + { + "network-ips": { + "network-ip": [ + "ip2", + "ip3" + ] + }, + "ip-version": "ipv6" + } + ] + }, + "related-networks" : { + "related-network" : [{ + "vlan-tags" : { + "is-private" : "True", + "upper-tag-id" : "1" + } + },{ + "vlan-tags" : { + "is-private" : "False", + "upper-tag-id" : "2" + } + },{ + "vlan-tags" : { + "is-private" : "True", + "upper-tag-id" : "3" + } + },{ + "vlan-tags" : { + "is-private" : "False", + "upper-tag-id" : "3" + } + }] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml index 4562ebdaea..6f67a9ccc4 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml @@ -114,30 +114,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: @@ -220,4 +196,4 @@ camunda: bpm: metrics: enabled: false - db-reporter-activate: false \ No newline at end of file + db-reporter-activate: false diff --git a/common/pom.xml b/common/pom.xml index d8e71b0e44..d2dba45ebd 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -62,7 +62,7 @@ org.onap.aai.aai-common aai-schema - 1.3.0 + 1.3.1-SNAPSHOT org.modelmapper diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java index 553c1e0db0..4f3816ad90 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java @@ -20,22 +20,31 @@ package org.onap.so.client.aai; +import org.onap.aai.domain.yang.NetworkTechnologies; import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.constants.Defaults; import com.google.common.base.CaseFormat; public enum AAIObjectPlurals implements GraphInventoryObjectPlurals { + CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers"), GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"), PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"), P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"), L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"), + NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies"), + VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings"), SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"), SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"), - OWNING_ENTITIES(AAINamespaceConstants.BUSINESS, "/owning-entities"), - VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/"), - AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones/"); - + OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities"), + VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"), + AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"), + VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"), + CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations"), + DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"), + NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"), + LOGICAL_LINK(AAINamespaceConstants.NETWORK, "/logical-links"); private final String uriTemplate; private final String partialUri; diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java index 4b646f9ed7..0e50818f0f 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java @@ -7,9 +7,9 @@ * 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. @@ -29,13 +29,16 @@ import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Collection; import org.onap.aai.domain.yang.Complex; import org.onap.aai.domain.yang.Configuration; +import org.onap.aai.domain.yang.Connector; import org.onap.aai.domain.yang.Customer; +import org.onap.aai.domain.yang.ExtAaiNetwork; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.InstanceGroup; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LineOfBusiness; import org.onap.aai.domain.yang.ModelVer; import org.onap.aai.domain.yang.NetworkPolicy; +import org.onap.aai.domain.yang.NetworkTechnology; import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.aai.domain.yang.OwningEntity; import org.onap.aai.domain.yang.PInterface; @@ -46,6 +49,7 @@ import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.RouteTableReferences; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; import org.onap.aai.domain.yang.Vce; @@ -56,12 +60,13 @@ import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; import org.onap.aai.domain.yang.Vserver; import org.onap.so.client.graphinventory.GraphInventoryObjectType; +import org.onap.so.constants.Defaults; import com.google.common.base.CaseFormat; public enum AAIObjectType implements GraphInventoryObjectType { - DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/att-aic/{cloud-region-id}"), + DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}"), CUSTOMER(AAINamespaceConstants.BUSINESS, Customer.class), GENERIC_QUERY("/search", "/generic-query"), BULK_PROCESS("/bulkprocess", ""), @@ -73,10 +78,9 @@ public enum AAIObjectType implements GraphInventoryObjectType { NODES_QUERY("/search", "/nodes-query"), CUSTOM_QUERY("/query", ""), ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, RouteTableReferences.class), - DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/att-aic/AAIAIC25", "/tenants/tenant/{tenant-id}"), + DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}"), VCE(AAINamespaceConstants.NETWORK, Vce.class), VPN_BINDING(AAINamespaceConstants.NETWORK, VpnBinding.class), - VPN_BINDINGS(AAINamespaceConstants.NETWORK, "/vpn-bindings"), CONFIGURATION(AAINamespaceConstants.NETWORK, Configuration.class), PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class), SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class), @@ -101,6 +105,10 @@ public enum AAIObjectType implements GraphInventoryObjectType { VNFC(AAINamespaceConstants.NETWORK, Vnfc.class), VLAN_TAG(AAINamespaceConstants.NETWORK, VlanTag.class), COMPLEX(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class), + CONNECTOR(AAINamespaceConstants.BUSINESS, Connector.class), + NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class), + SUBNET(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class), + EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class), UNKNOWN("", ""); private final String uriTemplate; @@ -114,7 +122,7 @@ public enum AAIObjectType implements GraphInventoryObjectType { this.uriTemplate = parentUri + partialUri; this.aaiObjectClass = null; } - + private AAIObjectType(String parentUri, Class aaiObjectClass) { this.parentUri = parentUri; this.partialUri = removeParentUri(aaiObjectClass, parentUri); @@ -126,14 +134,14 @@ public enum AAIObjectType implements GraphInventoryObjectType { public String toString() { return this.uriTemplate(); } - + public static AAIObjectType fromTypeName(String name) { if (map.isEmpty()) { for (AAIObjectType type : AAIObjectType.values()) { map.put(type.typeName(), type); } } - + if (map.containsKey(name)) { return map.get(name); } else { @@ -163,7 +171,7 @@ public enum AAIObjectType implements GraphInventoryObjectType { public String partialUri() { return this.partialUri; } - + protected String removeParentUri(Class aaiObjectClass, String parentUri) { return aaiObjectClass.getAnnotation(Metadata.class).uriTemplate().replace(parentUri, ""); } diff --git a/common/src/main/java/org/onap/so/constants/Defaults.java b/common/src/main/java/org/onap/so/constants/Defaults.java new file mode 100644 index 0000000000..abbd522b4e --- /dev/null +++ b/common/src/main/java/org/onap/so/constants/Defaults.java @@ -0,0 +1,18 @@ +package org.onap.so.constants; + +public enum Defaults { + + CLOUD_OWNER("att-aic"); + + + private final String value; + + private Defaults(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java index a58949e498..67d852eff8 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java @@ -22,13 +22,16 @@ package org.onap.so.serviceinstancebeans; import java.io.Serializable; +import org.onap.so.constants.Defaults; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.ToStringBuilder; @JsonRootName(value = "cloudConfiguration") -@JsonInclude(Include.NON_DEFAULT) +@JsonInclude(Include.NON_EMPTY) public class CloudConfiguration implements Serializable { private static final long serialVersionUID = 6260165690180745471L; @@ -36,6 +39,8 @@ public class CloudConfiguration implements Serializable { protected String aicNodeClli; @JsonProperty("tenantId") protected String tenantId; + @JsonProperty("cloudOwner") + protected String cloudOwner = Defaults.CLOUD_OWNER.toString(); @JsonProperty("lcpCloudRegionId") protected String lcpCloudRegionId; @@ -96,11 +101,19 @@ public class CloudConfiguration implements Serializable { this.lcpCloudRegionId = lcpCloudRegionId; } - @Override - public String toString() { - return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId=" - + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]"; + public String getCloudOwner() { + return cloudOwner; } + public void setCloudOwner(String cloudOwner) { + this.cloudOwner = cloudOwner; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) + .append("cloudOwner", getCloudOwner()).append("lcpCloudRegionId", getLcpCloudRegionId()).toString(); + } + + } diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java index 7a4af7808e..5af84fdb86 100644 --- a/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java @@ -20,10 +20,16 @@ package org.onap.so.serviceinstancebeans; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + import org.junit.Test; import org.onap.so.openpojo.rules.HasToStringRule; import org.onap.so.openpojo.rules.ToStringTester; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.PojoClassFilter; import com.openpojo.reflection.filters.FilterEnum; @@ -43,6 +49,17 @@ public class ServiceInstanceBeansTest { public void pojoStructure() { test("org.onap.so.serviceinstancebeans"); } + + @Test + public void cloudConfigurationkeepDefaultValues() throws IOException { + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + cloudConfiguration.setLcpCloudRegionId("myRegionId"); + ObjectMapper mapper = new ObjectMapper(); + + assertEquals("{\"cloudOwner\":\"att-aic\",\"lcpCloudRegionId\":\"myRegionId\"}", mapper.writeValueAsString(cloudConfiguration)); + + + } private void test(String pojoPackage) { Validator validator = ValidatorBuilder.create() diff --git a/logger/logback-spring.xml b/logger/logback-spring.xml new file mode 100644 index 0000000000..dbba5da9b0 --- /dev/null +++ b/logger/logback-spring.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${logs_dir:-.}/${saneLogName}.log + + ${logs_dir:-.}/${saneLogName}.%d{yyyy-MM-dd}.%i.log.zip + + + + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${defaultPattern} + + + + + ${logs_dir:-.}/${auditLogName}.log + + ${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip + + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${auditPattern} + + + + + 256 + + + + + ${logs_dir:-.}/${metricsLogName}.log + + ${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip + + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${metricPattern} + + + + + + 256 + + + + + + ERROR + ACCEPT + DENY + + ${logs_dir:-.}/${errorLogName}.log + + ${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip + + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${errorPattern} + + + + + 256 + + + + + ${logs_dir:-.}/${debugLogName}.log + + ${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip + + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${debugPattern} + + + + + 256 + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java new file mode 100644 index 0000000000..154ae36d41 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.apihandlerinfra.exceptions; + +public class RequestDbFailureException extends ApiException { + + private static final String requestDbFailMessage = "Unable to %s due to error contacting requestDb: %s"; + + private RequestDbFailureException(Builder builder) { + super(builder); + } + + public static class Builder extends ApiException.Builder{ + + + public Builder(String action, String error, int httpResponseCode, String messageID) { + super(requestDbFailMessage.format(requestDbFailMessage, action, error),httpResponseCode,messageID); + } + + public RequestDbFailureException build() { + return new RequestDbFailureException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index bb7df4b7be..fb6076e1a4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -45,6 +45,7 @@ import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException; +import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -109,6 +110,7 @@ public class ServiceInstances { private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,MsoRequest.class); private static String NAME = "name"; private static String VALUE = "value"; + private static final String SAVE_TO_DB = "save instance to db"; @Autowired private Environment env; @@ -740,7 +742,13 @@ public class ServiceInstances { if (sir.getCorrelationId() != null) { correlationId = sir.getCorrelationId(); } - infraActiveRequestsClient.save(currentActiveReq); + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -870,7 +878,13 @@ public class ServiceInstances { currentActiveReq.setRequestStatus(Status.IN_PROGRESS.name()); setInstanceId(currentActiveReq, requestScope, jsonResponse.getRequestReferences().getInstanceId(), new HashMap<>()); - infraActiveRequestsClient.save(currentActiveReq); + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion); } } @@ -983,14 +997,10 @@ public class ServiceInstances { } } catch (Exception e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - ValidateException validateException = new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) .errorInfo(errorLoggerInfo).build(); - - updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - - throw validateException; + updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage()); + throw requestDbFailureException; } return dup; } @@ -1016,7 +1026,7 @@ public class ServiceInstances { } private void parseRequest(ServiceInstancesRequest sir, HashMap instanceIdMap, Actions action, String version, - String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException { + String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException { int reqVersion = Integer.parseInt(version.substring(1)); try { msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte); @@ -1218,6 +1228,7 @@ public class ServiceInstances { targetConfiguration.setAicNodeClli(sourceCloudConfiguration.getAicNodeClli()); targetConfiguration.setTenantId(sourceCloudConfiguration.getTenantId()); targetConfiguration.setLcpCloudRegionId(sourceCloudConfiguration.getLcpCloudRegionId()); + targetConfiguration.setCloudOwner(sourceCloudConfiguration.getCloudOwner()); return Optional.of(targetConfiguration); } return Optional.empty(); @@ -1633,7 +1644,13 @@ public class ServiceInstances { if (sir.getCorrelationId() != null) { correlationId = sir.getCorrelationId(); } - infraActiveRequestsClient.save(currentActiveReq); + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -1660,14 +1677,20 @@ public class ServiceInstances { throw validateException; } } - public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){ + public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{ if ((status == Status.FAILED) || (status == Status.COMPLETE)) { aq.setStatusMessage (errorMessage); aq.setProgress(new Long(100)); aq.setRequestStatus(status.toString()); Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); aq.setEndTime (endTimeStamp); - infraActiveRequestsClient.save(aq); + try{ + infraActiveRequestsClient.save(aq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 464d5e6bba..b3ee40bb8b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -2302,4 +2302,94 @@ public class ServiceInstancesTest extends BaseTest{ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); } + @Test + public void createServiceInstanceDuplicateError() throws IOException{ + stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createServiceInstanceSaveError() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + stubFor(post(urlMatching(".*/infraActiveRequests/")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createPortConfigurationSaveError() throws IOException { + stubFor(post(urlMatching(".*/infraActiveRequests/")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + HttpHeaders headers = new HttpHeaders(); + + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; + ResponseEntity response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createPortConfigDbUpdateError() throws IOException { + stubFor(post(urlMatching(".*/infraActiveRequests/")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; + ResponseEntity response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } } \ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 07d185b3af..b809691b31 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -59,6 +59,7 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; + import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; 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 9742a0c85b..4f070e71c9 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 @@ -20,6 +20,14 @@ package org.onap.so.db.catalog.client; +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.ws.rs.core.UriBuilder; + import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; @@ -27,6 +35,7 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; @@ -55,17 +64,11 @@ import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; + import uk.co.blackpepper.bowman.Client; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; -import javax.annotation.PostConstruct; -import javax.ws.rs.core.UriBuilder; -import java.net.URI; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - @Component("CatalogDbClient") public class CatalogDbClient { @@ -84,6 +87,7 @@ public class CatalogDbClient { private static final String NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION = "/networkCollectionResourceCustomization"; private static final String VNF_RESOURCE_CUSTOMIZATION = "/vnfResourceCustomization"; private static final String SERVICE = "/service"; + private static final String EXTERNAL_SERVICE_TO_INTERNAL_MODEL_MAPPING = "/externalServiceToInternalService"; private static final String VNF_RESOURCE = "/vnfResource"; private static final String VNF_RECIPE = "/vnfRecipe"; private static final String VFMODULE = "/vfModule"; @@ -96,6 +100,8 @@ public class CatalogDbClient { private static final String URI_SEPARATOR = "/"; private static final String SERVICE_MODEL_UUID = "serviceModelUUID"; + private static final String SERVICE_NAME = "serviceName"; + private static final String MODEL_UUID = "modelUUID"; private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; private static final String ACTION = "action"; private static final String MODEL_NAME = "modelName"; @@ -122,6 +128,10 @@ public class CatalogDbClient { private static final String TARGET_ENTITY = "SO:CatalogDB"; + private String findExternalToInternalServiceByServiceName = "/findByServiceName"; + private String findServiceByModelName = "/findOneByModelName"; + private String findServiceRecipeByActionAndServiceModelUUID = "/findByActionAndServiceModelUUID"; + private String findServiceByModelUUID = "/findOneByModelUUID"; private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc"; private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction"; private String findFirstByModelVersionAndModelInvariantUUIDURI = "/findFirstByModelVersionAndModelInvariantUUID"; @@ -196,6 +206,8 @@ public class CatalogDbClient { private final Client serviceRecipeClient; + private final Client externalServiceToInternalServiceClient; + private final Client cloudSiteClient; private final Client cloudifyManagerClient; @@ -213,6 +225,10 @@ public class CatalogDbClient { @PostConstruct public void init(){ + findExternalToInternalServiceByServiceName = endpoint + EXTERNAL_SERVICE_TO_INTERNAL_MODEL_MAPPING + SEARCH + findExternalToInternalServiceByServiceName; + findServiceByModelName = endpoint + SERVICE + SEARCH + findServiceByModelName; + findServiceRecipeByActionAndServiceModelUUID = endpoint + SERVICE_RECIPE + SEARCH + findServiceRecipeByActionAndServiceModelUUID; + findServiceByModelUUID = endpoint + SERVICE + SEARCH + findServiceByModelUUID; findFirstByModelNameURI = endpoint + SERVICE + SEARCH + findFirstByModelNameURI; findFirstByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findFirstByModelVersionAndModelInvariantUUIDURI; findByModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findByModelInvariantUUIDURI; @@ -288,6 +304,7 @@ public class CatalogDbClient { serviceRecipeClient = clientFactory.create(ServiceRecipe.class); cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); + externalServiceToInternalServiceClient = clientFactory.create(ExternalServiceToInternalService.class); } public CatalogDbClient(String baseUri, String auth) { @@ -329,6 +346,7 @@ public class CatalogDbClient { serviceRecipeClient = clientFactory.create(ServiceRecipe.class); cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); + externalServiceToInternalServiceClient = clientFactory.create(ExternalServiceToInternalService.class); } public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) { @@ -495,6 +513,30 @@ public class CatalogDbClient { .queryParam(MODEL_NAME,modelName).build()); } + public ExternalServiceToInternalService findExternalToInternalServiceByServiceName(String serviceName){ + return this.getSingleResource(externalServiceToInternalServiceClient, getUri(UriBuilder + .fromUri(findExternalToInternalServiceByServiceName) + .queryParam(SERVICE_NAME,serviceName).build().toString())); + } + + public ServiceRecipe findServiceRecipeByActionAndServiceModelUUID(String action,String modelUUID){ + return this.getSingleResource(serviceRecipeClient, getUri(UriBuilder + .fromUri(findServiceRecipeByActionAndServiceModelUUID) + .queryParam(ACTION,action) + .queryParam(SERVICE_MODEL_UUID,modelUUID).build().toString())); + } + + public Service getServiceByModelName(String modelName){ + return this.getSingleResource(serviceClient,getUri(UriBuilder + .fromUri(findServiceByModelName) + .queryParam(MODEL_NAME,modelName).build().toString())); + } + + public Service getServiceByModelUUID(String modelModelUUID){ + return this.getSingleResource(serviceClient,getUri(UriBuilder + .fromUri(findServiceByModelUUID) + .queryParam(MODEL_UUID,modelModelUUID).build().toString())); + } public VnfResource getFirstVnfResourceByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion){ return this.getSingleResource(vnfResourceClient, getUri(UriBuilder -- cgit 1.2.3-korg