From 62cd6aaaf74aa91ee0037c0e155c8e7284f07567 Mon Sep 17 00:00:00 2001 From: Arthur Martella Date: Fri, 8 Sep 2017 13:27:46 -0400 Subject: 1710 Rebase - Second Attempt This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit: 54483fc6606ddb1591a2e9da61bff8712325f924 Wed Sep 6 18:12:56 2017 -0400 Rebasing was done on a branch on top of this commit in so/master in ONAP: 93fbdfbe46104f8859d4754040f979cb7997c157 Thu Sep 7 16:42:59 2017 +0000 Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59 Issue-id: SO-107 Signed-off-by: Arthur Martella --- bpmn/MSOInfrastructureBPMN/pom.xml | 47 +- .../CreateGenericALaCarteServiceInstance.groovy | 45 +- .../CreateGenericMacroServiceNetworkVnf.groovy | 804 ---- .../scripts/CreateNetworkInstance.groovy | 116 +- .../scripts/CreateVfModuleInfra.groovy | 61 +- .../scripts/CreateVfModuleVolumeInfraV1.groovy | 152 +- .../infrastructure/scripts/CreateVnfInfra.groovy | 70 +- .../DeleteGenericALaCarteServiceInstance.groovy | 45 +- .../DeleteGenericMacroServiceNetworkVnf.groovy | 468 --- .../scripts/DeleteNetworkInstance.groovy | 14 +- .../scripts/DeleteVfModuleInfra.groovy | 13 +- .../scripts/DeleteVfModuleVolumeInfraV1.groovy | 17 +- .../scripts/DoCreateNetworkInstance.groovy | 24 +- .../scripts/DoCreateServiceInstance.groovy | 203 +- .../infrastructure/scripts/DoCreateVfModule.groovy | 98 +- .../scripts/DoCreateVfModuleRollback.groovy | 299 +- .../scripts/DoCreateVfModuleVolumeRollback.groovy | 222 ++ .../scripts/DoCreateVfModuleVolumeV1.groovy | 657 ---- .../scripts/DoCreateVfModuleVolumeV2.groovy | 593 +++ .../bpmn/infrastructure/scripts/DoCreateVnf.groovy | 78 +- .../scripts/DoCreateVnfAndModules.groovy | 268 +- .../scripts/DoCreateVnfAndModulesRollback.groovy | 218 +- .../scripts/DoDeleteNetworkInstance.groovy | 8 +- .../scripts/DoDeleteServiceInstance.groovy | 110 +- .../infrastructure/scripts/DoDeleteVfModule.groovy | 23 +- .../scripts/DoDeleteVfModuleFromVnf.groovy | 613 +++ .../scripts/DoDeleteVfModuleVolumeV2.groovy | 358 ++ .../scripts/DoDeleteVnfAndModules.groovy | 18 +- .../scripts/DoUpdateNetworkInstance.groovy | 20 +- .../infrastructure/scripts/DoUpdateVfModule.groovy | 119 +- .../scripts/DoUpdateVnfAndModules.groovy | 391 ++ .../infrastructure/scripts/ReplaceVnfInfra.groovy | 694 ++++ .../scripts/UpdateNetworkInstance.groovy | 29 +- .../scripts/UpdateVfModuleInfra.groovy | 171 +- .../scripts/UpdateVfModuleInfraV2.groovy | 473 +++ .../scripts/UpdateVfModuleVolumeInfraV1.groovy | 52 +- .../infrastructure/scripts/UpdateVnfInfra.groovy | 676 ++++ .../MSOInfrastructureApplication.java | 2 +- .../WorkflowAsyncInfrastructureResource.java | 46 - .../service/WorkflowResourceApplication.java | 57 - .../CreateGenericMacroServiceNetworkVnf.bpmn | 1243 ------ .../resources/process/CreateNetworkInstance.bpmn | 52 +- .../resources/process/CreateVfModuleInfra.bpmn | 202 +- .../process/CreateVfModuleVolumeInfraV1.bpmn | 508 +-- .../src/main/resources/process/CreateVnfInfra.bpmn | 69 +- .../DeleteGenericMacroServiceNetworkVnf.bpmn | 773 ---- .../resources/process/DeleteNetworkInstance.bpmn | 4 +- .../resources/process/DeleteVfModuleInfra.bpmn | 3 +- .../process/DeleteVfModuleVolumeInfraV1.bpmn | 395 +- .../main/resources/process/ReplaceVnfInfra.bpmn | 1177 ++++++ .../src/main/resources/process/TestHelloWorld.bpmn | 52 + .../resources/process/UpdateNetworkInstance.bpmn | 3 +- .../resources/process/UpdateVfModuleInfra.bpmn | 224 +- .../resources/process/UpdateVfModuleInfraV2.bpmn | 412 ++ .../process/UpdateVfModuleVolumeInfraV1.bpmn | 345 +- .../src/main/resources/process/UpdateVnfInfra.bpmn | 1123 ++++++ .../src/main/resources/processengine.properties | 20 - .../subprocess/DoCreateNetworkInstance.bpmn | 42 +- .../DoCreateNetworkInstanceRollback.bpmn | 4 +- .../resources/subprocess/DoCreateVfModule.bpmn | 208 +- .../subprocess/DoCreateVfModuleRollback.bpmn | 648 +++- .../subprocess/DoCreateVfModuleVolumeRollback.bpmn | 247 ++ .../subprocess/DoCreateVfModuleVolumeV1.bpmn | 675 ---- .../subprocess/DoCreateVfModuleVolumeV2.bpmn | 362 ++ .../src/main/resources/subprocess/DoCreateVnf.bpmn | 17 +- .../subprocess/DoCreateVnfAndModules.bpmn | 224 +- .../subprocess/DoCreateVnfAndModulesRollback.bpmn | 432 ++- .../subprocess/DoDeleteNetworkInstance.bpmn | 8 +- .../DoDeleteNetworkInstanceRollback.bpmn | 4 +- .../subprocess/DoDeleteServiceInstance.bpmn | 145 +- .../subprocess/DoDeleteVfModuleFromVnf.bpmn | 396 ++ .../subprocess/DoDeleteVfModuleVolumeV2.bpmn | 208 + .../subprocess/DoDeleteVnfAndModules.bpmn | 2 +- .../subprocess/DoUpdateNetworkInstance.bpmn | 27 +- .../DoUpdateNetworkInstanceRollback.bpmn | 4 +- .../resources/subprocess/DoUpdateVfModule.bpmn | 501 +-- .../subprocess/DoUpdateVnfAndModules.bpmn | 274 ++ .../src/main/webapp/WEB-INF/applicationContext.xml | 14 + .../src/main/webapp/WEB-INF/web.xml | 9 +- .../scripts/CreateNetworkInstanceTest.groovy | 360 ++ .../scripts/CreateVfModuleVolumeInfraV1Test.groovy | 11 +- .../scripts/DeleteNetworkInstanceTest.groovy | 397 ++ .../scripts/DeleteVfModuleVolumeInfraV1Test.groovy | 4 + .../DoCreateNetworkInstanceRollbackTest.groovy | 349 ++ .../scripts/DoCreateNetworkInstanceTest.groovy | 3988 ++++++++++++++++++++ .../scripts/DoCreateVfModuleVolumeV1Test.groovy | 218 -- .../DoDeleteNetworkInstanceRollbackTest.groovy | 323 ++ .../scripts/DoDeleteNetworkInstanceTest.groovy | 1929 ++++++++++ .../DoUpdateNetworkInstanceRollbackTest.groovy | 315 ++ .../scripts/DoUpdateNetworkInstanceTest.groovy | 2625 +++++++++++++ .../scripts/UpdateNetworkInstanceTest.groovy | 368 ++ .../CreateGenericALaCarteServiceInstanceTest.java | 109 + .../infrastructure/CreateNetworkInstanceTest.java | 645 ++++ .../CreateVfModuleVolumeInfraV1Test.java | 72 +- .../bpmn/infrastructure/CreateVnfInfraTest.java | 3 + .../DeleteGenericALaCarteServiceInstanceTest.java | 91 + .../infrastructure/DeleteNetworkInstanceTest.java | 321 ++ .../infrastructure/DoCreateSIRollbackTest.java | 179 + .../DoCreateServiceInstanceTest.java | 98 + .../DoCreateVfModuleRollbackTest.java | 3 +- .../bpmn/infrastructure/DoCreateVfModuleTest.java | 172 +- .../DoCreateVfModuleVolumeV1Test.java | 351 -- .../DoCreateVfModuleVolumeV2Test.java | 220 ++ .../DoCreateVnfAndModulesRollbackTest.java | 405 ++ .../infrastructure/DoCreateVnfAndModulesTest.java | 354 ++ .../mso/bpmn/infrastructure/DoCreateVnfTest.java | 15 +- .../DoDeleteServiceInstanceTest.java | 88 + .../DoDeleteVfModuleFromVnfTest.java | 157 + .../bpmn/infrastructure/DoDeleteVfModuleTest.java | 11 +- .../DoDeleteVfModuleVolumeV2Test.java | 198 + .../infrastructure/DoDeleteVnfAndModulesTest.java | 190 + .../bpmn/infrastructure/DoUpdateVfModuleTest.java | 130 +- .../infrastructure/DoUpdateVnfAndModulesTest.java | 206 + .../bpmn/infrastructure/ReplaceVnfInfraTest.java | 259 ++ .../infrastructure/UpdateNetworkInstanceTest.java | 468 +++ .../infrastructure/UpdateVfModuleInfraV2Test.java | 119 + .../bpmn/infrastructure/UpdateVnfInfraTest.java | 174 + .../__files/AAI/AAI_genericVnfsByVnfId.json | 329 ++ .../resources/__files/AAI/AAI_pserverByVnfId.json | 72 + ...sdncCreateNetworkTopologyRsrcAssignResponse.xml | 17 + .../sdncCreateNetworkTopologySimResponse.xml | 19 + .../createVfModuleVolume_VID_request.json | 16 +- ...createVfModuleVolume_VID_request_noreqparm.json | 6 +- ...eVolume_queryVolumeName_AAIResponse_Success.xml | 1 + ...ryVolumeId_AAIResponse_HasVfModRelationship.xml | 62 + .../__files/CreateVfModule_VID_request.json | 18 +- .../CreateVfModule_VID_request_noPreloads.json | 18 +- .../test/resources/__files/DBUpdateResponse.xml | 4 + .../sdncDeleteNetworkTopologySimResponse.xml | 19 + ...DeleteNetworkTopologySimResponse_noExtraTag.xml | 17 + .../__files/DeleteVfModuleCallbackResponse.xml | 21 + .../deleteVfModuleVolume_VID_request_st.json | 2 +- .../createVfModuleVolume_VID_request.json | 6 +- .../__files/DoCreateVfModule_getVnfResponse.xml | 26 + .../__files/GenericFlows/getSINoRelations.xml | 6 + .../__files/GenericFlows/getSIUrlByIdVipr.xml | 7 + .../InfrastructureFlows/CreateVnfInfraRequest.json | 11 +- .../DeleteVnfInfraRequestCascadeDelete.json | 10 +- .../ReplaceVnf_VID_request.json | 49 + .../UpdateVfModule_VID_request.json | 28 +- .../InfrastructureFlows/UpdateVnf_VID_request.json | 49 + .../__files/Policy/policyAbortResponse.json | 1 + .../__files/Policy/policySkipResponse.json | 1 + .../queryVolumeId_AAIResponse_Success.xml | 4 +- .../updateVfModuleVolume_VID_request.json | 14 +- .../updateVfModuleVolume_VID_request_2.json | 14 +- .../vf_module_aai_response.xml | 4 +- ...alogServiceResourcesDataForReplaceVnfInfra.json | 93 + ...talogServiceResourcesDataForUpdateVnfInfra.json | 105 + .../__files/VIPR/serviceDecompositionATMFW.json | 110 + .../__files/VfModularity/DBUpdateResponse.xml | 2 +- .../GenerateVfModuleName_AAIResponse_Success.xml | 2 +- .../resources/__files/VfModularity/GenericVnf.xml | 2 +- .../VfModularity/SDNCTopologyQueryCallback.xml | 2 +- .../SDNCTopologyQueryCallbackVfModule.xml | 2 +- .../SDNCTopologyQueryCallbackVfModuleNoVnf.xml | 81 + .../VfModularity/SDNCTopologyQueryCallbackVnf.xml | 82 + .../__files/VfModularity/VfModule-lukewarm.xml | 2 +- .../__files/VfModularity/VfModule-new.xml | 2 +- .../__files/VfModularity/VfModule-supercool.xml | 2 +- .../src/test/resources/mso.bpmn.urn.properties | 38 +- 161 files changed, 28967 insertions(+), 7762 deletions(-) delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowAsyncInfrastructureResource.java delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/ReplaceVnfInfra.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/TestHelloWorld.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfraV2.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVnfInfra.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV1.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV1Test.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_pserverByVnfId.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DBUpdateResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSINoRelations.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policyAbortResponse.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policySkipResponse.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml (limited to 'bpmn/MSOInfrastructureBPMN') diff --git a/bpmn/MSOInfrastructureBPMN/pom.xml b/bpmn/MSOInfrastructureBPMN/pom.xml index 5c0eff96bb..24c8546b8d 100644 --- a/bpmn/MSOInfrastructureBPMN/pom.xml +++ b/bpmn/MSOInfrastructureBPMN/pom.xml @@ -214,13 +214,7 @@ 1.10.19 test - - - org.camunda.bpm.workbench - camunda-workbench-dist-embeddable - 1.0.0-alpha8 - test - + @@ -229,6 +223,11 @@ camunda-spin-dataformat-all compile + + camunda-spin-dataformat-all + org.camunda.spin + compile + org.camunda.bpm camunda-engine-plugin-spin @@ -330,6 +329,13 @@ ${project.version} + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + com.github.tomakehurst wiremock @@ -380,10 +386,25 @@ - javax.servlet - javax.servlet-api - 3.0.1 - provided - + org.camunda.bpm + camunda-engine-spring + + + org.springframework + spring-beans + 4.3.2.RELEASE + + + + org.camunda.bpm.workbench + camunda-workbench-dist-embeddable + 1.0.0-alpha8 + test + + + org.jboss.resteasy + resteasy-jackson2-provider + 3.0.11.Final + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy index ec414a4ee2..e7190291da 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy @@ -39,7 +39,7 @@ import org.apache.commons.codec.binary.Base64; import org.springframework.web.util.UriUtils /** - * This groovy class supports the CreateServiceInstance.bpmn process. + * This groovy class supports the CreateGenericALaCarteServiceInstance.bpmn process. * AlaCarte flow for 1702 ServiceInstance Create * */ @@ -118,8 +118,29 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro execution.setVariable("subscriptionServiceType", subscriptionServiceType) } + + /* + * Extracting User Parameters from incoming Request and converting into a Map + */ + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + + Map reqMap = jsonSlurper.parseText(siRequest) + + //InputParams + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map inputMap = [:] + if (userParams) { + userParams.each { + userParam -> inputMap.put(userParam.name, userParam.value) + } + } + + utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) + execution.setVariable("serviceInputParams", inputMap) + //TODO - //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) //execution.setVariable("failExists", true) } catch (BpmnError e) { @@ -168,7 +189,7 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro } String buildworkflowException = - """ + """ ${errorMessage} 7000 """ @@ -192,9 +213,9 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro String source = execution.getVariable("source") String msoCompletionRequest = - """ - + """ + ${requestId} CREATE ${source} @@ -228,7 +249,7 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro String requestId = execution.getVariable("msoRequestId") String source = execution.getVariable("source") String requestInfo = - """ + """ ${requestId} CREATE ${source} @@ -241,15 +262,15 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() String requestId = execution.getVariable("msoRequestId") String falloutRequest = - """ - + """ + ${requestId} CREATE VID - + ${errorException} 7000 diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy deleted file mode 100644 index 79508cb8cb..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy +++ /dev/null @@ -1,804 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.decomposition.ModelInfo -import org.openecomp.mso.bpmn.core.decomposition.NetworkResource -import org.openecomp.mso.bpmn.core.decomposition.ServiceDecomposition -import org.openecomp.mso.bpmn.core.decomposition.VnfResource -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the CreateGenericMacroServiceNetworkVnf.bpmn process. - * - */ -public class CreateGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { - - String Prefix="CGMSNV_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - CatalogDbUtils catalogDbUtils = new CatalogDbUtils() - - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("createViprServiceRequest", "") - execution.setVariable("globalSubscriberId", "") - execution.setVariable("serviceInstanceName", "") - execution.setVariable("msoRequestId", "") - execution.setVariable("CGMSNV_NetworksCreatedCount", 0) - execution.setVariable("CGMSNV_VnfsCreatedCount", 0) - execution.setVariable("productFamilyId", "") - - //TODO - execution.setVariable("sdncVersion", "1707") - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // check for incoming json message/input - String createViprServiceRequest = execution.getVariable("bpmnRequest") - utils.logAudit(createViprServiceRequest) - execution.setVariable("createViprServiceRequest", createViprServiceRequest); - println 'createViprServiceRequest - ' + createViprServiceRequest - - // extract requestId - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { - serviceInstanceId = UUID.randomUUID().toString() - utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled) - } else { - utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled) - } - - serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceInstanceId) - - String requestAction = execution.getVariable("requestAction") - execution.setVariable("requestAction", requestAction) - - String source = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) - } - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") - - // verify element global-customer-id is sent from JSON input, throw exception if missing - if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) { - String dataErrorMessage = " Element 'globalSubscriberId' is missing. " - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - execution.setVariable("globalCustomerId", globalSubscriberId) - } - - // extract subscriptionServiceType - String subscriptionServiceType = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - String suppressRollback = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """ - ${requestId} - CREATE - ${source} - """ - - execution.setVariable("CGMSNV_requestInfo", requestInfo) - - utils.log("DEBUG", " ***** Completed preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // - // ******************************* - public void prepareDecomposeService(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - String createViprServiceRequest = execution.getVariable("createViprServiceRequest") - String serviceModelInfo = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.modelInfo") - execution.setVariable("serviceModelInfo", serviceModelInfo) - - utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // - // ******************************* - public void prepareCreateServiceInstance(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - /* - * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject - * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - * ModelInfo modelInfo = serviceDecomposition.getModelInfo() - * - */ - String createViprServiceRequest = execution.getVariable("createViprServiceRequest") - String serviceInputParams = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestParameters") - execution.setVariable("serviceInputParams", serviceInputParams) - - String serviceInstanceName = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.instanceName") - execution.setVariable("serviceInstanceName", serviceInstanceName) - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString()) - - utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void postProcessServiceInstanceCreate (Execution execution){ - def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceInstanceName = execution.getVariable("serviceInstanceName") - - try { - - String payload = """ - - - - - ${requestId} - BPEL - ${serviceInstanceId} - ${serviceInstanceName} - - - - """ - execution.setVariable("CGMSNV_setUpdateDbInstancePayload", payload) - utils.logAudit("CGMSNV_setUpdateDbInstancePayload: " + payload) - logDebug('Exited ' + method, isDebugLogEnabled) - //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload")) - - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - } - - - public void getDataFromDecomposition (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside getDataFromDecomposition() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - List networkList = serviceDecomposition.getServiceNetworks() - - //utils.log("DEBUG", "got network list: "+ networkList.toString(), isDebugEnabled) - execution.setVariable("networkList", networkList) - execution.setVariable("networkListString", networkList.toString()) - - networkList = execution.getVariable("networkList"); - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - if (networkList != null && networkList.size() > 0) { - - execution.setVariable("CGMSNV_NetworksCount", networkList.size()) - utils.log("DEBUG", "networks to create: "+ networkList.size(), isDebugEnabled) - } else { - execution.setVariable("CGMSNV_NetworksCount", 0) - utils.log("DEBUG", "no networks to create based upon serviceDecomposition content", isDebugEnabled) - } - - // VNFs - List vnfList = serviceDecomposition.getServiceVnfs() - execution.setVariable("vnfList", vnfList) - - String vnfModelInfoString = "" - if (vnfList != null && vnfList.size() > 0) { - execution.setVariable("CGMSNV_VNFsCount", vnfList.size()) - utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled) - ModelInfo vnfModelInfo = vnfList[0].getModelInfo() - String vnfModelInfoWithRoot = vnfModelInfo.toString() - vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") - } else { - execution.setVariable("CGMSNV_VNFsCount", 0) - utils.log("DEBUG", "no vnfs to create based upon Catalog DB response", isDebugEnabled) - } - - execution.setVariable("vnfModelInfo", vnfModelInfoString) - //utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed getDataFromDecomposition() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. getDataFromDecomposition() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - -// String disableRollback = execution.getVariable("disableRollback") -// def backoutOnFailure = "" -// if(disableRollback != null){ -// if ( disableRollback == true) { -// backoutOnFailure = "false" -// } else if ( disableRollback == false) { -// backoutOnFailure = "true" -// } -// } - //failIfExists - optional - - String createViprServiceRequest = execution.getVariable("createViprServiceRequest") - - JSONArray networkList = execution.getVariable("networkList") - utils.log("DEBUG", "array networkList: "+ networkList, isDebugEnabled) - - if (networkList == null || networkList.size() < 1){ - networkList = new JSONArray(execution.getVariable("networkListString")) - utils.log("DEBUG", "array from string networkList: "+ networkList, isDebugEnabled) - } - - Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") - String networkModelInfoString = "" - - if (networkList != null) { - utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled) - ModelInfo networkModelInfo = networkList[networksCreatedCount.intValue()].getModelInfo() - networkModelInfoString = networkModelInfo.toString() - } else { - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected number of networks to create - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - execution.setVariable("networkModelInfo", networkModelInfoString) - utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled) - -// String networkModelInfo = execution.getVariable("networkModelInfo") - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - List vnfList = execution.getVariable("vnfList") - utils.log("DEBUG", "vnfList: "+ vnfList.toString(), isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> increment count - // ******************************* - public void validateNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") - networksCreatedCount++ - - execution.setVariable("CGMSNV_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData")) - - utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled) - utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - JSONArray networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareVnfAndModulesCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - // String disableRollback = execution.getVariable("disableRollback") - // def backoutOnFailure = "" - // if(disableRollback != null){ - // if ( disableRollback == true) { - // backoutOnFailure = "false" - // } else if ( disableRollback == false) { - // backoutOnFailure = "true" - // } - // } - //failIfExists - optional - - String createViprServiceRequest = execution.getVariable("createViprServiceRequest") - String productFamilyId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled) - - List vnfList = execution.getVariable("vnfList") - - Integer vnfsCreatedCount = execution.getVariable("CGMSNV_VnfsCreatedCount") - String vnfModelInfoString = null; - - if (vnfList != null && vnfList.size() > 0 ) { - utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled) - ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo() - utils.log("DEBUG", "got 0 ", isDebugEnabled) - ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo() - vnfModelInfoString = vnfModelInfo.toString() - } else { - //TODO: vnfList does not contain data. Need to investigate why ... . Fro VIPR use model stored - vnfModelInfoString = execution.getVariable("vnfModelInfo") - } - - utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer vnfsCreatedCount = execution.getVariable("CGMSNV_VnfsCreatedCount") - vnfsCreatedCount++ - - execution.setVariable("CGMSNV_VnfsCreatedCount", vnfsCreatedCount) - - utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> decrement count - // ******************************* - public void validateNetworkRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") - networksCreatedCount-- - - execution.setVariable("CGMSNV_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount)) - - utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage() - //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - execution.setVariable("CGMSNV_NetworksCreatedCount", 0) - utils.log("ERROR", exceptionMessage, true) - } - } - -// public void extractServiceModelInfo (Execution execution) { -// def isDebugEnabled = execution.getVariable("isDebugLogEnabled") -// String msg = "" -// utils.log("DEBUG"," ***** extractServiceModelInfo of CreateGenericMacroServiceNetworkVnf *****", isDebugEnabled) -// -// try { -// -// // check for input -// String requestId = execution.getVariable("msoRequestId") -// -// ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") -// ModelInfo modelInfo = serviceDecomposition.getModelInfo() -// -// utils.log("DEBUG", "modelInfo: "+ modelInfo.toJsonString(), isDebugEnabled) -// utils.log("DEBUG", "modelInfo: "+ modelInfo, isDebugEnabled) -// execution.setVariable("serviceDecomposition", modelInfo) -// -// utils.log("DEBUG"," ***** Exit extractServiceModelInfo of CreateGenericMacroServiceNetworkVnf *****", isDebugEnabled) -// -// } catch (BpmnError e) { -// throw e; -// } catch (Exception ex){ -// msg = "Exception in extractServiceModelInfo " + ex.getMessage() -// utils.log("DEBUG", msg, isDebugEnabled) -// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) -// } -// utils.log("DEBUG"," ***** Exit extractServiceModelInfo of DecomposeService *****", isDebugEnabled) -// } - - // ******************************* - // Build DB request Section - // ******************************* -// public void prepareDBRequest (Execution execution) { -// def isDebugEnabled=execution.getVariable("isDebugLogEnabled") -// -// try { -// utils.log("DEBUG", " ***** Inside prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) -// -// String requestId = execution.getVariable("CGMSNV_requestId") -// String statusMessage = "vIPR ATM Service Instance successfully created." -// String serviceInstanceId = execution.getVariable("CGMSNV_serviceInstanceId") -// -// //TODO - verify the format for Service Instance Create, -// String dbRequest = -// """ -// -// -// -// ${requestId} -// BPMN -// ${statusMessage} -// -// COMPLETED -// 100 -// -// ${serviceInstanceId} -// -// -// """ -// -// String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) -// execution.setVariable("CGMSNV_createDBRequest", buildDeleteDBRequestAsString) -// utils.logAudit(buildDeleteDBRequestAsString) -// -// utils.log("DEBUG", " ***** Completed prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) -// } catch (Exception ex) { -// // try error in method block -// String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() -// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) -// -// } -// -// } - - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside postProcessResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - String msoCompletionRequest = - """ - - ${requestId} - CREATE - ${source} - - Service Instance has been created successfully via macro orchestration - ${serviceInstanceId} - BPMN macro create - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("CGMSNV_Success", true) - execution.setVariable("CGMSNV_CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void preProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback of CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) - } - - public void postProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback of CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " *** STARTED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("CGMSNV_requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - //TODO. hmmm. there is no way to UPDATE error message. -// String errorMessage = wfex.getErrorMessage() -// boolean successIndicator = execution.getVariable("DCRESI_rollbackSuccessful") -// if (successIndicator){ -// errorMessage = errorMessage + ". Rollback successful." -// } else { -// errorMessage = errorMessage + ". Rollback not completed." -// } - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("CGMSNV_falloutRequest", falloutRequest) - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncError() of CreateServiceInstanceInfra ***** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """ - ${errorMessage} - 7000 - """ - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("CRESI_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(BpmnError b){ - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("CRESI_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy index 11de8d9819..54f676f731 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy @@ -1,32 +1,32 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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========================================================= +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts; + +package org.openecomp.mso.bpmn.infrastructure.scripts; import groovy.xml.XmlUtil import groovy.json.* -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse import java.util.UUID; @@ -105,12 +105,12 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) } - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) @@ -161,7 +161,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " ***** Inside sendSyncResponse() of CreateNetworkInstance ***** ", isDebugEnabled) try { - String requestId = execution.getVariable("mso-request-id") + String requestId = execution.getVariable("mso-request-id") // RESTResponse (for API Handler (APIH) Reply Task) String createNetworkRestRequest = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim() @@ -186,14 +186,11 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { try { - // "networkModelInfo" is expected to be sent - String networkModelInfo = execution.getVariable("networkModelInfo") - utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) - - // "serviceModelInfo" is expected to be sent - String serviceModelInfo = execution.getVariable("serviceModelInfo") - utils.log("DEBUG", " serviceModelInfo - " + serviceModelInfo, isDebugEnabled) - + // For Ala-Carte (sdnc = 1610): + // 1. the Network ModelInfo is expected to be sent + // via requestDetails.modelInfo (modelType = network). + // 2. the Service ModelInfo is expected to be sent but will be IGNORE + // via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service) } catch (Exception ex) { sendSyncError(execution) @@ -214,7 +211,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { try { - String requestId = execution.getVariable("mso-request-id") + String requestId = execution.getVariable("mso-request-id") // REST Error (for API Handler (APIH) Reply Task) String syncError = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim() @@ -234,6 +231,9 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { try { utils.log("DEBUG", " ***** Inside prepareDBRequestError() of CreateNetworkInstance ***** ", isDebugEnabled) + // set DB Header Authorization + setBasicDBAuthHeader(execution, isDebugEnabled) + String statusMessage = "" WorkflowException wfe = null if (execution.getVariable("WorkflowException") instanceof WorkflowException) { @@ -248,7 +248,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { """ - + ${requestId} BPMN ${statusMessage} @@ -280,13 +280,13 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { try { - String requestId = execution.getVariable("mso-request-id") + String requestId = execution.getVariable("mso-request-id") String source = execution.getVariable(Prefix + "source") String msoCompletionRequest = - """ - + """ + ${requestId} CREATE VID @@ -379,25 +379,29 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) + utils.log("DEBUG", "DB updateInfraRequest ResponseCode: " + execution.getVariable(Prefix + "dbReturnCode"), isDebugEnabled) + utils.log("DEBUG", "DB updateInfraRequest Response: " + execution.getVariable(Prefix + "createDBResponse"), isDebugEnabled) + utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) String falloutHandlerRequest = "" - String requestId = execution.getVariable("mso-request-id") + String requestId = execution.getVariable("mso-request-id") try { + WorkflowException wfe = execution.getVariable("WorkflowException") String errorCode = String.valueOf(wfe.getErrorCode()) String errorMessage = wfe.getErrorMessage() falloutHandlerRequest = - """ - + """ + ${requestId} CREATE VID - + ${errorMessage} ${errorCode} @@ -408,18 +412,18 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) } catch (Exception ex) { - String errorException = " Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - utils.log("DEBUG", errorException, isDebugEnabled) + String errorException = " Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse()" + utils.log("DEBUG", "Exception error in CreateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage(), isDebugEnabled) falloutHandlerRequest = - """ - + """ + ${requestId} CREATE VID - + ${errorException} 7000 diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index b468a5116c..74234f8d6e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -51,6 +51,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("CVFMI_sentSyncResponse", false) + def prefix = 'CVFMI_' logDebug('Entered 1' + method, isDebugLogEnabled) execution.setVariable('prefix', prefix) @@ -71,6 +73,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) utils.logAudit("CreateVfModule Infra incoming Request: " + incomingRequest) + setBasicDBAuthHeader(execution, isDebugLogEnabled) + // check if request is xml or json try { def jsonSlurper = new JsonSlurper() @@ -156,7 +160,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } } - execution.setVariable(prefix + 'disableRollback', suppressRollback) + execution.setVariable('disableRollback', suppressRollback) def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null execution.setVariable(prefix + 'vfModuleName', vfModuleName) @@ -198,9 +202,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { execution.setVariable("CVFMI_requestInfo", requestInfo) //backoutOnFailure - - //NetworkUtils networkUtils = new NetworkUtils() - //execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request)) + execution.setVariable("CVFMI_originalWorkflowException", null) @@ -266,6 +268,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { sendWorkflowResponse(execution, 200, synchResponse) + execution.setVariable("CVFMI_sentSyncResponse", true) utils.logAudit("CreateVfModule Infra Response: " + synchResponse) logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError e) { @@ -291,18 +294,6 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled) utils.log("DEBUG", "action is: " + action, isDebugEnabled) - try { - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - String payload = """ @@ -542,7 +521,29 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } - + public void sendErrorResponse(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " *** STARTED CreateVfModulenfra sendErrorResponse Process *** ", isDebugEnabled) + try { + def sentSyncResponse = execution.getVariable("CVFMI_sentSyncResponse") + if(sentSyncResponse == false){ + WorkflowException wfex = execution.getVariable("WorkflowException") + String response = exceptionUtil.buildErrorResponseXml(wfex) + + utils.logAudit(response) + sendWorkflowResponse(execution, 500, response) + }else{ + utils.log("DEBUG", "Not Sending Error Response. Sync Response Already Sent", isDebugEnabled) + } + + } catch (Exception ex) { + utils.log("DEBUG", "Error Occured in CreateVfModuleInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVfModuleInfra sendErrorResponse Process") + + } + utils.log("DEBUG", "*** COMPLETED CreateVfModuleInfra sendErrorResponse Process ***", isDebugEnabled) + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 48ca2905c1..4d40938d86 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -26,7 +26,9 @@ import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; import org.openecomp.mso.bpmn.common.scripts.VidUtils; import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse +import java.util.Map; +import groovy.json.JsonOutput import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError @@ -43,6 +45,7 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { */ public void preProcessRequest (Execution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + setBasicDBAuthHeader(execution, isDebugEnabled) preProcessRequest(execution, isDebugEnabled) } @@ -64,47 +67,96 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { try { def jsonSlurper = new JsonSlurper() Map reqMap = jsonSlurper.parseText(createVolumeIncoming) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - def vnfId = execution.getVariable('vnfId') - - def vidUtils = new VidUtils(this) - createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', serviceInstanceId) - - execution.setVariable(prefix+'Request', createVolumeIncoming) - execution.setVariable(prefix+'vnfId', vnfId) - execution.setVariable(prefix+'isVidRequest', true) - + setupVariables(execution, reqMap, isDebugEnabled) utils.log("DEBUG", "XML request:\n" + createVolumeIncoming, isDebugEnabled) - } catch(groovy.json.JsonException je) { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'Request is not a valid JSON document') } - execution.setVariable(prefix+'source', utils.getNodeText1(createVolumeIncoming, "source")) - execution.setVariable(prefix+'volumeGroupName', utils.getNodeText1(createVolumeIncoming, 'volume-group-name')) - execution.setVariable(prefix+'volumeOutputs', utils.getNodeXml(createVolumeIncoming, 'volume-outputs', false)) - - execution.setVariable(prefix+'serviceType', 'service-instance') - execution.setVariable(prefix+'serviceInstanceId', utils.getNodeText1(createVolumeIncoming, "service-instance-id")) + // For rollback in this flow + setBasicDBAuthHeader(execution, isDebugEnabled) + setRollbackEnabled(execution, isDebugEnabled) + } - // Generate volume group id + + /** + * Set up variables that will be passed to the BB DoCreatevfModuleVolume flow + * @param execution + * @param requestMap + * @param serviceInstanceId + * @param isDebugLogEnabled + */ + public void setupVariables(Execution execution, Map requestMap, isDebugLogEnabled) { + + def jsonOutput = new JsonOutput() + + // volumeGroupId - is generated String volumeGroupId = UUID.randomUUID() - utils.log("DEBUG", "Generated volume group id: " + volumeGroupId, isDebugEnabled) + execution.setVariable('volumeGroupId', volumeGroupId) + utils.log("DEBUG", "Generated volumeGroupId: " + volumeGroupId, isDebugLogEnabled) + + // volumeGroupName + def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: '' + execution.setVariable('volumeGroupName', volGrpName) - def testGroupId = execution.getVariable('test-volume-group-id') - if (testGroupId != null && testGroupId.trim() != '') { - volumeGroupId = testGroupId + // vfModuleModelInfo + def vfModuleModelInfo = jsonOutput.toJson(requestMap.requestDetails?.modelInfo) + execution.setVariable('vfModuleModelInfo', vfModuleModelInfo) + + // lcpCloudRegonId + def lcpCloudRegionId = requestMap.requestDetails.cloudConfiguration.lcpCloudRegionId + execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + + // tenant + def tenantId = requestMap.requestDetails.cloudConfiguration.tenantId + execution.setVariable('tenantId', tenantId) + + // source + def source = requestMap.requestDetails.requestInfo.source + execution.setVariable(prefix+'source', source) + + // vnfType and asdcServiceModelVersion + + def serviceName = '' + def asdcServiceModelVersion = '' + def modelCustomizationName = '' + + def relatedInstanceList = requestMap.requestDetails.relatedInstanceList + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + serviceName = it.relatedInstance.modelInfo?.modelName + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + } + if (it.relatedInstance.modelInfo?.modelType == 'vnf') { + modelCustomizationName = it.relatedInstance.modelInfo?.modelCustomizationName + } } + + def vnfType = serviceName + '/' + modelCustomizationName + execution.setVariable('vnfType', vnfType) + execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion) + + // vfModuleInputParams + def userParams = requestMap.requestDetails?.requestParameters?.userParams + Map vfModuleInputMap = [:] + + userParams.each { userParam -> + vfModuleInputMap.put(userParam.name, userParam.value) + } + execution.setVariable('vfModuleInputParams', vfModuleInputMap) - execution.setVariable(prefix+'volumeGroupId', volumeGroupId) - + // disableRollback (true or false) + def disableRollback = requestMap.requestDetails.requestInfo.suppressRollback + execution.setVariable('disableRollback', disableRollback) + utils.log("DEBUG", 'disableRollback (suppressRollback) from request: ' + disableRollback, isDebugLogEnabled) + } - + + public void sendSyncResponse (Execution execution, isDebugEnabled) { - def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') + def volumeGroupId = execution.getVariable('volumeGroupId') def requestId = execution.getVariable("mso-request-id") def serviceInstanceId = execution.getVariable("serviceInstanceId") @@ -137,24 +189,17 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { } + /** + * Build Infra DB Request + * @param execution + * @param isDebugEnabled + */ public void prepareDbInfraSuccessRequest(Execution execution, isDebugEnabled) { def dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') def requestId = execution.getVariable('mso-request-id') def statusMessage = "VolumeGroup successfully created." def requestStatus = "COMPLETED" def progress = "100" - - try { - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } /* from: $gVolumeGroup/aai:volume-group-id/text() @@ -180,16 +225,18 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { """ - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString) - - utils.logAudit(buildDeleteDBRequestAsString) + String buildDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable(prefix+"createDBRequest", buildDBRequestAsString) + utils.log("DEBUG", "DB Infra Request: " + buildDBRequestAsString, isDebugEnabled) + utils.logAudit(buildDBRequestAsString) } - - - + /** + * Build CommpleteMsoProcess request + * @param execution + * @param isDebugEnabled + */ public void postProcessResponse (Execution execution, isDebugEnabled) { def dbReturnCode = execution.getVariable(prefix+'dbReturnCode') @@ -300,4 +347,17 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { } } } + + public void logAndSaveOriginalException(Execution execution, isDebugLogEnabled) { + logWorkflowException(execution, 'CreateVfModuleVolumeInfraV1 caught an event') + saveWorkflowException(execution, 'CVMVINFRAV1_originalWorkflowException') + } + + public void validateRollbackResponse(Execution execution, isDebugLogEnabled) { + + def originalException = execution.getVariable("CVMVINFRAV1_originalWorkflowException") + execution.setVariable("WorkflowException", originalException) + execution.setVariable("RollbackCompleted", true) + + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy index 9b7fd6835c..311c1c727a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -26,6 +26,9 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution; import static org.apache.commons.lang3.StringUtils.*; +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils; +import org.json.JSONObject; +import org.json.JSONArray; import org.openecomp.mso.bpmn.common.scripts.AaiUtil; import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; @@ -33,6 +36,7 @@ import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils; import org.openecomp.mso.bpmn.common.scripts.VidUtils; import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.domain.VnfResource import org.openecomp.mso.bpmn.core.json.JsonUtils; @@ -47,6 +51,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) + CatalogDbUtils cutils = new CatalogDbUtils() /** * This method gets and validates the incoming @@ -59,7 +64,8 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED CreateVnfInfra PreProcessRequest Process*** ", isDebugEnabled) - + + setBasicDBAuthHeader(execution, isDebugEnabled) execution.setVariable("CREVI_sentSyncResponse", false) try{ @@ -101,7 +107,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { def vnfModelInfo = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo") execution.setVariable("CREVI_vnfModelInfo", vnfModelInfo) - String modelInvariantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelInvariantId") + String modelInvariantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelInvariantUuid") execution.setVariable("CREVI_modelInvariantId", modelInvariantId) utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) @@ -157,7 +163,13 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { } execution.setVariable("CREVI_sdncCallbackUrl", sdncCallbackUrl) - def vnfInputParameters = jsonUtil.getJsonValue(createVnfRequest, "requestParameters.userParams") + def vnfInputParameters = null + try { + vnfInputParameters = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestParameters.userParams") + } + catch (Exception e) { + utils.log("DEBUG", "userParams are not present in the request", isDebugEnabled) + } execution.setVariable("CREVI_vnfInputParameters", vnfInputParameters) @@ -429,4 +441,56 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", "*** COMPLETED CreateVnfInfra prepareFalloutRequest Process ***", isDebugEnabled) } + + public void queryCatalogDB (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " *** STARTED CreateVnfInfra QueryCatalogDB Process *** ", isDebugEnabled) + try { + //Get Vnf Info + String vnfModelInfo = execution.getVariable("CREVI_vnfModelInfo") + String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") + utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugEnabled) + + JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(execution, + vnfModelCustomizationUuid, "v2") + utils.log("DEBUG", "obtained VNF list: " + vnfs, isDebugEnabled) + execution.setVariable("CREVI_vnfs", vnfs) + + if (vnfs == null) { + utils.log("ERROR", "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid) + } + + // Only one match here + JSONObject vnf = vnfs.get(0) + + if (vnf == null) { + utils.log("ERROR", "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid) + } + + VnfResource vnfResource = new VnfResource() + String nfType = jsonUtil.getJsonValueForKey(vnf, "nfType") + vnfResource.setNfType(nfType) + String nfRole = jsonUtil.getJsonValueForKey(vnf, "nfRole") + vnfResource.setNfRole(nfRole) + String nfFunction = jsonUtil.getJsonValueForKey(vnf, "nfFunction") + vnfResource.setNfFunction(nfFunction) + String nfNamingCode = jsonUtil.getJsonValueForKey(vnf, "nfNamingCode") + vnfResource.setNfNamingCode(nfNamingCode) + + execution.setVariable("CREVI_vnfResourceDecomposition", vnfResource) + + }catch(BpmnError e) { + throw e; + }catch(Exception ex) { + utils.log("DEBUG", "Error Occurred in CreateVnfInfra QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra QueryCatalogDB Process") + } + + + utils.log("DEBUG", "*** COMPLETED CreateVnfInfra QueryCatalogDb Process ***", isDebugEnabled) + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy index 7555885bcb..c3aadaf61e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy @@ -126,6 +126,27 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro } else { execution.setVariable("subscriptionServiceType", subscriptionServiceType) } + + /* + * Extracting User Parameters from incoming Request and converting into a Map + */ + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + + Map reqMap = jsonSlurper.parseText(siRequest) + + //InputParams + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map inputMap = [:] + if (userParams) { + userParams.each { + userParam -> inputMap.put(userParam.name, userParam.value) + } + } + + utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) + execution.setVariable("serviceInputParams", inputMap) } catch (BpmnError e) { throw e; @@ -171,7 +192,7 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro } String buildworkflowException = - """ + """ ${errorMessage} 7000 """ @@ -193,9 +214,9 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro String requestId = execution.getVariable("msoRequestId") String source = execution.getVariable("source") String msoCompletionRequest = - """ - + """ + ${requestId} DELETE ${source} @@ -228,7 +249,7 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro String requestId = execution.getVariable("msoRequestId") String source = execution.getVariable("source") String requestInfo = - """ + """ ${requestId} DELETE ${source} @@ -241,15 +262,15 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() String requestId = execution.getVariable("msoRequestId") String falloutRequest = - """ - + """ + ${requestId} DELETE VID - + ${errorException} 7000 @@ -279,7 +300,7 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro """ - + ${requestId} BPMN ${statusMessage} @@ -328,7 +349,7 @@ public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskPro """ - + ${requestId} BPMN ${statusMessage} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy deleted file mode 100644 index 108f8d3751..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy +++ /dev/null @@ -1,468 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; - - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the DeleteViprAtmService.bpmn process. - * - */ -public class DeleteGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { - - String Prefix="DELVAS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - CatalogDbUtils catalogDbUtils = new CatalogDbUtils() - NetworkUtils networkUtils = new NetworkUtils() - - /** - * This method is executed during the preProcessRequest task of the DeleteGenericMacroServiceNetworkVnf.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("DeleteGenericMacroServiceNetworkVnfRequest", "") - execution.setVariable("msoRequestId", "") - execution.setVariable("DELVAS_vnfsDeletedCount", 0) - execution.setVariable("DELVAS_vnfsCount", 0) - execution.setVariable("DELVAS_networksCount", 0) - execution.setVariable("DELVAS_networksDeletedCount", 0) - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest DeleteGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // check for incoming json message/input - String DeleteGenericMacroServiceNetworkVnfRequest = execution.getVariable("bpmnRequest") - utils.logAudit(DeleteGenericMacroServiceNetworkVnfRequest) - execution.setVariable("DeleteGenericMacroServiceNetworkVnfRequest", DeleteGenericMacroServiceNetworkVnfRequest); - println 'DeleteGenericMacroServiceNetworkVnfRequest - ' + DeleteGenericMacroServiceNetworkVnfRequest - - // extract requestId - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { - String dataErrorMessage = " Element 'serviceInstanceId' is missing. " - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - String requestAction = execution.getVariable("requestAction") - execution.setVariable("requestAction", requestAction) - - String source = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) - } - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.subscriberInfo.globalSubscriberId") - - // global-customer-id is optional on Delete - - execution.setVariable("globalSubscriberId", globalSubscriberId) - execution.setVariable("globalCustomerId", globalSubscriberId) - - String suppressRollback = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - // extract subscriptionServiceType - String subscriptionServiceType = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = "1707" - execution.setVariable("sdncVersion", sdncVersion) - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """ - ${requestId} - DELETE - ${source} - """ - - execution.setVariable("DELVAS_requestInfo", requestInfo) - - //Setting for Generic Sub Flows - execution.setVariable("GENGS_type", "service-instance") - - utils.log("DEBUG", " ***** Completed preProcessRequest DeleteGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareServiceInstanceDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // confirm if ServiceInstance was found - if ( !execution.getVariable("GENGS_FoundIndicator") ) - { - String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Service Instance was not found in AAI by id: " + serviceInstanceId - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - // get variable within incoming json - String DeleteGenericMacroServiceNetworkVnfRequest = execution.getVariable("DeleteGenericMacroServiceNetworkVnfRequest"); - - // get SI extracted by GenericGetService - String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); - - utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled) - - String relationship = "" - try { - relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list") - } catch (Exception ex) { - //no relationships found - } - utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled) - - int vnfsCount = 0 - int networksCount = 0 - - if (relationship != null && relationship.length() > 0){ - relationship = relationship.trim().replace("tag0:","").replace(":tag0","") - - // Check if Network TableREf is present, then build a List of network policy - List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship) - vnfsCount = relatedVnfIdList.size() - execution.setVariable("DELVAS_vnfsCount", vnfsCount) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList) - - // Check if Network TableREf is present, then build a List of network policy - List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship) - networksCount = relatedNetworkIdList.size() - execution.setVariable("DELVAS_networksCount", networksCount) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList) - } else { - execution.setVariable("DELVAS_vnfsCount", 0) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_networksCount", 0) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - } - - utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. prepareServiceInstanceDelete() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - // ******************************* - // - // ******************************* - public void prepareVnfAndModulesDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) - - List vnfList = execution.getVariable("DELVAS_relatedVnfIdList") - Integer vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") - String vnfModelInfoString = "" - String vnfId = "" - if (vnfList.size() > 0 ) { - vnfId = vnfList.get(vnfsDeletedCount.intValue()) - } - - execution.setVariable("vnfId", vnfId) - utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") - vnfsDeletedCount++ - - execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount) - - utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - List networkList = execution.getVariable("DELVAS_relatedNetworkIdList") - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - - String networkId = "" - if (networkList.size() > 0) { - networkId = networkList.get(networksDeletedCount.intValue()) - } - - execution.setVariable("networkId", networkId) - utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = q"Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section - // ******************************* - public void validateNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - networksDeletedCount++ - - execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount) - - utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("msoRequestId") - - String msoCompletionRequest = - """ - - ${requestId} - DELETE - ${source} - - vIPR ATM Service Instance has been deleted successfully. - BPMN Service Instance macro action: DELETE - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("DELVAS_Success", true) - execution.setVariable("DELVAS_CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** STARTED DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("DELVAS_requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("DELVAS_falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """ - ${errorMessage} - 7000 - """ - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("DELVAS_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(BpmnError b){ - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("DELVAS_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } - - -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy index e18af172de..b8629c39f8 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy @@ -153,10 +153,11 @@ public class DeleteNetworkInstance extends AbstractServiceTaskProcessor { try { - // "networkModelInfo" is expected to be sent - String networkModelInfo = execution.getVariable("networkModelInfo") - utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) - + // For Ala-Carte (sdnc = 1610): + // 1. the Network ModelInfo is expected to be sent + // via requestDetails.modelInfo (modelType = network), ex: modelCustomizationId. + // 2. the Service ModelInfo is expected to be sent but will be IGNORE + // via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service) } catch (Exception ex) { sendSyncError(execution) @@ -241,7 +242,10 @@ public class DeleteNetworkInstance extends AbstractServiceTaskProcessor { try { utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteNetworkInstance ***** ", isDebugEnabled) - + + // set DB Header Authorization + setBasicDBAuthHeader(execution, isDebugEnabled) + WorkflowException wfe = execution.getVariable("WorkflowException") String statusMessage = wfe.getErrorMessage() String requestId = execution.getVariable(Prefix +"requestId") diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy index f8b3b4739f..021cdbb4c5 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy @@ -110,18 +110,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", " Request in XML format: " + requestInXmlFormat, isDebugLogEnabled) - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + setBasicDBAuthHeader(execution, isDebugLogEnabled) execution.setVariable(prefix + 'Request', requestInXmlFormat) execution.setVariable(prefix+'vnfId', vnfId) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index 7bda7b4fe3..547b5f3bb6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -132,18 +132,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { execution.setVariable('DELVfModVol_volumeParams', utils.getNodeXml(request, 'volume-params')) execution.setVariable('DELVfModVol_cloudRegion', utils.getNodeText1(request, 'aic-cloud-region')) - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + setBasicDBAuthHeader(execution, isDebugLogEnabled) logDebug('Request: ' + createVolumeIncoming, isDebugLogEnabled) } @@ -436,7 +425,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { public void prepareDBRequest (Execution execution, isDebugLogEnabled) { WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException") - + ExceptionUtil exceptionUtil = new ExceptionUtil(); def requestId = execution.getVariable('DELVfModVol_requestId') def volOutputs = execution.getVariable('DELVfModVol_volumeOutputs') def statusMessage = "VolumeGroup successfully deleted" @@ -450,7 +439,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { requestStatus = "FAILURE" progress = "" } - + String updateInfraRequest = """ diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index d221d0622b..53c878dc22 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -448,7 +448,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // get variables String networkId = "" String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - if (execution.getVariable("sdncVersion") == "1702") { + if (execution.getVariable("sdncVersion") != "1610") { String networkResponseInformation = "" try { networkResponseInformation = utils.getNodeXml(assignSDNCResponse, "network-response-information", false).replace("tag0:","").replace(":tag0","") @@ -655,9 +655,9 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { 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) + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" } } else { @@ -666,7 +666,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" } utils.logAudit(queryVpnBindingAAIRequest) @@ -789,9 +789,9 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { 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) + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" } } else { // using uri value in URN mapping @@ -800,7 +800,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" } @@ -925,9 +925,9 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { 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) + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" } } else { // using uri value in URN mapping @@ -936,7 +936,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" } @@ -1236,7 +1236,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "ActivateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) utils.logAudit(sndcTopologyCreateRequesAsString) @@ -1598,7 +1598,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { - if (execution.getVariable("sdncVersion") == '1702') { + if (execution.getVariable("sdncVersion") != '1610') { prepareRpcSDNCRollbackRequest(execution) prepareRpcSDNCActivateRollback(execution) } else { diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index 9f28db727d..49aa948c44 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -23,12 +23,14 @@ import static org.apache.commons.lang3.StringUtils.*; import groovy.xml.XmlUtil import groovy.json.* +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.ServiceInstance +import org.openecomp.mso.bpmn.core.domain.ModelInfo import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse; @@ -57,8 +59,10 @@ import org.springframework.web.util.UriUtils; * @param - productFamilyId * @param - disableRollback * @param - failExists - TODO - * @param - serviceInputParams - Deferred/TODO + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) * @param - sdncVersion ("1610") + * @param - serviceDecomposition - Decomposition for R1710 + * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored) * * Outputs: * @param - rollbackData (localRB->null) @@ -72,7 +76,6 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String Prefix="DCRESI_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() public void preProcessRequest (Execution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -82,19 +85,11 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { try { String requestId = execution.getVariable("msoRequestId") execution.setVariable("prefix", Prefix) - + //Inputs //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData & SDNC assignToplology - String serviceInstanceName = execution.getVariable("serviceInstanceName") - //Generated in parent for AAI PUT - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - //requestDetails.modelInfo. for AAI PUT servieInstanceData & SDNC assignTopology - String serviceModelInfo = execution.getVariable("serviceModelInfo") - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology String subscriptionServiceType = execution.getVariable("subscriptionServiceType") @@ -106,21 +101,13 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(serviceModelInfo)) { - msg = "Input serviceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } + if (isBlank(subscriptionServiceType)) { msg = "Input subscriptionServiceType is null" utils.log("DEBUG", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } + if (productFamilyId == null) { execution.setVariable("productFamilyId", "") } @@ -134,30 +121,152 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - String modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") - String modelVersionId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") + //requestDetails.modelInfo.for AAI PUT servieInstanceData & SDNC assignTopology + String modelInvariantUuid = "" + String modelVersion = "" + String modelUuid = "" + String modelName = "" + String serviceInstanceName = "" + //Generated in parent.for AAI PUT + String serviceInstanceId = "" + String serviceType = "" + String serviceRole = "" - if (modelInvariantId == null) { - modelInvariantId = "" + ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") + if (serviceDecomp != null) + { + serviceType = serviceDecomp.getServiceType() + if (serviceType == null) + { + utils.log("DEBUG", "null serviceType", isDebugEnabled) + serviceType = "" + } + else + { + utils.log("DEBUG", "serviceType:" + serviceType, isDebugEnabled) + } + serviceRole = serviceDecomp.getServiceRole() + if (serviceRole == null) + { + serviceRole = "" + } + + ServiceInstance serviceInstance = serviceDecomp.getServiceInstance() + if (serviceInstance != null) + { + serviceInstanceId = serviceInstance.getInstanceId() + serviceInstanceName = serviceInstance.getInstanceName() + execution.setVariable("serviceInstanceId", serviceInstanceId) + execution.setVariable("serviceInstanceName", serviceInstanceName) + } + + ModelInfo modelInfo = serviceDecomp.getModelInfo() + if (modelInfo != null) + { + modelInvariantUuid = modelInfo.getModelInvariantUuid() + modelVersion = modelInfo.getModelVersion() + modelUuid = modelInfo.getModelUuid() + modelName = modelInfo.getModelName() + } + else + { + msg = "Input serviceModelInfo is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } } - if (modelVersionId == null) { - modelVersionId = "" + else + { + //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData & SDNC assignToplology + serviceInstanceName = execution.getVariable("serviceInstanceName") + serviceInstanceId = execution.getVariable("serviceInstanceId") + + String serviceModelInfo = execution.getVariable("serviceModelInfo") + if (isBlank(serviceModelInfo)) { + msg = "Input serviceModelInfo is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + //modelCustomizationUuid NA for SI + } + execution.setVariable("serviceType", serviceType) + execution.setVariable("serviceRole", serviceRole) + if (serviceInstanceName == null) { execution.setVariable("serviceInstanceName", "") serviceInstanceName = "" } + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (modelInvariantUuid == null) { + modelInvariantUuid = "" + } + if (modelUuid == null) { + modelUuid = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelName == null) { + modelName = "" + } + + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + execution.setVariable("modelVersion", modelVersion) + execution.setVariable("modelUuid", modelUuid) + execution.setVariable("modelName", modelName) + StringBuilder sbParams = new StringBuilder() + Map paramsMap = execution.getVariable("serviceInputParams") + if (paramsMap != null) + { + sbParams.append("") + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ + ${paramName} + ${paramValue} + + """ + sbParams.append(paramsXml) + } + sbParams.append("") + } + String siParamsXml = sbParams.toString() + if (siParamsXml == null) + siParamsXml = "" + execution.setVariable("siParamsXml", siParamsXml) + //AAI PUT + String oStatus= "Active" + if ("TRANSPORT".equalsIgnoreCase(serviceType)) + { + oStatus = "Created" + } + AaiUtil aaiUriUtil = new AaiUtil(this) String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) String serviceInstanceData = """ ${serviceInstanceName} - Active - ${modelInvariantId} - ${modelVersionId} + ${serviceType} + ${serviceRole} + ${oStatus} + ${modelInvariantUuid} + ${modelUuid} """.trim() execution.setVariable("serviceInstanceData", serviceInstanceData) @@ -340,27 +449,17 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { def serviceId = execution.getVariable("productFamilyId") def subscriptionServiceType = execution.getVariable("subscriptionServiceType") def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + def serviceType = execution.getVariable("serviceType") - String serviceModelInfo = execution.getVariable("serviceModelInfo") - def modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") - def modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") - def modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") - def modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + def modelInvariantUuid = execution.getVariable("modelInvariantUuid") + def modelVersion = execution.getVariable("modelVersion") + def modelUuid = execution.getVariable("modelUuid") + def modelName = execution.getVariable("modelName") + def sdncRequestId = UUID.randomUUID().toString() - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersion == null) { - modelVersion = "" - } - if (modelUUId == null) { - modelUUId = "" - } - if (modelName == null) { - modelName = "" - } - + def siParamsXml = execution.getVariable("siParamsXml") + String sdncAssignRequest = """assign service-topology-operation ${callbackURL} + ${serviceType} @@ -385,8 +485,8 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { ${serviceId} ${subscriptionServiceType} - ${modelInvariantId} - ${modelUUId} + ${modelInvariantUuid} + ${modelUuid} ${modelVersion} ${modelName} @@ -396,6 +496,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { ${serviceInstanceName} + ${siParamsXml} """ diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 1fd5ab0abc..8bd3c5a4c3 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -67,7 +67,7 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable('prefix', Prefix) try{ - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") if (rollbackData == null) { rollbackData = new RollbackData() } @@ -140,6 +140,7 @@ public class DoCreateVfModule extends VfModuleBase { def requestId = execution.getVariable("msoRequestId") execution.setVariable("DCVFM_requestId", requestId) logDebug("requestId: " + requestId, isDebugLogEnabled) + rollbackData.put("VFMODULE", "msorequestid", requestId) // Set mso-request-id to request-id for VNF Adapter interface execution.setVariable("mso-request-id", requestId) //serviceId @@ -159,7 +160,7 @@ public class DoCreateVfModule extends VfModuleBase { //backoutOnFailure def disableRollback = execution.getVariable("disableRollback") def backoutOnFailure = true - if (disableRollback != null && disableRollback.equals("true")) { + if (disableRollback != null && disableRollback == true) { backoutOnFailure = false } execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure) @@ -173,9 +174,9 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion) logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) //personaModelId - execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId")) + execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid")) //personaModelVersion - execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersionId")) + execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelUuid")) //vfModuleLabel def vfModuleLabel = execution.getVariable("vfModuleLabel") if (vfModuleLabel != null) { @@ -437,7 +438,7 @@ public class DoCreateVfModule extends VfModuleBase { logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugLogEnabled) - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) }catch(BpmnError b){ throw b }catch(Exception e){ @@ -501,7 +502,7 @@ public class DoCreateVfModule extends VfModuleBase { def createResponse = execution.getVariable('DCVFM_createVfModuleResponse') utils.logAudit("createVfModule Response: " + createResponse) - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") String vnfName = utils.getNodeText1(createResponse, 'vnf-name') if (vnfName != null) { execution.setVariable('DCVFM_vnfName', vnfName) @@ -521,7 +522,7 @@ public class DoCreateVfModule extends VfModuleBase { rollbackData.put("VFMODULE", "vfmoduleid", vfModuleId) rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "true") rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "true") - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) } catch (Exception ex) { ex.printStackTrace() logDebug('Exception occurred while postProcessing CreateAAIVfModule request:' + ex.getMessage(),isDebugLogEnabled) @@ -812,13 +813,25 @@ public class DoCreateVfModule extends VfModuleBase { } Map vnfParamsMap = execution.getVariable("DCVFM_vnfParamsMap") + String vfModuleParams = "" + //Get SDNC Response Data for VF Module Topology + String vfModuleSdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse') + utils.logAudit("sdncGetResponse: " + vfModuleSdncGetResponse) + def sdncVersion = execution.getVariable("sdncVersion") - //Get SDNC Response Data for VnfSubCreate Request - String sdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse') - utils.logAudit("sdncGetResponse: " + sdncGetResponse) - - String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName, + if (!sdncVersion.equals("1707")) { + + vfModuleParams = buildVfModuleParams(vnfParamsMap, vfModuleSdncGetResponse, vnfId, vnfName, vfModuleId, vfModuleName, vfModuleIndex) + } + else { + //Get SDNC Response Data for Vnf Topology + String vnfSdncGetResponse = execution.getVariable('DCVFM_getVnfSDNCAdapterResponse') + utils.logAudit("vnfSdncGetResponse: " + vnfSdncGetResponse) + + vfModuleParams = buildVfModuleParamsFromCombinedTopologies(vnfParamsMap, vnfSdncGetResponse, vfModuleSdncGetResponse, vnfId, vnfName, + vfModuleId, vfModuleName, vfModuleIndex) + } def svcInstId = "" if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { @@ -1006,7 +1019,7 @@ public class DoCreateVfModule extends VfModuleBase { def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid") def modelCustomizationUuidString = "" if (!usePreload) { - modelCustomizationUuidString = "" + modelCustomizationUuid + "" + modelCustomizationUuidString = "" + modelCustomizationUuid + "" } String sdncVNFParamsXml = "" @@ -1026,7 +1039,7 @@ public class DoCreateVfModule extends VfModuleBase { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${svcInstId} ${action} vnf-topology-operation @@ -1069,7 +1082,7 @@ public class DoCreateVfModule extends VfModuleBase { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${svcInstId} ${action} vf-module-topology-operation @@ -1210,7 +1223,7 @@ public class DoCreateVfModule extends VfModuleBase { logDebug("VNF Adapter Response is: " + vnfResponse, isDebugLogEnabled) utils.logAudit("createVnfAResponse is: \n" + vnfResponse) - RollbackData rollbackData = execution.getVariable("RollbackData") + RollbackData rollbackData = execution.getVariable("rollbackData") if(vnfResponse != null){ if(vnfResponse.contains("createVfModuleResponse")){ @@ -1273,7 +1286,7 @@ public class DoCreateVfModule extends VfModuleBase { } rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "true") - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) }catch(BpmnError b){ throw b @@ -1364,7 +1377,7 @@ public class DoCreateVfModule extends VfModuleBase { String sdncResponse = response if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - RollbackData rollbackData = execution.getVariable("RollbackData") + RollbackData rollbackData = execution.getVariable("rollbackData") if(method.equals("assign")){ rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "true") @@ -1373,7 +1386,7 @@ public class DoCreateVfModule extends VfModuleBase { else if (method.equals("activate")) { rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "true") } - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) }else{ logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) throw new BpmnError("MSOWorkflowException") @@ -1613,7 +1626,7 @@ public class DoCreateVfModule extends VfModuleBase { // get variables List fqdnList = execution.getVariable("DCVFM_contrailNetworkPolicyFqdnList") int fqdnCount = fqdnList.size() - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") execution.setVariable("DCVFM_networkPolicyFqdnCount", fqdnCount) logDebug("DCVFM_networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled) @@ -1701,7 +1714,7 @@ public class DoCreateVfModule extends VfModuleBase { logDebug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut, isDebugLogEnabled) rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) } else { // aai all errors @@ -1758,7 +1771,7 @@ public class DoCreateVfModule extends VfModuleBase { logDebug('Entered ' + method, isDebugLogEnabled) try { - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") def vnfId = execution.getVariable('DCVFM_vnfId') def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address") def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address") @@ -1839,6 +1852,47 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage()) } } + + public void preProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) + } + public void postProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index af1161b656..08f1f50c37 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -47,71 +47,96 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ initProcessVariables(execution) - def rollbackData = execution.getVariable("RollbackData") - String vnfId = rollbackData.get("VFMODULE", "vnfid") - execution.setVariable("DCVFMR_vnfId", vnfId) - String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid") - execution.setVariable("DCVFMR_vfModuleId", vfModuleId) - String source = rollbackData.get("VFMODULE", "source") - execution.setVariable("DCVFMR_source", source) - String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId") - execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) - String serviceId = rollbackData.get("VFMODULE", "service-id") - execution.setVariable("DCVFMR_serviceId", serviceId) - String vnfType = rollbackData.get("VFMODULE", "vnftype") - execution.setVariable("DCVFMR_vnfType", vnfType) - String vnfName = rollbackData.get("VFMODULE", "vnfname") - execution.setVariable("DCVFMR_vnfName", vnfName) - String tenantId = rollbackData.get("VFMODULE", "tenantid") - execution.setVariable("DCVFMR_tenantId", tenantId) - String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename") - execution.setVariable("DCVFMR_vfModuleName", vfModuleName) - String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname") - execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName) - String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion") - execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) - String heatStackId = rollbackData.get("VFMODULE", "heatstackid") - execution.setVariable("DCVFMR_heatStackId", heatStackId) - String requestId = rollbackData.get("VFMODULE", "attmsorequestid") - execution.setVariable("DCVFMR_requestId", requestId) - List createdNetworkPolicyFqdnList = [] - int i = 0 - while (i < 100) { - String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i) - if (fqdn == null) { - break - } - createdNetworkPolicyFqdnList.add(fqdn) - logDebug("got fqdn # " + i + ": " + fqdn, isDebugEnabled) - i = i + 1 + try { + execution.setVariable("rolledBack", null) + execution.setVariable("rollbackError", null) + + def rollbackData = execution.getVariable("rollbackData") + utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) + + if (rollbackData != null) { + String vnfId = rollbackData.get("VFMODULE", "vnfid") + execution.setVariable("DCVFMR_vnfId", vnfId) + String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid") + execution.setVariable("DCVFMR_vfModuleId", vfModuleId) + String source = rollbackData.get("VFMODULE", "source") + execution.setVariable("DCVFMR_source", source) + String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId") + execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) + String serviceId = rollbackData.get("VFMODULE", "service-id") + execution.setVariable("DCVFMR_serviceId", serviceId) + String vnfType = rollbackData.get("VFMODULE", "vnftype") + execution.setVariable("DCVFMR_vnfType", vnfType) + String vnfName = rollbackData.get("VFMODULE", "vnfname") + execution.setVariable("DCVFMR_vnfName", vnfName) + String tenantId = rollbackData.get("VFMODULE", "tenantid") + execution.setVariable("DCVFMR_tenantId", tenantId) + String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename") + execution.setVariable("DCVFMR_vfModuleName", vfModuleName) + String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname") + execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName) + String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion") + execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) + String heatStackId = rollbackData.get("VFMODULE", "heatstackid") + execution.setVariable("DCVFMR_heatStackId", heatStackId) + String requestId = rollbackData.get("VFMODULE", "msorequestid") + execution.setVariable("DCVFMR_requestId", requestId) + // Set mso-request-id to request-id for VNF Adapter interface + execution.setVariable("mso-request-id", requestId) + List createdNetworkPolicyFqdnList = [] + int i = 0 + while (i < 100) { + String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i) + if (fqdn == null) { + break + } + createdNetworkPolicyFqdnList.add(fqdn) + logDebug("got fqdn # " + i + ": " + fqdn, isDebugEnabled) + i = i + 1 + + } + + execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList) + String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address") + execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) + String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") + execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) + //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid") + //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) + execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) + execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) + execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate")) + execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign")) + execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate")) + execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule")) + execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI")) + execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI")) + + // formulate the request for PrepareUpdateAAIVfModule + String request = """ + ${vnfId} + ${vfModuleId} + pending-delete + """ as String + utils.log("DEBUG", "PrepareUpdateAAIVfModuleRequest :" + request, isDebugEnabled) + utils.logAudit("DoCreateVfModuleRollback PrepareUpdateAAIVfModule Request: " + request) + execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) + } else { + execution.setVariable("skipRollback", true) + } + + if (execution.getVariable("disableRollback").equals("true" )) { + execution.setVariable("skipRollback", true) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + def msg = "Exception in DoCreateVfModuleRollback preProcessRequest " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - - execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList) - String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address") - execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) - String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") - execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) - //String serviceInstanceId = rollbackData.get("VFMODULE", "attmsoserviceinstanceid") - //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) - execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) - execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) - execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate")) - execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign")) - execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate")) - execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule")) - execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI")) - execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI")) - - // formulate the request for PrepareUpdateAAIVfModule - String request = """ - ${vnfId} - ${vfModuleId} - pending-delete - """ as String - utils.log("DEBUG", "PrepareUpdateAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("DoCreateVfModuleRollback PrepareUpdateAAIVfModule Request: " + request) - execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) } // build a SDNC vnf-topology-operation request for the specified action @@ -120,6 +145,11 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() + } + def callbackUrl = execution.getVariable("URN_mso_workflow_sdncadapter_callback") String source = execution.getVariable("DCVFMR_source") @@ -163,7 +193,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${vfModuleId} ${action} vnf-topology-operation @@ -202,6 +232,112 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("sdncAdapterWorkflowRequest", request) } + public void preProcessSDNCDeactivateRequest(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + + def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable("DCVFMR_deactivateSDNCRequest", deactivateSDNCRequest) + logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + } + + public void preProcessSDNCUnassignRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + try{ + String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest) + logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + } + + public String buildSDNCRequest(Execution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("URN_mso_workflow_sdncadapter_callback") + def requestId = execution.getVariable("DCVFMR_requestId") + def serviceId = execution.getVariable("DCVFMR_serviceId") + def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + def vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + def source = execution.getVariable("DCVFMR_source") + def vnfId = execution.getVariable("DCVFMR_vnfId") + + def sdncVersion = execution.getVariable("sdncVersion") + + String sdncRequest = + """ + + ${uuid} + ${svcInstId} + ${action} + vf-module-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + DeleteVfModuleInstance + ${source} + + + + + + + + ${serviceInstanceId} + + + + ${vnfId} + + + + ${vfModuleId} + + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + // parse the incoming DELETE_VF_MODULE request // and formulate the outgoing VnfAdapterDeleteV1 request public void prepVNFAdapterRequest(Execution execution) { @@ -484,4 +620,39 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage()) } } + + public void setSuccessfulRollbackStatus (Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled) + + try{ + // Set rolledBack to true, rollbackError to null + execution.setVariable("rolledBack", true) + execution.setVariable("rollbackError", null) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing setSuccessfulRollbackStatus. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled) + } + + public void setFailedRollbackStatus (Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED setFailedRollbackStatus ======== ", isDebugLogEnabled) + + try{ + // Set rolledBack to false, rollbackError to actual value, rollbackData to null + execution.setVariable("rolledBack", false) + execution.setVariable("rollbackError", 'Caught exception in DoCreateVfModuleRollback') + execution.setVariable("rollbackData", null) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing setFailedRollbackStatus. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED setFailedRollbackStatus ======== ", isDebugLogEnabled) + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy new file mode 100644 index 0000000000..46b6dd8366 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy @@ -0,0 +1,222 @@ +/* + * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* + + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + +public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor { + 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 + */ + public InitializeProcessVariables(Execution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "volumeGroupName", null) + execution.setVariable(Prefix + "lcpCloudRegionId", null) + execution.setVariable(Prefix + "rollbackVnfARequest", null) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the DoCreateVfModuleVolumeRollback.bpmn process. + * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + 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") +// execution.setVariable("DCVFMODVOLRBK_vfModuleId", vfModuleId) +// String source = rollbackData.get("DCVFMODULEVOL", "source") +// execution.setVariable("DCVFMODVOLRBK_source", source) +// String serviceInstanceId = rollbackData.get("DCVFMODULEVOL", "serviceInstanceId") +// execution.setVariable("DCVFMODVOLRBK_serviceInstanceId", serviceInstanceId) +// String serviceId = rollbackData.get("DCVFMODULEVOL", "service-id") +// execution.setVariable("DCVFMODVOLRBK_serviceId", serviceId) +// String vnfType = rollbackData.get("DCVFMODULEVOL", "vnftype") +// execution.setVariable("DCVFMODVOLRBK_vnfType", vnfType) +// String vnfName = rollbackData.get("DCVFMODULEVOL", "vnfname") +// execution.setVariable("DCVFMODVOLRBK_vnfName", vnfName) +// String tenantId = rollbackData.get("DCVFMODULEVOL", "tenantid") +// execution.setVariable("DCVFMODVOLRBK_tenantId", tenantId) +// String vfModuleName = rollbackData.get("DCVFMODULEVOL", "vfmodulename") +// execution.setVariable("DCVFMODVOLRBK_vfModuleName", vfModuleName) +// String vfModuleModelName = rollbackData.get("DCVFMODULEVOL", "vfmodulemodelname") +// execution.setVariable("DCVFMODVOLRBK_vfModuleModelName", vfModuleModelName) +// String cloudSiteId = rollbackData.get("DCVFMODULEVOL", "aiccloudregion") +// execution.setVariable("DCVFMODVOLRBK_cloudSiteId", cloudSiteId) +// String heatStackId = rollbackData.get("DCVFMODULEVOL", "heatstackid") +// 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(Execution 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') + + utils.logAudit('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + //aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI query volume group by name return code: " + returnCode) + utils.logAudit("AAI query volume group by name response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString) + execution.setVariable(prefix+'AaiReturnCode', returnCode) + + if (returnCode=='200') { + // @TODO: verify error code + // @TODO: create class of literals representing error codes + execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString) + utils.log("DEBUG", "Volume Group Name $volumeGroupName exists in AAI.", isDebugEnabled) + } else { + if (returnCode=='404') { + utils.log("DEBUG", "Volume Group Name $volumeGroupName does not exist in AAI.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404") + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + + public void callRESTDeleteAAIVolumeGroup(Execution 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") + + utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) + + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + //aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI delete volume group return code: " + returnCode) + utils.logAudit("AAI delete volume group response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + def volumeGroupNameFound = prefix+'volumeGroupNameFound' + if (returnCode=='200' || returnCode=='204' ) { + utils.log("DEBUG", "Volume group $volumeGroupId deleted.", isDebugEnabled) + } else { + if (returnCode=='404') { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404") + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + // ******************************* + // Build Error Section + // ******************************* + + + + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + try{ + utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) + 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){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled) + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy deleted file mode 100644 index 8e54024c6f..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy +++ /dev/null @@ -1,657 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure.scripts - -import static org.camunda.spin.Spin.XML - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.VfModuleBase -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils - -class DoCreateVfModuleVolumeV1 extends VfModuleBase { - - String prefix='DCVFMODVOLV1_' - - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - preProcessRequest(execution, isDebugEnabled) - } - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * @param execution - * @param isDebugEnabled - */ - public void preProcessRequest (Execution execution, isDebugEnabled) { - - execution.setVariable("prefix",prefix) - execution.setVariable(prefix+'SuccessIndicator', false) - - - // INPUT: DoCreateVfModuleVolumeV1Request, mso-request-id, volume-group-id, vnf-id, is-vid-request - // OUTPUT: DCVFMODVOLV1_SuccessIndicator. WorkflowException - - def volumeRequest = getVariable(execution, 'DoCreateVfModuleVolumeV1Request') - if (volumeRequest != null) { - execution.setVariable(prefix+'Request', volumeRequest) - } else { - volumeRequest = getVariable(execution, prefix+'Request') - if (volumeRequest == null) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'DoCreateVfModuleVolumeV1 received null request.') - } - } - - def vnfId = execution.getVariable('vnf-id') - if (vnfId == null) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'DoCreateVfModuleVolumeV1 received null vnf-id.') - } - - def volumeGroupId = execution.getVariable('volume-group-id') - if (volumeGroupId == null) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'DoCreateVfModuleVolumeV1 received null volume-group-id.') - } - - def requestId = execution.getVariable("mso-request-id") - if (requestId == null || requestId == "") { - requestId = utils.getNodeText1(volumeRequest, "request-id") - } - - //def serviceId = execution.getVariable("mso-service-instance-id") - //if (serviceId == null || serviceId == "") { - def serviceId = utils.getNodeText1(volumeRequest, "service-id") - //} - - def source = utils.getNodeText1(volumeRequest, "source") - - execution.setVariable(prefix+'requestId', requestId) - execution.setVariable(prefix+'serviceId', serviceId) - execution.setVariable(prefix+'source', source) - - // @TODO: for better tracking of logs, should we strip all new lines in the log message? - utils.logAudit('Incoming request: ' + volumeRequest) - - // Rollback settings - NetworkUtils networkUtils = new NetworkUtils() - def rollbackEnabled = networkUtils.isRollbackEnabled(execution,volumeRequest) - execution.setVariable(prefix+"rollbackEnabled", rollbackEnabled) - utils.log("DEBUG", 'rollbackEnabled: ' + rollbackEnabled, isDebugEnabled) - - } - - - /** - * Get cloud region - * @param execution - * @param isDebugEnabled - */ - public void callRESTQueryAAICloudRegion (Execution execution, isDebugEnabled) { - - def request = execution.getVariable(prefix+'Request') - def cloudRegion = utils.getNodeText1(request, "aic-cloud-region") - utils.log("DEBUG", 'Request cloud region is: ' + cloudRegion, isDebugEnabled) - - AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion - - utils.logAudit(queryCloudRegionRequest) - - cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - - if ((cloudRegion != "ERROR")) { - if(execution.getVariable(prefix+"queryCloudRegionReturnCode") == "404"){ - cloudRegion = "AAIAIC25" - } - execution.setVariable(prefix+"aicCloudRegion", cloudRegion) - utils.log("DEBUG", "AIC Cloud Region: " + cloudRegion, isDebugEnabled) - } else { - String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode") - utils.log("DEBUG", errorMessage, isDebugEnabled) - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage) - } - } - - - /** - * Query AAI volume group by name - * @param execution - * @param isDebugEnabled - */ - public void callRESTQueryAAIVolGrpName(Execution execution, isDebugEnabled) { - - def volumeRequest = execution.getVariable(prefix+'Request') - def volumeGroupName = utils.getNodeText(volumeRequest, "volume-group-name") - def cloudRegion = execution.getVariable(prefix+"aicCloudRegion") - - // Save volume group name - execution.setVariable(prefix+'volumeGroupName', volumeGroupName) - - // This is for stub testing - def testVolumeGroupName = execution.getVariable('test-volume-group-name') - if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) { - volumeGroupName = testVolumeGroupName - //reset to null - execution.setVariable('test-volume-group-name', null) - } - - AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8') - - utils.logAudit('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) - - APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI query volume group by name return code: " + returnCode) - utils.logAudit("AAI query volume group by name response: " + aaiResponseAsString) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString) - execution.setVariable(prefix+'AaiReturnCode', returnCode) - - if (returnCode=='200') { - // @TODO: verify error code - // @TODO: create class of literals representing error codes - execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString) - utils.log("DEBUG", "Volume Group Name $volumeGroupName exists in AAI.", isDebugEnabled) - } else { - if (returnCode=='404') { - utils.log("DEBUG", "Volume Group Name $volumeGroupName does not exist in AAI.", isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404") - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - throw new BpmnError("MSOWorkflowException") - } - } - } - - - /** - * Create a WorkflowException - * @param execution - * @param isDebugEnabled - */ - public void buildWorkflowException(Execution execution, int errorCode, errorMessage, isDebugEnabled) { - utils.log("DEBUG", errorMessage, isDebugEnabled) - (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) - } - - - /** - * Create a WorkflowException - * @param execution - * @param isDebugEnabled - */ - public void handleError(Execution execution, isDebugEnabled) { - WorkflowException we = execution.getVariable('WorkflowException') - if (we == null) { - (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!") - } - throw new BpmnError("MSOWorkflowException") - } - - /** - * Create volume group in AAI - * @param execution - * @param isDebugEnabled - */ - public void callRESTCreateAAIVolGrpName(Execution execution, isDebugEnabled) { - - def volumeRequest = execution.getVariable(prefix+'Request') - def vnfId = execution.getVariable('vnf-id') - def volumeName = utils.getNodeText(volumeRequest, "volume-group-name") - def modelCustomizationId = getNodeTextForce(volumeRequest, "model-customization-id") - - def cloudRegion = execution.getVariable(prefix+"aicCloudRegion") - def groupId = execution.getVariable('volume-group-id') - utils.log("DEBUG", "volume group id: " + groupId, isDebugEnabled) - - AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") - - String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution)) - utils.log("DEBUG", "AAI namespace is: " + namespace, isDebugEnabled) - - utils.logAudit(createAAIVolumeGrpNameUrlRequest) - - //Prepare payload (PUT) - def vnfType = utils.getNodeText(volumeRequest, "vnf-type") - def tenantId = utils.getNodeText(volumeRequest, "tenant-id") - - NetworkUtils networkUtils = new NetworkUtils() - String payload = networkUtils.createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) - String payloadXml = utils.formatXml(payload) - utils.logAudit(payloadXml) - - APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI create volume group return code: " + returnCode) - utils.logAudit("AAI create volume group response: " + aaiResponseAsString) - - execution.setVariable(prefix+"createAAIVolumeGrpNameReturnCode", returnCode) - execution.setVariable(prefix+"createAAIVolumeGrpNameResponse", aaiResponseAsString) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - if (returnCode =='201') { - execution.setVariable(prefix+"isAAIRollbackNeeded", true) - } else { - execution.setVariable(prefix+"isErrorMessageException", true) - if (returnCode=='404') { - // @TODO: verify return code and make static LITERAL - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404") - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - } - } - - /** - * Prepare VNF adapter create request XML - * @param execution - */ - public void prepareVnfAdapterCreateRequest(Execution execution, isDebugEnabled) { - - - def volumeRequest = execution.getVariable(prefix+'Request') - def requestId = execution.getVariable(prefix+'requestId') - def serviceId = execution.getVariable(prefix+'serviceId') - - def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse') - def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id') - def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name') - def modelCustomizationId = getNodeTextForce(volumeRequest, "model-customization-id") - - String messageId = UUID.randomUUID() - utils.log("DEBUG", "messageId to be used is generated: " + messageId, isDebugEnabled) - - // prepare vnf request for vnfAdapterCreateV1 - def cloudSiteId = utils.getNodeText1(volumeRequest, 'aic-cloud-region') - def tenantId = utils.getNodeText1(volumeRequest, "tenant-id") - def vnfType = utils.getNodeText1(volumeRequest, "vnf-type") - def vnfVersion = utils.getNodeText1(volumeRequest, "asdc-service-model-version") - def vnfModuleType = utils.getNodeText1(volumeRequest, "vf-module-model-name") - def volumeGroupnName = utils.getNodeText1(volumeRequest, "volume-group-name") - - def volumeParamsXml = utils.getNodeXml(volumeRequest, 'volume-params') - def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml) - - utils.log("DEBUG", "volumeGroupParams: "+ volumeGroupParams, isDebugEnabled) - - String volumeGroupId = execution.getVariable('volume-group-id') - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - utils.log("DEBUG", "CreateVfModuleVolume - notificationUrl: "+ notificationUrl, isDebugEnabled) - - def backoutOnFailure = execution.getVariable("DCVFMODVOLV1_rollbackEnabled") - utils.log("DEBUG", "backoutOnFailure: "+ backoutOnFailure, isDebugEnabled) - - // build request - String vnfSubCreateWorkflowRequest = - """ - - ${cloudSiteId} - ${tenantId} - ${vnfId} - ${vnfName} - ${volumeGroupId} - ${volumeGroupnName} - ${vnfType} - ${vnfVersion} - ${vnfModuleType} - ${modelCustomizationId} - - - vnf_id - ${vnfId} - - - vnf_name - ${vnfName} - - - vf_module_id - ${volumeGroupId} - - - vf_module_name - ${volumeGroupnName} - - ${volumeGroupParams} - - true - ${backoutOnFailure} - true - - ${requestId} - ${serviceId} - - ${messageId} - ${notificationUrl} - - """ - - String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest) - utils.logAudit(vnfSubCreateWorkflowRequestAsString) - utils.log('DEBUG', vnfSubCreateWorkflowRequestAsString, isDebugEnabled) - execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString) - - // build rollback request for use later if needed - - String vnfSubRollbackWorkflowRequest = - """ - ${cloudSiteId} - ${tenantId} - ${volumeGroupId} - true - true - - ${requestId} - ${serviceId} - - ${messageId} - ${notificationUrl} - """ - - utils.log("DEBUG", "Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest, isDebugEnabled) - - String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest) - execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString) - } - - - - /** - * Update voulume group in AAI - * @TODO: Can we re-use the create method?? - * @param execution - * @param isDebugEnabled - */ - public void callRESTUpdateCreatedVolGrpName(Execution execution, isDebugEnabled) { - - // get variables - String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse") - String volumeGroupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id") - String modelCustomizationId = getNodeTextForce(requeryAAIVolGrpNameResponse, "vf-module-persona-model-customization-id") - String cloudRegion = execution.getVariable(prefix+"aicCloudRegion") - - 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)) - - utils.logAudit(updateAAIVolumeGroupUrlRequest) - - //Prepare payload (PUT) - String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse") - - // @TODO: revisit - // if VID request createVnfresponse will be null, use vnf from JSON request - def vnfId = "" - if(createVnfAResponse == null || createVnfAResponse == "") { - vnfId = execution.getVariable(prefix+'vnfId') - } - else { - vnfId = utils.getNodeText(createVnfAResponse, "volumeGroupStackId") - } - - NetworkUtils networkUtils = new NetworkUtils() - String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, vnfId, namespace, modelCustomizationId) - String payloadXml = utils.formatXml(payload) - - //execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNamePayloadRequest", payloadXml) - utils.logAudit(payload) - //utils.log("DEBUG", " 'payload' to Update Created VolumeGroupName - " + "\n" + payloadXml, isDebugEnabled) - - APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI create volume group return code: " + returnCode) - utils.logAudit("AAI create volume group response: " + aaiResponseAsString) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - if (returnCode =='200') { - execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNameResponse", aaiResponseAsString) - execution.setVariable(prefix+"isPONR", true) - } else { - execution.setVariable(prefix+"isErrorMessageException", true) - if (returnCode=='404') { - // @TODO: verify return code and make static LITERAL - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404") - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - } - } - - - /** - * Query AAI service instance - * @param execution - * @param isDebugEnabled - */ - public void callRESTQueryAAIGenericVnf(Execution execution, isDebugEnabled) { - - def request = execution.getVariable(prefix+"Request") - def vnfId = execution.getVariable('vnf-id') - - AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) - def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") - - utils.logAudit("AAI query generic vnf request: " + queryAAIRequest) - - APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI query generic vnf return code: " + returnCode) - utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString) - - //utils.log("DEBUG", "AAI query generic vnf return code: " + returnCode, isDebugEnabled) - //utils.log("DEBUG", "AAI query generic vnf response: " + aaiResponseAsString, isDebugEnabled) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - if (returnCode=='200') { - utils.log("DEBUG", 'Generic vnf ' + vnfId + ' found in AAI.', isDebugEnabled) - execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString) - } else { - if (returnCode=='404') { - def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.' - utils.log("DEBUG", message, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - throw new BpmnError("MSOWorkflowException") - } - } - } - - public void callRESTDeleteAAIVolumeGroup(Execution 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(prefix+"aicCloudRegion") - - 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") - - utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) - - APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI delete volume group return code: " + returnCode) - utils.logAudit("AAI delete volume group response: " + aaiResponseAsString) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - def volumeGroupNameFound = prefix+'volumeGroupNameFound' - if (returnCode=='200' || returnCode=='204' ) { - utils.log("DEBUG", "Volume group $volumeGroupId deleted.", isDebugEnabled) - } else { - if (returnCode=='404') { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404") - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - throw new BpmnError("MSOWorkflowException") - } - } - } - - - - - - public void prepareSuccessDBRequest(Execution execution, isDebugEnabled) { - String requestId = execution.getVariable(prefix+'requestId') - String dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') - prepareDBRequest(execution, requestId, "VolumeGroup successfully created.", "COMPLETED", "100", dbVnfOutputs, isDebugEnabled) - } - - public void prepareFailDbRequest(Execution execution, isDebugEnabled) { - - WorkflowException we = execution.getVariable("WorkflowException") - - String requestId = execution.getVariable(prefix+'requestId') - String dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') - prepareDBRequest(execution, requestId, we.getErrorMessage(), "FAILURE", "", dbVnfOutputs, isDebugEnabled) - - } - - - /** - * Prepare Infra DB XML Request - * @param execution - */ - public void prepareDBRequest (Execution execution, String requestId, String statusMessage, String requestStatus, String progress, String dbVnfOutputs, isDebugEnabled) { - - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - ${requestStatus} - ${progress} - ${dbVnfOutputs} - - - """ - - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - - execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString) - - utils.logAudit(buildDeleteDBRequestAsString) - } - - - - - public void postProcessResponse (Execution execution, isDebugEnabled) { - - String dbReturnCode = execution.getVariable(prefix+"dbReturnCode") - utils.log("DEBUG", "DB Update Response Code : " + dbReturnCode, isDebugEnabled) - - String createDBResponse = execution.getVariable(prefix+"createDBResponse") - utils.logAudit(createDBResponse) - - String source = execution.getVariable(prefix+"source") - String requestId = execution.getVariable(prefix+'requestId') - - String msoCompletionRequest = - """ - - ${requestId} - CREATE - ${source} - - BPEL Volume Group action: CREATE - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - utils.logAudit(xmlMsoCompletionRequest) - - // normal path - if (dbReturnCode == "200") { - execution.setVariable(prefix+"Success", true) - execution.setVariable(prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - } else { - execution.setVariable(prefix+"isErrorMessageException", true) - utils.log("DEBUG", " DB Update failed, code: " + dbReturnCode + ", going to Unexpected Error.", isDebugEnabled) - } - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy new file mode 100644 index 0000000000..2d004b88ac --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy @@ -0,0 +1,593 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.camunda.spin.Spin.XML; +import groovy.json.JsonSlurper +import groovy.lang.GroovyInterceptable; +import groovy.xml.XmlUtil + +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils +import org.openecomp.mso.bpmn.common.scripts.VfModuleBase; +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + + + + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; + +class DoCreateVfModuleVolumeV2 extends VfModuleBase { + + String prefix='DCVFMODVOLV2_' + JsonUtils jsonUtil = new JsonUtils() + + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * * @param execution + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + public void preProcessRequest(Execution execution, isDebugLogEnabled) { + + execution.setVariable("prefix",prefix) + execution.setVariable(prefix+'SuccessIndicator', false) + execution.setVariable(prefix+'isPONR', false) + + displayInput(execution, isDebugLogEnabled) + setRollbackData(execution, isDebugLogEnabled) + setRollbackEnabled(execution, isDebugLogEnabled) + + + def tenantId = execution.getVariable("tenantId") + if (tenantId == null) { + String cloudConfiguration = execution.getVariable("cloudConfiguration") + tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + } + + def cloudSiteId = execution.getVariable("lcpCloudRegionId") + if (cloudSiteId == null) { + String cloudConfiguration = execution.getVariable("cloudConfiguration") + cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", cloudSiteId) + } + + // Extract attributes from modelInfo + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + + //modelCustomizationUuid + def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") + execution.setVariable("modelCustomizationId", modelCustomizationUuid) + logDebug("modelCustomizationId: " + modelCustomizationUuid, isDebugLogEnabled) + + //modelName + def modelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") + execution.setVariable("modelName", modelName) + logDebug("modelName: " + modelName, isDebugLogEnabled) + + // The following is used on the get Generic Service Instance call + execution.setVariable('GENGS_type', 'service-instance') + } + + + /** + * Display input variables + * @param execution + * @param isDebugLogEnabled + */ + public void displayInput(Execution execution, isDebugLogEnabled) { + def input = ['mso-request-id', 'msoRequestId', 'isDebugLogEnabled', 'disableRollback', 'failIfExists', 'serviceInstanceId', + 'vnfId', 'vnfName', 'tenantId', 'volumeGroupId', 'volumeGroupName', 'lcpCloudRegionId', 'vnfType', 'vfModuleModelInfo', 'asdcServiceModelVersion', + 'test-volume-group-name', 'test-volume-group-id', 'vfModuleInputParams'] + + logDebug('Begin input: ', isDebugLogEnabled) + input.each { + logDebug(it + ': ' + execution.getVariable(it), isDebugLogEnabled) + } + logDebug('End input.', isDebugLogEnabled) + } + + + /** + * Define and set rollbackdata object + * @param execution + * @param isDebugEnabled + */ + public void setRollbackData(Execution execution, isDebugEnabled) { + def rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + def volumeGroupName = execution.getVariable('volumeGroupName') + rollbackData.put("DCVFMODULEVOL", "volumeGroupName", volumeGroupName) + execution.setVariable("rollbackData", rollbackData) + } + + + /** + * validate getServiceInstance response + * @param execution + * @param isDebugEnabled + */ + public void validateGetServiceInstanceCall(Execution execution, isDebugEnabled) { + def found = execution.getVariable('GENGS_FoundIndicator') + def success = execution.getVariable('GENGS_SuccessIndicator') + def serviceInstanceId = execution.getVariable('serviceInstanceId') + utils.log("DEBUG", "getServiceInstance success: " + success, isDebugEnabled) + utils.log("DEBUG", "getServiceInstance found: " + found, isDebugEnabled) + if(!found || !success) { + String errorMessage = "Service instance id not found in AAI: ${serviceInstanceId}." + utils.log("DEBUG", errorMessage, isDebugEnabled) + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + + } + + /** + * Get cloud region + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAICloudRegion (Execution execution, isDebugEnabled) { + + def cloudRegion = execution.getVariable("lcpCloudRegionId") + utils.log("DEBUG", 'Request cloud region is: ' + cloudRegion, isDebugEnabled) + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion + + utils.logAudit(queryCloudRegionRequest) + + cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + + def aaiCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion) + if ((aaiCloudRegion != "ERROR")) { + execution.setVariable("lcpCloudRegionId", aaiCloudRegion) + utils.log("DEBUG", "AIC Cloud Region for AAI: " + aaiCloudRegion, isDebugEnabled) + } else { + String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode") + utils.log("DEBUG", errorMessage, isDebugEnabled) + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + + def poCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + if ((poCloudRegion != "ERROR")) { + execution.setVariable("poLcpCloudRegionId", poCloudRegion) + utils.log("DEBUG", "AIC Cloud Region for PO: " + poCloudRegion, isDebugEnabled) + } else { + String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode") + utils.log("DEBUG", errorMessage, isDebugEnabled) + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudRegion) + } + + + /** + * Query AAI volume group by name + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAIVolGrpName(Execution execution, isDebugEnabled) { + + def volumeGroupName = execution.getVariable('volumeGroupName') + def cloudRegion = execution.getVariable('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') + + utils.logAudit('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI query volume group by name return code: " + returnCode) + utils.logAudit("AAI query volume group by name response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString) + execution.setVariable(prefix+'AaiReturnCode', returnCode) + + if (returnCode=='200') { + execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString) + utils.log("DEBUG", "Volume Group Name $volumeGroupName exists in AAI.", isDebugEnabled) + } else { + if (returnCode=='404') { + utils.log("DEBUG", "Volume Group Name $volumeGroupName does not exist in AAI.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404") + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + /** + * Create a WorkflowException + * @param execution + * @param isDebugEnabled + */ + public void buildWorkflowException(Execution execution, int errorCode, errorMessage, isDebugEnabled) { + utils.log("DEBUG", errorMessage, isDebugEnabled) + (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) + } + + + /** + * Create a WorkflowException + * @param execution + * @param isDebugEnabled + */ + public void handleError(Execution execution, isDebugEnabled) { + WorkflowException we = execution.getVariable('WorkflowException') + if (we == null) { + (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!") + } + throw new BpmnError("MSOWorkflowException") + } + + + /** + * Create volume group in AAI + * @param execution + * @param isDebugEnabled + */ + public void callRESTCreateAAIVolGrpName(Execution execution, isDebugEnabled) { + + def vnfId = execution.getVariable('vnfId') + def volumeGroupId = execution.getVariable('volumeGroupId') + def volumeName = execution.getVariable("volumeGroupName") + def modelCustomizationId = execution.getVariable("modelCustomizationId") + def vnfType = execution.getVariable("vnfType") + def tenantId = execution.getVariable("tenantId") + def cloudRegion = execution.getVariable('lcpCloudRegionId') + + utils.log("DEBUG", "volumeGroupId: " + volumeGroupId, isDebugEnabled) + + def testGroupId = execution.getVariable('test-volume-group-id') + if (testGroupId != null && testGroupId.trim() != '') { + utils.log("DEBUG", "test volumeGroupId is present: " + testGroupId, isDebugEnabled) + volumeGroupId = testGroupId + execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0") + } + + utils.log("DEBUG", "volumeGroupId to be used: " + volumeGroupId, isDebugEnabled) + + 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)) + utils.log("DEBUG", "AAI namespace is: " + namespace, isDebugEnabled) + + utils.logAudit("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest) + + NetworkUtils networkUtils = new NetworkUtils() + String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) + String payloadXml = utils.formatXml(payload) + utils.logAudit("Request payload for PUT: " + payloadXml) + + APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI create volume group return code: " + returnCode) + utils.logAudit("AAI create volume group response: " + aaiResponseAsString) + + execution.setVariable(prefix+"createAAIVolumeGrpNameReturnCode", returnCode) + execution.setVariable(prefix+"createAAIVolumeGrpNameResponse", aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode =='201') { + RollbackData rollbackData = execution.getVariable("rollbackData") + rollbackData.put("DCVFMODULEVOL", "isAAIRollbackNeeded", "true") + } else { + execution.setVariable(prefix+"isErrorMessageException", true) + if (returnCode=='404') { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404") + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + /** + * Prepare VNF adapter create request XML + * @param execution + */ + public void prepareVnfAdapterCreateRequest(Execution execution, isDebugEnabled) { + + def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse') + def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id') + def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name') + def vnfType = utils.getNodeText1(aaiGenericVnfResponse, "vnf-type") + + def requestId = execution.getVariable('msoRequestId') + def serviceId = execution.getVariable('serviceInstanceId') + def cloudSiteId = execution.getVariable('poLcpCloudRegionId') + def tenantId = execution.getVariable('tenantId') + def volumeGroupId = execution.getVariable('volumeGroupId') + def volumeGroupnName = execution.getVariable('volumeGroupName') + + def vnfVersion = execution.getVariable("asdcServiceModelVersion") + def vnfModuleType = execution.getVariable("modelName") + + def modelCustomizationId = execution.getVariable("modelCustomizationId") + + // for testing + utils.log("DEBUG", "volumeGroupId: " + volumeGroupId, isDebugEnabled) + def testGroupId = execution.getVariable('test-volume-group-id') + if (testGroupId != null && testGroupId.trim() != '') { + utils.log("DEBUG", "test volumeGroupId is present: " + testGroupId, isDebugEnabled) + volumeGroupId = testGroupId + execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0") + } + utils.log("DEBUG", "volumeGroupId to be used: " + volumeGroupId, isDebugEnabled) + + // volume group parameters + + String volumeGroupParams = '' + StringBuilder sbParams = new StringBuilder() + Map paramsMap = execution.getVariable("vfModuleInputParams") + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey(); + String paramValue = entry.getValue() + paramsXml = + """ + ${paramName} + ${paramValue} + + """ + sbParams.append(paramsXml) + } + + volumeGroupParams = sbParams.toString() + utils.log("DEBUG", "volumeGroupParams: "+ volumeGroupParams, isDebugEnabled) + + def backoutOnFailure = execution.getVariable(prefix+"backoutOnFailure") + utils.log("DEBUG", "backoutOnFailure: "+ backoutOnFailure, isDebugEnabled) + + def failIfExists = execution.getVariable("failIfExists") + if(failIfExists == null) { + failIfExists = 'true' + } + + String messageId = UUID.randomUUID() + utils.log("DEBUG", "messageId to be used is generated: " + messageId, isDebugEnabled) + + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + utils.log("DEBUG", "CreateVfModuleVolume - notificationUrl: "+ notificationUrl, isDebugEnabled) + + // build request + String vnfSubCreateWorkflowRequest = + """ + + ${cloudSiteId} + ${tenantId} + ${vnfId} + ${vnfName} + ${volumeGroupId} + ${volumeGroupnName} + ${vnfType} + ${vnfVersion} + ${vnfModuleType} + ${modelCustomizationId} + + + vnf_id + ${vnfId} + + + vnf_name + ${vnfName} + + + vf_module_id + ${volumeGroupId} + + + vf_module_name + ${volumeGroupnName} + + ${volumeGroupParams} + + true + ${backoutOnFailure} + ${failIfExists} + + ${requestId} + ${serviceId} + + ${messageId} + ${notificationUrl} + + """ + + String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest) + utils.logAudit(vnfSubCreateWorkflowRequestAsString) + utils.log('DEBUG', vnfSubCreateWorkflowRequestAsString, isDebugEnabled) + execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString) + + // build rollback request for use later if needed + + String vnfSubRollbackWorkflowRequest = + """ + ${cloudSiteId} + ${tenantId} + ${volumeGroupId} + true + true + + ${requestId} + ${serviceId} + + ${messageId} + ${notificationUrl} + """ + + utils.log("DEBUG", "Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest, isDebugEnabled) + + String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest) + execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString) + } + + + /** + * Validate VNF adapter response + * @param execution + */ + public void validateVnfResponse(Execution execution, isDebugEnabled) { + def vnfSuccess = execution.getVariable('VNFREST_SuccessIndicator') + utils.log("DEBUG", "vnfAdapterSuccessIndicator: "+ vnfSuccess, isDebugEnabled) + if(vnfSuccess==true) { + def vnfRollbackRequest = execution.getVariable(prefix+"rollbackVnfARequest") + utils.log("DEBUG", "vnfAdapter rollback request: "+ vnfRollbackRequest, isDebugEnabled) + RollbackData rollbackData = execution.getVariable("rollbackData") + rollbackData.put("DCVFMODULEVOL", "rollbackVnfARequest", vnfRollbackRequest) + rollbackData.put("DCVFMODULEVOL", "isCreateVnfRollbackNeeded", "true") + } + + } + + + /** + * Update voulume group in AAI + * @TODO: Can we re-use the create method?? + * @param execution + * @param isDebugEnabled + */ + public void callRESTUpdateCreatedVolGrpName(Execution execution, isDebugEnabled) { + + String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse") + String volumeGroupId = utils.getNodeText1(requeryAAIVolGrpNameResponse, "volume-group-id") + String modelCustomizationId = execution.getVariable("modelCustomizationId") + 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)) + + utils.logAudit(updateAAIVolumeGroupUrlRequest) + utils.log("DEBUG", "updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest, isDebugEnabled) + + String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse") + def heatStackID = utils.getNodeText1(createVnfAResponse, "volumeGroupStackId") + + execution.setVariable(prefix+"heatStackId", heatStackID) + + NetworkUtils networkUtils = new NetworkUtils() + String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackID, namespace, modelCustomizationId) + String payloadXml = utils.formatXml(payload) + + utils.logAudit("Payload to Update Created VolumeGroupName - " + "\n" + payloadXml) + + APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI create volume group return code: " + returnCode) + utils.logAudit("AAI create volume group response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode =='200') { + execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNameResponse", aaiResponseAsString) + execution.setVariable(prefix+"isPONR", true) + } else { + execution.setVariable(prefix+"isErrorMessageException", true) + if (returnCode=='404') { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404") + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + /** + * Query AAI Generic VNF + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAIGenericVnf(Execution 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") + + utils.logAudit("AAI query generic vnf request: " + queryAAIRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI query generic vnf return code: " + returnCode) + utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode=='200') { + utils.log("DEBUG", 'Generic vnf ' + vnfId + ' found in AAI.', isDebugEnabled) + execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString) + } else { + if (returnCode=='404') { + def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.' + utils.log("DEBUG", message, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 8a6cac4a91..0fa08fdc4e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -23,12 +23,14 @@ import static org.apache.commons.lang3.StringUtils.* import org.openecomp.mso.bpmn.core.RollbackData import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution +import org.springframework.web.util.UriUtils import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.domain.VnfResource import org.openecomp.mso.bpmn.core.json.JsonUtils @@ -64,7 +66,12 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { /*******************/ try{ - // Get Variables + // Get Variables + + def rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } String vnfModelInfo = execution.getVariable("vnfModelInfo") String serviceModelInfo = execution.getVariable("serviceModelInfo") @@ -76,6 +83,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId) + rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId) utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) String vnfType = execution.getVariable("vnfType") @@ -95,17 +103,18 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String source = "VID" execution.setVariable("DoCVNF_source", source) + rollbackData.put("VNF", "source", source) utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) String suppressRollback = execution.getVariable("disableRollback") execution.setVariable("DoCVNF_suppressRollback", suppressRollback) utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled) - String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId") + String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid") execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) - String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") + String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid") if (modelVersionId == null) { modelVersionId = "" } @@ -120,19 +129,21 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { execution.setVariable("DoCVNF_modelName", modelName) utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled) - String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId") - if (modelCustomizationId == null) { - modelCustomizationId = "" + String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") + if (modelCustomizationId == null) { + modelCustomizationId = "" } execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId) utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) String cloudSiteId = execution.getVariable("lcpCloudRegionId") execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId) + rollbackData.put("VNF", "cloudSiteId", cloudSiteId) utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) String tenantId = execution.getVariable("tenantId") execution.setVariable("DoCVNF_tenantId", tenantId) + rollbackData.put("VNF", "tenantId", tenantId) utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) String globalSubscriberId = execution.getVariable("globalSubscriberId") @@ -186,15 +197,33 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl) + rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl) utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) - def rollbackData = execution.getVariable("RollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } + VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition") + + String nfRole = vnfResource.getNfRole() + execution.setVariable("DoCVNF_nfRole", nfRole) + logDebug("NF Role is: " + nfRole, isDebugEnabled) - execution.setVariable("RollbackData", rollbackData) + String nfNamingCode = vnfResource.getNfNamingCode() + execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode) + logDebug("NF Naming Code is: " + nfNamingCode, isDebugEnabled) + + String nfType = vnfResource.getNfType() + execution.setVariable("DoCVNF_nfType", nfType) + logDebug("NF Type is: " + nfType, isDebugEnabled) + + String nfFunction = vnfResource.getNfFunction() + execution.setVariable("DoCVNF_nfFunction", nfFunction) + logDebug("NF Function is: " + nfFunction, isDebugEnabled) + + rollbackData.put("VNF", "rollbackSDNCAssign", "false") + rollbackData.put("VNF", "rollbackSDNCActivate", "false") + rollbackData.put("VNF", "rollbackVnfCreate", "false") + + execution.setVariable("rollbackData", rollbackData) }catch(BpmnError b){ utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) @@ -229,6 +258,10 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") // TODO: 1702 Variable def equipmentRole = execution.getVariable("DoCVNF_equipmentRole") + def nfType = execution.getVariable("DoCVNF_nfType") + def nfRole = execution.getVariable("DoCVNF_nfRole") + def nfFunction = execution.getVariable("DoCVNF_nfFunction") + def nfNamingCode = execution.getVariable("DoCVNF_nfNamingCode") //Get Service Instance Info def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") @@ -240,6 +273,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { int serviceStart = siRelatedLink.indexOf("service-subscription/") int serviceEnd = siRelatedLink.indexOf("/service-instances/") String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd) + serviceType = UriUtils.decode(serviceType,"UTF-8") //Get Namespace AaiUtil aaiUtil = new AaiUtil(this) @@ -257,6 +291,10 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { ${modelInvariantId} ${modelVersionId} ${modelCustomizationId} + ${nfType} + ${nfRole} + ${nfFunction} + ${nfNamingCode} service-instance @@ -294,9 +332,10 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { try { //Get Vnf Info String vnfId = execution.getVariable("DoCVNF_vnfId") - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") rollbackData.put("VNF", "vnfId", vnfId) - execution.setVariable("RollbackData", rollbackData) + rollbackData.put("VNF", "rollbackVnfCreate", "true") + execution.setVariable("rollbackData", rollbackData) }catch(Exception ex) { utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process") @@ -360,7 +399,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String uuid = execution.getVariable('testReqId') // for junits if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis() } def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl") def requestId = execution.getVariable("DoCVNF_requestId") @@ -397,7 +436,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${svcInstId} ${action} vnf-topology-operation @@ -467,6 +506,15 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { execution.setVariable("vnfName", vnfName) execution.setVariable("DoCVNF_vnfName", vnfName) } + def rollbackData = execution.getVariable("rollbackData") + if (method.equals("assign")) { + rollbackData.put("VNF", "rollbackSDNCAssign", "true") + } + else if (method.equals("activate")) { + rollbackData.put("VNF", "rollbackSDNCActivate", "true") + } + execution.setVariable("rollbackData", rollbackData) + }else{ logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy index daae3d7dac..6ede7e932d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -20,26 +20,26 @@ package org.openecomp.mso.bpmn.infrastructure.scripts import java.util.UUID; +import java.util.List import org.json.JSONObject; import org.json.JSONArray; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; - -import static org.apache.commons.lang3.StringUtils.*; - -import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.decomposition.ModelInfo -import org.openecomp.mso.bpmn.core.decomposition.ModuleResource -import org.openecomp.mso.bpmn.core.decomposition.ServiceDecomposition -import org.openecomp.mso.bpmn.core.decomposition.VnfResource +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.ModuleResource +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.json.DecomposeJsonUtil +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; + +import static org.apache.commons.lang3.StringUtils.*; @@ -54,6 +54,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) CatalogDbUtils cutils = new CatalogDbUtils() + DecomposeJsonUtil decomposeJsonUtil = new DecomposeJsonUtil() /** * This method gets and validates the incoming @@ -65,7 +66,8 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) - + + setBasicDBAuthHeader(execution, isDebugLogEnabled) try{ // Get Variables @@ -81,9 +83,6 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - String vnfType = execution.getVariable("vnfType") - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) - String vnfName = execution.getVariable("vnfName") execution.setVariable("CREVI_vnfName", vnfName) utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) @@ -117,15 +116,20 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { } execution.setVariable("vnfId", vnfId) - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") if (rollbackData == null) { rollbackData = new RollbackData() } - + + def isTest = execution.getVariable("isTest") + + if (isTest == null || isTest == false) { + execution.setVariable("isBaseVfModule", "true") + } execution.setVariable("numOfCreatedAddOnModules", 0) rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0") - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) sleep (20000) @@ -148,6 +152,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules QueryCatalogDB Process *** ", isDebugEnabled) try { + VnfResource vnf = null ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") // if serviceDecomposition is specified, get info from serviceDecomposition if (serviceDecomposition != null) { @@ -158,87 +163,77 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { utils.log("DEBUG", "Error - vnfs are empty in serviceDecomposition object", isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnfs are empty") } - VnfResource vnf = vnfs[0] - utils.log("DEBUG", "Read vnfResource", isDebugEnabled) - if (vnf == null) { - utils.log("DEBUG", "Error - vnf is empty in serviceDecomposition object", isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnf is null") - } - - List vfModules = vnf.getAllVfModuleObjects() - utils.log("DEBUG", "Read vfModules", isDebugEnabled) - if (vfModules == null) { - utils.log("DEBUG", "Error - vfModules are empty in serviceDecomposition object", isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vf modules are empty") - } - JSONArray addOnModules = new JSONArray() - - for (int i = 0; i < vfModules.size; i++) { - utils.log("DEBUG", "handling VF Module ", isDebugEnabled) - ModuleResource vfModule = vfModules[i] - boolean isBase = vfModule.getIsBase() - if (isBase) { - ModelInfo baseVfModuleModelInfoObject = vfModule.getModelInfo() - String baseVfModuleModelInfoWithRoot = baseVfModuleModelInfoObject.toString() - String baseVfModuleModelInfo = jsonUtil.getJsonValue(baseVfModuleModelInfoWithRoot, "modelInfo") - execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) - String baseVfModuleLabel = vfModule.getVfModuleLabel() - execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) - String basePersonaModelId = baseVfModuleModelInfoObject.getModelInvariantId() - execution.setVariable("basePersonaModelId", basePersonaModelId) - } - else { - addOnModules.put(vfModules[i]) - } - } - - execution.setVariable("addOnModules", addOnModules) - execution.setVariable("addOnModulesToDeploy", addOnModules.length()) - execution.setVariable("addOnModulesDeployed", 0) - + vnf = vnfs[0] + String serviceModelName = serviceDecomposition.getModelInfo().getModelName() + vnf.constructVnfType(serviceModelName) + String vnfType = vnf.getVnfType() + utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) + execution.setVariable("vnfType", vnfType) } else { //Get Vnf Info String vnfModelInfo = execution.getVariable("vnfModelInfo") utils.log("DEBUG", "vnfModelInfo: " + vnfModelInfo, isDebugEnabled) - String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationId") + String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") if (vnfModelCustomizationUuid == null) { - vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") + vnfModelCustomizationUuid = "" } utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugEnabled) - String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint") - - JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(catalogDbEndpoint, + + JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(execution, vnfModelCustomizationUuid) utils.log("DEBUG", "obtained VNF list") // Only one match here - JSONObject vnf = vnfs[0] - JSONArray vfModules = vnf.getJSONArray("vfModules") - JSONArray addOnModules = new JSONArray() - - // Set up base Vf Module info - for (int i = 0; i < vfModules.length(); i++) { - utils.log("DEBUG", "handling VF Module ") - JSONObject vfModule = vfModules[i] - String isBase = jsonUtil.getJsonValueForKey(vfModule, "isBase") - if (isBase.equals("true")) { - JSONObject baseVfModuleModelInfoObject = vfModule.getJSONObject("modelInfo") - String baseVfModuleModelInfo = baseVfModuleModelInfoObject.toString() + JSONObject vnfObject = vnfs[0] + vnf = decomposeJsonUtil.JsonToVnfResource(vnfObject.toString()) + } + utils.log("DEBUG", "Read vnfResource", isDebugEnabled) + if (vnf == null) { + utils.log("DEBUG", "Error - vnf is empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnf is null") + } + execution.setVariable("vnfResourceDecomposition", vnf) + + List vfModules = vnf.getAllVfModuleObjects() + utils.log("DEBUG", "Read vfModules", isDebugEnabled) + if (vfModules == null) { + utils.log("DEBUG", "Error - vfModules are empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vf modules are empty") + } + + ModuleResource baseVfModule = null + + for (int i = 0; i < vfModules.size; i++) { + utils.log("DEBUG", "handling VF Module ", isDebugEnabled) + ModuleResource vfModule = vfModules[i] + boolean isBase = vfModule.getIsBase() + if (isBase) { + ModelInfo baseVfModuleModelInfoObject = vfModule.getModelInfo() + String baseVfModuleModelInfoWithRoot = baseVfModuleModelInfoObject.toString() + String baseVfModuleModelInfo = jsonUtil.getJsonValue(baseVfModuleModelInfoWithRoot, "modelInfo") execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) - String baseVfModuleLabel = jsonUtil.getJsonValueForKey(vfModule, "vfModuleLabel") + String baseVfModuleLabel = vfModule.getVfModuleLabel() execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) - String basePersonaModelId = jsonUtil.getJsonValueForKey(baseVfModuleModelInfoObject, "modelInvariantId") + String basePersonaModelId = baseVfModuleModelInfoObject.getModelInvariantUuid() execution.setVariable("basePersonaModelId", basePersonaModelId) - } - else { - addOnModules.put(vfModules[i]) - } - } - - execution.setVariable("addOnModules", addOnModules) - execution.setVariable("addOnModulesToDeploy", addOnModules.length()) - execution.setVariable("addOnModulesDeployed", 0) - } + baseVfModule = vfModule + break + } + + } + + ListaddOnModules = vfModules - baseVfModule + + int addOnModulesToDeploy = 0 + if (addOnModules != null) { + addOnModulesToDeploy = addOnModules.size + } + + utils.log("DEBUG", "AddOnModulesToDeploy: " + addOnModulesToDeploy) + + execution.setVariable("addOnModules", addOnModules) + execution.setVariable("addOnModulesToDeploy", addOnModulesToDeploy) + execution.setVariable("addOnModulesDeployed", 0) }catch(Exception ex) { utils.log("DEBUG", "Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) @@ -254,7 +249,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("vnfId", "skask") } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) + utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules QueryCatalogDB Process ***", isDebugEnabled) } public void preProcessAddOnModule(Execution execution){ @@ -263,25 +258,28 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) try { - JSONArray addOnModules = (JSONArray) execution.getVariable("addOnModules") + ListaddOnModules = execution.getVariable("addOnModules") int addOnIndex = (int) execution.getVariable("addOnModulesDeployed") - JSONObject addOnModule = addOnModules[addOnIndex] + ModuleResource addOnModule = addOnModules[addOnIndex] + + utils.log("DEBUG", "Got addon module", isDebugLogEnabled) def newVfModuleId = UUID.randomUUID().toString() execution.setVariable("addOnVfModuleId", newVfModuleId) + execution.setVariable("isBaseVfModule", "false") + + execution.setVariable("instancesOfThisModuleDeployed", 0) - execution.setVariable("instancesOfThisModelDeployed", 0) - - JSONObject addOnVfModuleModelInfoObject = jsonUtil.getJsonValueForKey(addOnModule, "modelInfo") - String addOnVfModuleModelInfoWithRoot = addOnVfModuleModelInfoObject.toString() + ModelInfo addOnVfModuleModelInfoObject = addOnModule.getModelInfo() + String addOnVfModuleModelInfoWithRoot = addOnVfModuleModelInfoObject.toString() String addOnVfModuleModelInfo = jsonUtil.getJsonValue(addOnVfModuleModelInfoWithRoot, "modelInfo") execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) - String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel") + String addOnVfModuleLabel = addOnModule.getVfModuleLabel() execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) - String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantId") + String addOnPersonaModelId = addOnVfModuleModelInfoObject.getModelInvariantUuid() execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) - String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") + int addOnInitialCount = addOnModule.getInitialCount() execution.setVariable("initialCount", addOnInitialCount) @@ -289,9 +287,25 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + logDebug("======== COMPLETED preProcessAddOnModule ======== ", isDebugLogEnabled) } + public void postProcessAddOnModule(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED postProcessAddOnModule ======== ", isDebugLogEnabled) + + try { + int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") + execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing postProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessAddOnModule Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED postProcessAddOnModule ======== ", isDebugLogEnabled) + } + public void validateBaseModule(Execution execution){ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) @@ -299,11 +313,11 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { try { def baseRollbackData = execution.getVariable("DCVAM_baseRollbackData") - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") def baseModuleMap = baseRollbackData.get("VFMODULE") baseModuleMap.each{ k, v -> rollbackData.put("VFMODULE_BASE", "${k}","${v}") } - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) logDebug("addOnModulesDeployed: " + execution.getVariable("addOnModulesDeployed"), isDebugLogEnabled) logDebug("addOnModulesToDeploy: " + execution.getVariable("addOnModulesToDeploy"), isDebugLogEnabled) if (execution.getVariable("addOnModulesDeployed") < execution.getVariable("addOnModulesToDeploy")) { @@ -329,7 +343,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { int instancesOfThisModuleDeployed = execution.getVariable("instancesOfThisModuleDeployed") int numOfCreatedAddOnModules = execution.getVariable("numOfCreatedAddOnModules") def addOnRollbackData = execution.getVariable("DCVAM_addOnRollbackData") - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") def addOnModuleMap = addOnRollbackData.get("VFMODULE") numOfCreatedAddOnModules = numOfCreatedAddOnModules + 1 @@ -341,29 +355,55 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("numOfCreatedAddOnModules", numOfCreatedAddOnModules) rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "${numOfCreatedAddOnModules}") - execution.setVariable("RollbackData", rollbackData) + execution.setVariable("rollbackData", rollbackData) }catch(Exception e){ utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } + logDebug("======== COMPLETED validateAddOnModule ======== ", isDebugLogEnabled) + } + + public void preProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) + try { + + Object workflowException = execution.getVariable("WorkflowException"); - public void finishProcessingInitialCountDeployment(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED finishProcessingInitialCountDeployment ======== ", isDebugLogEnabled) + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) + } + public void postProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) + String msg = "" try { - int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") - execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) } - -} +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy index 7b9bed3f7a..84546e11f2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy @@ -31,8 +31,8 @@ import static org.apache.commons.lang3.StringUtils.*; import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException @@ -63,12 +63,46 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { try{ // Get Rollback Variables - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") utils.log("DEBUG", "Incoming RollbackData is: " + rollbackData.toString(), isDebugEnabled) + execution.setVariable("rolledBack", null) + execution.setVariable("rollbackError", null) + + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + String vnfId = rollbackData.get("VNF", "vnfId") utils.log("DEBUG", "Rollback vnfId is: " + vnfId, isDebugEnabled) execution.setVariable("DCVAMR_vnfId", vnfId) + execution.setVariable("mso-request-id", execution.getVariable("msoRequestId")) + + execution.setVariable("DCVAMR_rollbackSDNCAssign", rollbackData.get("VNF", "rollbackSDNCAssign")) + execution.setVariable("DCVAMR_rollbackSDNCActivate", rollbackData.get("VNF", "rollbackSDNCActivate")) + execution.setVariable("DCVAMR_rollbackVnfCreate", rollbackData.get("VNF", "rollbackVnfCreate")) + + String sdncCallbackUrl = rollbackData.get("VNF", "sdncCallbackUrl") + utils.log("DEBUG", "Rollback sdncCallbackUrl is: " + sdncCallbackUrl, isDebugEnabled) + execution.setVariable("DCVAMR_sdncCallbackUrl", sdncCallbackUrl) + + String tenantId= rollbackData.get("VNF", "tenantId") + utils.log("DEBUG", "Rollback tenantId is: " + tenantId, isDebugEnabled) + execution.setVariable("DCVAMR_tenantId", tenantId) + + String source= rollbackData.get("VNF", "source") + utils.log("DEBUG", "Rollback source is: " + source, isDebugEnabled) + execution.setVariable("DCVAMR_source", source) + + String serviceInstanceId = rollbackData.get("VNF", "serviceInstanceId") + utils.log("DEBUG", "Rollback serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + execution.setVariable("DCVAMR_serviceInstanceId", serviceInstanceId) + + String cloudSiteId = rollbackData.get("VNF", "cloudSiteId") + utils.log("DEBUG", "Rollback cloudSiteId is: " + cloudSiteId, isDebugEnabled) + execution.setVariable("DCVAMR_cloudSiteId", cloudSiteId) + def numOfAddOnModulesString = rollbackData.get("VNFANDMODULES", "numOfCreatedAddOnModules") int numOfAddOnModules = 0 if (numOfAddOnModulesString != null) { @@ -105,7 +139,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { try { - def rollbackData = execution.getVariable("RollbackData") + def rollbackData = execution.getVariable("rollbackData") def vfModuleRollbackData = new RollbackData() @@ -137,17 +171,193 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) logDebug(" ======== STARTED postProcessCreateVfModuleRollback ======== ", isDebugLogEnabled) + def rolledBack = false - try { + try { + rolledBack = execution.getVariable("DCVM_rolledBack") def numOfModulesToDelete = execution.getVariable("DCVAMR_numOfModulesToDelete") execution.setVariable("DCVAMR_numOfModulesToDelete", numOfModulesToDelete - 1) }catch(Exception e){ utils.log("ERROR", "Exception Occured Processing postProcessCreateVfModuleRollback. Exception is:\n" + e, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessCreateVfModuleRollback Method:\n" + e.getMessage()) } + if (rolledBack == false) { + logDebug("Failure on DoCreateVfModuleRollback", isDebugLogEnabled) + utils.log("ERROR", "Unsuccessful rollback of DoCreateVfModule") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during rollback of DoCreateVfModule") + } logDebug("======== COMPLETED postProcessCreateVfModuleRollback ======== ", isDebugLogEnabled) } + public void preProcessSDNCDeactivateRequest(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + def vnfId = execution.getVariable("vnfId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable(Prefix + "deactivateSDNCRequest", deactivateSDNCRequest) + logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + } + + public void preProcessSDNCUnassignRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + try{ + String vnfId = execution.getVariable("vnfId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable(Prefix + "unassignSDNCRequest", unassignSDNCRequest) + logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + } + + public String buildSDNCRequest(Execution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable(Prefix + "sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def tenantId = execution.getVariable(Prefix + "tenantId") + def source = execution.getVariable(Prefix + "source") + def vnfId = execution.getVariable(Prefix + "vnfId") + def serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + def cloudSiteId = execution.getVariable(Prefix + "cloudSiteId") + + String sdncRequest = + """ + + ${uuid} + ${svcInstId} + ${action} + vnf-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + DeleteVnfInstance + ${source} + + + + + + + + ${serviceInstanceId} + + + + ${vnfId} + + + + + ${tenantId} + ${cloudSiteId} + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(Execution execution, String response, String method){ + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + utils.logAudit("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + utils.logAudit("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) + }else{ + logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + } + + public void setSuccessfulRollbackStatus (Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled) + + try{ + // Set rolledBack to true, rollbackError to null + execution.setVariable("rolledBack", true) + execution.setVariable("rollbackError", null) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing setSuccessfulRollbackStatus. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled) + } + + public void setFailedRollbackStatus (Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED setFailedRollbackStatus ======== ", isDebugLogEnabled) + + try{ + // Set rolledBack to false, rollbackError to actual value, rollbackData to null + execution.setVariable("rolledBack", false) + def rollbackError = execution.getVariable("rollbackError") + if (rollbackError == null) { + execution.setVariable("rollbackError", 'Caught exception in DoCreateVnfAndModulesRollback') + } + execution.setVariable("rollbackData", null) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing setFailedRollbackStatus. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED setFailedRollbackStatus ======== ", isDebugLogEnabled) + } + } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 2bf3e55301..72ee0d8a81 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -415,6 +415,8 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (utils.nodeExists(networkRequest, "networkModelInfo")) { String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") + } else { + modelCustomizationUuid = utils.getNodeText1(networkRequest, "modelCustomizationId") } String deleteNetworkRequest = """ @@ -772,10 +774,10 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "ActivateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-ActivateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled) + utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled) } catch (Exception ex) { @@ -892,7 +894,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { try { - if (execution.getVariable("sdncVersion") == '1702') { + if (execution.getVariable("sdncVersion") != '1610') { prepareRpcSDNCDeactivateRollback(execution) prepareRpcSDNCUnassignRollback(execution) } else { diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index 32197c1bc2..338b4cc7bc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -27,7 +27,6 @@ import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse; import org.openecomp.mso.rest.RESTClient @@ -60,6 +59,7 @@ import org.xml.sax.InputSource * @param - serviceInstanceName - O * @param - serviceModelInfo - O * @param - productFamilyId + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) * @param - sdncVersion * @param - failNotFound - TODO * @param - serviceInputParams - TODO @@ -74,7 +74,6 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { String Prefix="DDELSI_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() public void preProcessRequest (Execution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -117,6 +116,30 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) + StringBuilder sbParams = new StringBuilder() + Map paramsMap = execution.getVariable("serviceInputParams") + if (paramsMap != null) + { + sbParams.append("") + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ + ${paramName} + ${paramValue} + + """ + sbParams.append(paramsXml) + } + sbParams.append("") + } + String siParamsXml = sbParams.toString() + if (siParamsXml == null) + siParamsXml = "" + execution.setVariable("siParamsXml", siParamsXml) + } catch (BpmnError e) { throw e; } catch (Exception ex){ @@ -133,12 +156,6 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { String msg = "" try { - /* - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() - } - */ def serviceInstanceId = execution.getVariable("serviceInstanceId") def serviceInstanceName = execution.getVariable("serviceInstanceName") def callbackURL = execution.getVariable("sdncCallbackUrl") @@ -148,25 +165,25 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId String serviceModelInfo = execution.getVariable("serviceModelInfo") - def modelInvariantId = "" + def modelInvariantUuid = "" def modelVersion = "" - def modelUUId = "" + def modelUuid = "" def modelName = "" if (!isBlank(serviceModelInfo)) { - modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") + modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") - modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") + modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") - - if (modelInvariantId == null) { - modelInvariantId = "" + + if (modelInvariantUuid == null) { + modelInvariantUuid = "" } if (modelVersion == null) { modelVersion = "" } - if (modelUUId == null) { - modelUUId = "" + if (modelUuid == null) { + modelUuid = "" } if (modelName == null) { modelName = "" @@ -178,11 +195,18 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { if (serviceId == null) { serviceId = "" } - + + def siParamsXml = execution.getVariable("siParamsXml") + def serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + serviceType = "" + } + def sdncRequestId = UUID.randomUUID().toString() String sdncDelete = - """ @@ -191,6 +215,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { delete service-topology-operation ${callbackURL} + ${serviceType} @@ -205,8 +230,8 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { ${serviceId} ${subscriptionServiceType} - ${modelInvariantId} - ${modelUUId} + ${modelInvariantUuid} + ${modelUuid} ${modelVersion} ${modelName} @@ -216,6 +241,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { ${serviceInstanceName} + ${siParamsXml} """ @@ -249,7 +275,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled) utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled) - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) @@ -280,6 +306,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + String serviceType = "" if(foundInAAI == true){ utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled) @@ -304,18 +331,18 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { } //Extract Service Type if not provided on request - String serviceType = execution.getVariable("subscriptionServiceType") - if(isBlank(serviceType)){ + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + if(isBlank(subscriptionServiceType)){ int serviceStart = siRelatedLink.indexOf("service-subscription/") int serviceEnd = siRelatedLink.indexOf("/service-instances/") String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd) - serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") - execution.setVariable("subscriptionServiceType", serviceType) + subscriptionServiceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) } - if (isBlank(globalSubscriberId) || isBlank(serviceType)) + if (isBlank(globalSubscriberId) || isBlank(subscriptionServiceType)) { - msg = "Could not retrive global-customer-id & service-type from AAI to delete id:" + serviceInstanceId + msg = "Could not retrive global-customer-id & subscription-service-type from AAI to delete id:" + serviceInstanceId utils.log("DEBUG", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } @@ -332,6 +359,11 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { else { utils.log("DEBUG", "SI Data" + siData, isDebugEnabled) + serviceType = utils.getNodeText1(siData,"service-type") + execution.setVariable("serviceType", serviceType) + execution.setVariable("serviceRole", utils.getNodeText1(siData,"service-role")) + String orchestrationStatus = utils.getNodeText1(siData,"orchestration-status") + //Confirm there are no related service instances (vnf/network or volume) if (utils.nodeExists(siData, "relationship-list")) { utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled) @@ -346,8 +378,8 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { if (node.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) node def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() - if(e.equals("generic-vnf") || e.equals("l3-network")){ - utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs or l3-networks", isDebugEnabled) + if(e.equals("generic-vnf") || e.equals("l3-network") || e.equals("allotted-resource") ){ + utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs, l3-networks or allotted-resources", isDebugEnabled) execution.setVariable("siInUse", true) //there are relationship dependencies to this Service Instance msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId @@ -359,6 +391,21 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { } } } + + if ("TRANSPORT".equalsIgnoreCase(serviceType)) + { + if ("PendingDelete".equals(orchestrationStatus)) + { + execution.setVariable("skipDeactivate", true) + } + else + { + msg = "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status:" + orchestrationStatus + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + } } }else{ boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") @@ -376,6 +423,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) } } + utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) } } catch (BpmnError e) { @@ -387,7 +435,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { } utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled) } - + public void postProcessAAIDEL(Execution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index cd9c798c09..afb09839b4 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -36,6 +36,8 @@ import org.springframework.web.util.UriUtils import org.w3c.dom.Document import org.w3c.dom.Element import org.xml.sax.InputSource +import org.w3c.dom.Node +import org.w3c.dom.NodeList; /* Subflow for Delete VF Module. When no DoDeleteVfModuleRequest is specified on input, @@ -51,6 +53,7 @@ import org.xml.sax.InputSource * @param - vfModuleModelInfo * @param - cloudConfiguration* * @param - sdncVersion ("1610") +* @param - retainResources * * Outputs: * @param - WorkflowException @@ -114,7 +117,12 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ //vfModuleModelName def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") execution.setVariable("vfModuleModelName", vfModuleModelName) - + // retainResources + def retainResources = execution.getVariable("retainResources") + if (retainResources == null) { + retainResources = false + } + execution.setVariable("retainResources", retainResources) } else { @@ -179,6 +187,11 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ public void prepSDNCAdapterRequest(Execution execution, String action) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("requestId") + "-" + System.currentTimeMillis() + } + def srvInstId = execution.getVariable("srvInstId") def callbackUrl = execution.getVariable("URN_mso_workflow_sdncadapter_callback") String requestId = execution.getVariable("requestId") @@ -198,11 +211,16 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ } String vfModuleModelName = execution.getVariable("vfModuleModelName") String cloudSiteId = execution.getVariable("cloudSiteId") + boolean retainResources = execution.getVariable("retainResources") + String requestSubActionString = "" + if (retainResources) { + requestSubActionString = "RetainResource" + } String request = """ - ${requestId} + ${uuid} ${vfModuleId} ${action} vnf-topology-operation @@ -212,6 +230,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ ${requestId} DisconnectVNFRequest + ${requestSubActionString} ${source} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy new file mode 100644 index 0000000000..41663434db --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -0,0 +1,613 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VfModule +import org.openecomp.mso.bpmn.common.scripts.VfModuleBase +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.springframework.web.util.UriUtils +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.xml.sax.InputSource + +public class DoDeleteVfModuleFromVnf extends VfModuleBase { + + def Prefix="DDVFMV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void initProcessVariables(Execution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null) + } + + // parse the incoming request + public void preProcessRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + initProcessVariables(execution) + + try { + + // Building Block-type request + + // Set mso-request-id to request-id for VNF Adapter interface + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("mso-request-id", requestId) + execution.setVariable("requestId", requestId) + utils.log("DEBUG", "msoRequestId: " + requestId, isDebugEnabled) + String tenantId = execution.getVariable("tenantId") + utils.log("DEBUG", "tenantId: " + tenantId, isDebugEnabled) + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("cloudSiteId", cloudSiteId) + utils.log("DEBUG", "cloudSiteId: " + cloudSiteId, isDebugEnabled) + // Source is HARDCODED + String source = "VID" + execution.setVariable("source", source) + // isVidRequest is hardcoded to "true" + execution.setVariable("isVidRequest", "true") + // SrvInstId is hardcoded to empty + execution.setVariable("srvInstId", "") + // ServiceId is hardcoded to empty + execution.setVariable("serviceId", "") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "serviceInstanceId: " + serviceInstanceId, isDebugEnabled) + String vnfId = execution.getVariable("vnfId") + utils.log("DEBUG", "vnfId: " + vnfId, isDebugEnabled) + String vfModuleId = execution.getVariable("vfModuleId") + utils.log("DEBUG", "vfModuleId: " + vfModuleId, isDebugEnabled) + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) + } + else { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) + } + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1707" + } + execution.setVariable(Prefix + "sdncVersion", sdncVersion) + utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) + + String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) + utils.log("DEBUG:", "SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) + + + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + utils.log("DEBUG", "Exception is: " + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") + } + } + + public void queryAAIForVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.queryAAIForVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + + utils.logAudit("DoDeleteVfModuleFromVnf: AAI endPoint : " + endPoint) + + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def aaiRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', aaiRequestId). + addHeader('X-FromAppId', 'MSO'). + addHeader('Content-Type', 'application/xml'). + addHeader('Accept','application/xml'); + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + APIResponse response = client.httpGet() + utils.logAudit("DoDeleteVfModuleFromVnf: - invoking httpGet to AAI") + + responseData = response.getResponseBodyAsString() + execution.setVariable('DDVMFV_getVnfResponseCode', response.getStatusCode()) + execution.setVariable('DDVMFV_getVnfResponse', responseData) + + utils.logAudit("DoDeleteVfModuleFromVnf: AAI Response : " + responseData) + utils.logAudit("DoDeleteVfModuleFromVnf: AAI ResponseCode : " + response.getStatusCode()) + + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(), isDebugLogEnabled) + execution.setVariable('DDVMFV_getVnfResponseCode', 500) + execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + 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(Execution execution) { + def method = getClass().getSimpleName() + '.validateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def genericVnf = execution.getVariable('DDVMFV_getVnfResponse') + def vnfId = execution.getVariable('_vnfId') + def vfModuleId = execution.getVariable('vfModuleId') + def VfModule vfModule = findVfModule(genericVnf, vfModuleId) + if (vfModule == null) { + def String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\'' + logDebug(msg, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, msg) + } else { + + if (isDebugLogEnabled) { + logDebug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() + + ', isOnlyVfModule=' + vfModule.isOnlyVfModule(), + isDebugLogEnabled) + } + if (vfModule.isBaseVfModule() && !vfModule.isOnlyVfModule()) { + def String msg = 'Cannot delete VF Module \'' + vfModuleId + + '\'since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\'' + logDebug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + + def heatStackId = vfModule.getElementText('heat-stack-id') + execution.setVariable('DDVMFV_heatStackId', heatStackId) + logDebug('VF Module heatStackId retrieved from AAI: ' + heatStackId, isDebugLogEnabled) + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) + } + } + + + public void preProcessSDNCDeactivateRequest(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable("DDVMFV_deactivateSDNCRequest", deactivateSDNCRequest) + logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + } + + public void preProcessSDNCUnassignRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + try{ + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DDVMFV_unassignSDNCRequest", unassignSDNCRequest) + logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + } + + public String buildSDNCRequest(Execution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("serviceId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def vfModuleId = execution.getVariable("vfModuleId") + def source = execution.getVariable("source") + def vnfId = execution.getVariable("vnfId") + + def sdncVersion = execution.getVariable(Prefix + "sdncVersion") + + String sdncRequest = + """ + + ${uuid} + ${svcInstId} + ${action} + vf-module-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + DeleteVfModuleInstance + ${source} + + + + + + + + ${serviceInstanceId} + + + + ${vnfId} + + + + ${vfModuleId} + + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(Execution execution, String response, String method){ + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + utils.logAudit("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + utils.logAudit("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) + }else{ + logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + } + + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def requestId = UUID.randomUUID().toString() + def origRequestId = execution.getVariable('requestId') + def srvInstId = execution.getVariable("serviceInstanceId") + def aicCloudRegion = execution.getVariable("cloudSiteId") + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + def vfModuleStackId = execution.getVariable('DDVMFV_heatStackId') + def tenantId = execution.getVariable("tenantId") + def messageId = execution.getVariable('requestId') + '-' + + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ + + ${aicCloudRegion} + ${tenantId} + ${vnfId} + ${vfModuleId} + ${vfModuleStackId} + true + + ${origRequestId} + ${srvInstId} + + ${messageId} + ${notificationUrl} + + """ as String + + utils.log("DEBUG", "vnfAdapterRestV1Request: " + request, isDebugEnabled) + utils.logAudit("deleteVfModuleRequest: " + request) + execution.setVariable("vnfAdapterRestV1Request", request) + } + + + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: " + + execution.getVariable("DDVFMV_deleteGenericVnfResponse"), isDebugEnabled) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("DDVFMV_deleteGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + public void postProcessVNFAdapterRequest(Execution execution) { + def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix",Prefix) + try{ + logDebug(" *** STARTED postProcessVNFAdapterRequest Process*** ", isDebugLogEnabled) + + String vnfResponse = execution.getVariable("DDVMFV_doDeleteVfModuleResponse") + logDebug("VNF Adapter Response is: " + vnfResponse, isDebugLogEnabled) + utils.logAudit("deleteVnfAResponse is: \n" + vnfResponse) + + if(vnfResponse != null){ + + if(vnfResponse.contains("deleteVfModuleResponse")){ + logDebug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.", isDebugLogEnabled) + execution.setVariable("DDVFMV_vnfVfModuleDeleteCompleted", true) + + // Parse vnfOutputs for contrail network polcy FQDNs + if (vnfResponse.contains("vfModuleOutputs")) { + def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") + InputSource source = new InputSource(new StringReader(vfModuleOutputsXml)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document outputsXml = docBuilder.parse(source) + + NodeList entries = outputsXml.getElementsByTagNameNS("*", "entry") + List contrailNetworkPolicyFqdnList = [] + for (int i = 0; i< entries.getLength(); i++) { + Node node = entries.item(i) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node + String key = element.getElementsByTagNameNS("*", "key").item(0).getTextContent() + if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + logDebug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn, isDebugLogEnabled) + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + logDebug("Obtained oamManagementV4Address: " + oamManagementV4Address, isDebugLogEnabled) + execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + logDebug("Obtained oamManagementV6Address: " + oamManagementV6Address, isDebugLogEnabled) + execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) + } + + } + } + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + logDebug("Setting the fqdn list", isDebugLogEnabled) + execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) + } + } + }else{ + logDebug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + }else{ + logDebug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") + } + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + logDebug("Internal Error Occured in PostProcess Method", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") + } + logDebug(" *** COMPLETED postProcessVnfAdapterResponse Process*** ", isDebugLogEnabled) + } + + public void deleteNetworkPoliciesFromAAI(Execution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED deleteNetworkPoliciesFromAAI ======== ", isDebugLogEnabled) + + try { + // get variables + List fqdnList = execution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList") + if (fqdnList == null) { + logDebug("No network policies to delete", isDebugLogEnabled) + return + } + int fqdnCount = fqdnList.size() + + execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount) + logDebug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled) + + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + 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") + utils.logAudit("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) + logDebug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest, isDebugLogEnabled) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) + int returnCode = response.getStatusCode() + execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) + logDebug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugLogEnabled) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (isOneOf(returnCode, 200, 201)) { + logDebug("The return code is: " + returnCode, isDebugLogEnabled) + // This network policy FQDN exists in AAI - need to delete it now + utils.logAudit(aaiResponseAsString) + execution.setVariable("DDVFMV_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) + logDebug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugLogEnabled) + // Retrieve the network policy id for this FQDN + def networkPolicyId = utils.getNodeText1(aaiResponseAsString, "network-policy-id") + logDebug("Deleting network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled) + + // Retrieve the resource version for this network policy + def resourceVersion = utils.getNodeText1(aaiResponseAsString, "resource-version") + logDebug("Deleting network-policy with resource-version " + resourceVersion, isDebugLogEnabled) + + String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + utils.logAudit("AAI request endpoint: " + delNetworkPolicyAAIRequest) + logDebug("AAI request endpoint: " + delNetworkPolicyAAIRequest, isDebugLogEnabled) + + logDebug("invoking DELETE call to AAI", isDebugLogEnabled) + utils.logAudit("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest) + APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest) + int returnCodeDel = responseDel.getStatusCode() + execution.setVariable("DDVFMV_aaiDeleteNetworkPolicyReturnCode", returnCodeDel) + logDebug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel, isDebugLogEnabled) + + if (isOneOf(returnCodeDel, 200, 201, 204)) { + logDebug("The return code from deleting network policy is: " + returnCodeDel, isDebugLogEnabled) + // This network policy was deleted from AAI successfully + logDebug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ", isDebugLogEnabled) + + } else { + // aai all errors + String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel + logDebug(delErrorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) + } + } else if (returnCode == 404) { + // This network policy FQDN is not in AAI. No need to delete. + logDebug("The return code is: " + returnCode, isDebugLogEnabled) + logDebug("This network policy FQDN is not in AAI: " + fqdn, isDebugLogEnabled) + utils.logAudit("Network policy FQDN is not in AAI") + } 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 deleteNetworkPoliciesFromAAI - " + returnCode + logDebug(dataErrorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + + + + } // end loop + + + } else { + logDebug("No contrail network policies to query/create", isDebugLogEnabled) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + logDebug(exceptionMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${vnfId} + ${vfModuleId} + """ as String + utils.log("DEBUG", "DeleteAAIVfModuleRequest :" + request, isDebugEnabled) + utils.logAudit("DeleteAAIVfModuleRequest: " + request) + execution.setVariable("DeleteAAIVfModuleRequest", request) + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy new file mode 100644 index 0000000000..c2952ad0f4 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -0,0 +1,358 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts + +import groovy.json.JsonSlurper +import groovy.util.XmlParser; + +import java.util.concurrent.ExecutionException; + +import org.springframework.web.util.UriUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.apache.commons.lang3.* + +class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor { + + String prefix="DDVMV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + XmlParser xmlParser = new XmlParser() + JsonUtils jsonUtil = new JsonUtils() + + @Override + public void preProcessRequest(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + /** + * Set default variable values + * @param execution + * @param isDebugLogEnabled + */ + public void preProcessRequest (Execution execution, isDebugEnabled) { + + //Input: + // msoRequestId + // isDebugLogEnabled + // failIfNotFound (Optional) + // serviceInstanceId (Optional) + // vnfId (Optional) + // volumeGroupId + // vfModuleModelInfo (Optional) + // lcpCloudRegionId (Optional) @TODO: this is actually required + // tenantId (Optional) @TODO: this is actually required + // cloudConfiguration @TODO: temporary solution? this contains lcpCloudregion and tenantId + // + //Output: + // 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") + utils.log("DEBUG", "Using cloudConfiguration variable to get tenantId and lcpCloudRegionId - " + cloudConfiguration, isDebugEnabled) + tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") + execution.setVariable("tenantId", tenantId) + cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", cloudSiteId) + } + } + + + /** + * Set out 'wasDeleted' variable to 'true' + * @param execution + * @param isDebugLogEnabled + */ + public void postProcess(Execution execution, isDebugLogEnabled) { + execution.setVariable('wasDeleted', 'true') + } + + + /** + * Query and set cloud region to use for AAI calls + * Output variables: prefix+'aicCloudRegion', prefix+'cloudRegion' + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAICloudRegion(Execution execution, isDebugEnabled) { + + String cloudRegion = execution.getVariable('lcpCloudRegionId') + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + utils.logAudit(queryCloudRegionRequest) + utils.log("DEBUG", "AAI query cloud region URI - " + queryCloudRegionRequest, isDebugEnabled) + + cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + + if ((cloudRegion != "ERROR")) { + if(execution.getVariable(prefix+"queryCloudRegionReturnCode") == "404") { + execution.setVariable(prefix+"aicCloudRegion", "AAIAIC25") + } + else{ + execution.setVariable(prefix+"aicCloudRegion", cloudRegion) + } + } + else { + utils.log("DEBUG", "AAI Query Cloud Region Unsuccessful.", isDebugEnabled) + 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' + * @param execution + * @param isDebugLogEnabled + */ + public void callRESTQueryAAIForVolumeGroup(Execution execution, isDebugLogEnabled) { + + 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') + } + 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") + + utils.logAudit('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) + logDebug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest, isDebugLogEnabled) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI query volume group by id return code: " + returnCode) + utils.logAudit("AAI query volume group by id response: " + aaiResponseAsString) + logDebug('AAI query volume group by id return code: ' + returnCode, isDebugLogEnabled) + logDebug('AAI query volume group by id response: ' + aaiResponseAsString, isDebugLogEnabled) + + execution.setVariable(prefix+"queryAAIVolGrpResponse", aaiResponseAsString) + + if (returnCode=='200' || returnCode == '204') { + + def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id') + execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId) + + logDebug('Heat stack id from AAI response: ' + heatStackId, isDebugLogEnabled) + + if(hasVfModuleRelationship(aaiResponseAsString)){ + utils.log("DEBUG", 'Volume Group ' + volumeGroupId + ' currently in use', isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") + } + + def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) + logDebug('Tenant ID from AAI response: ' + volumeGroupTenantId, isDebugLogEnabled) + + if (volumeGroupTenantId == null) { + utils.log("DEBUG", "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}", isDebugLogEnabled) + 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 + utils.log("DEBUG", "Error in DeleteVfModuleVolume: " + errorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, errorMessage) + } + logDebug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId , isDebugLogEnabled) + } + else { + if (returnCode=='404') { + utils.log("DEBUG", "Volume Group ${volumeGroupId} not found in AAI", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404") + } + else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + /** + * Format VNF Adapter subflow request XML + * Variables: prefix+'deleteVnfARequest' + * @param execution + * @param isDebugLogEnabled + */ + public void prepareVnfAdapterDeleteRequest(Execution 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 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) + + def messageId = UUID.randomUUID().toString() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String vnfAdapterRestRequest = """ + + ${cloudRegion} + ${tenantId} + ${volumeGroupId} + ${volumeGroupHeatStackId} + true + + ${requestId} + ${serviceId} + + ${messageId} + ${notificationUrl} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable(prefix+'deleteVnfARequest', vnfAdapterRestRequest) + logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled) + } + + + /** + * Delete volume group in AAI + * @param execution + * @param isDebugEnabled + */ + public void callRESTDeleteAAIVolumeGroup(Execution 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') + } + + utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) + utils.log("DEBUG", "Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest, isDebugEnabled) + + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI delete volume group return code: " + returnCode) + utils.logAudit("AAI delete volume group response: " + aaiResponseAsString) + utils.log("DEBUG", "AAI delete volume group return code: " + returnCode, isDebugEnabled) + utils.log("DEBUG", "AAI delete volume group response: " + aaiResponseAsString, isDebugEnabled) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + if (returnCode=='200' || (returnCode == '204')) { + utils.log("DEBUG", "Volume group $groupId deleted.", isDebugEnabled) + } else { + if (returnCode=='404') { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $groupId not found for delete in AAI Response code: 404") + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + /** + * Check if volume group has a relationship to vf-module + * @param volumeGroupXml + * @return + */ + private boolean hasVfModuleRelationship(String volumeGroupXml) { + def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml) + def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list') + if (relationshipList != null) { + def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (Node relationship in relationships) { + def Node relatedTo = utils.getChildNode(relationship, 'related-to') + if ((relatedTo != null) && (relatedTo.text().equals('vf-module'))) { + def Node relatedLink = utils.getChildNode(relationship, 'related-link') + if (relatedLink !=null && relatedLink.text() != null){ + return true + } + } + } + } + return false + } + + + /** + * Extract the Tenant Id from the Volume Group information returned by AAI. + * @param volumeGroupXml Volume Group XML returned by AAI. + * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if + * the Tenant Id is missing or could not otherwise be extracted. + */ + private String getTenantIdFromVolumeGroup(String volumeGroupXml) { + def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml) + def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list') + if (relationshipList != null) { + def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (Node relationship in relationships) { + def Node relatedTo = utils.getChildNode(relationship, 'related-to') + if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) { + def NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data') + for (Node relationshipData in relationshipDataList) { + def Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key') + if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) { + def Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value') + if (relationshipValue != null) { + return relationshipValue.text() + } + } + } + } + } + } + return null + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 208caa790d..23f036896f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -23,7 +23,6 @@ import java.util.UUID; import org.json.JSONObject; import org.json.JSONArray; - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution; @@ -35,12 +34,12 @@ import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException +import org.springframework.web.util.UriUtils; /** * This class supports the macro VID Flow @@ -69,7 +68,8 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { try{ // Get Variables - String cloudConfiguration = execution.getVariable("cloudConfiguration") + String cloudConfiguration = execution.getVariable("cloudConfiguration") + utils.log("DEBUG", "Cloud Configuration: " + cloudConfiguration, isDebugEnabled) String requestId = execution.getVariable("msoRequestId") execution.setVariable("requestId", requestId) @@ -86,6 +86,8 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("DDVAM_source", source) utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) + execution.setVariable("DDVAM_isVidRequest", "true") + String sdncVersion = execution.getVariable("sdncVersion") if (sdncVersion == null) { sdncVersion = "1702" @@ -165,7 +167,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") } - utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) + utils.log("DEBUG", "*** COMPLETED DoDeleteVnfAndModules PreProcessRequest Process ***", isDebugEnabled) } @@ -191,7 +193,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel") execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) - String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantId") + String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantUuid") execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") execution.setVariable("initialCount", addOnInitialCount) @@ -389,7 +391,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { String uuid = execution.getVariable('testReqId') // for junits if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() } def callbackURL = execution.getVariable("sdncCallbackUrl") def requestId = execution.getVariable("msoRequestId") @@ -399,7 +401,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable("vnfId") def serviceInstanceId = execution.getVariable("serviceInstanceId") def cloudSiteId = execution.getVariable("DDVAM_cloudSiteId") - def modelCustomizationId = execution.getVariable("DDVAM_modelCustomizationId") + def modelCustomizationId = execution.getVariable("DDVAM_modelCustomizationId") //def serviceModelInfo = execution.getVariable("serviceModelInfo") //def vnfModelInfo = execution.getVariable("vnfModelInfo") //String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) @@ -412,7 +414,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${svcInstId} ${action} vnf-topology-operation diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 5bd9f96bc6..7feafcc421 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -539,9 +539,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { 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) + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" } } else { @@ -550,7 +550,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" } utils.logAudit(queryVpnBindingAAIRequest) @@ -673,9 +673,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { 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) + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" } } else { // using uri value in URN mapping @@ -684,7 +684,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" } @@ -809,9 +809,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { 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) + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" } } else { // using uri value in URN mapping @@ -820,7 +820,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" } @@ -1308,7 +1308,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { - if (execution.getVariable("sdncVersion") == '1702') { + if (execution.getVariable("sdncVersion") != '1610') { // skip: 1702 for 'changeassign' or equivalent not yet defined in SNDC, so no rollback. } else { prepareSDNCRollbackRequest(execution) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index f07bb0df49..87a6a73fb0 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -36,6 +36,7 @@ import org.springframework.web.util.UriUtils public class DoUpdateVfModule extends VfModuleBase { ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() /** * Initialize the flow's variables. @@ -62,6 +63,7 @@ public class DoUpdateVfModule extends VfModuleBase { execution.setVariable('DOUPVfMod_aicCloudRegion', null) execution.setVariable('DOUPVfMod_tenantId', null) execution.setVariable('DOUPVfMod_volumeGroupId', null) + execution.setVariable("DOUPVfMod_volumeGroupStackId", "") execution.setVariable('DOUPVfMod_vfModule', null) execution.setVariable('DOUPVfMod_vnfParams', null) execution.setVariable("DOUPVfMod_baseVfModuleId", "") @@ -110,18 +112,16 @@ public class DoUpdateVfModule extends VfModuleBase { //tenantId - def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId") + def tenantId = execution.getVariable("tenantId") execution.setVariable("DOUPVfMod_tenantId", tenantId) //volumeGroupId def volumeGroupId = execution.getVariable("volumeGroupId") execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) - //volumeGroupName - def volumeGroupName = execution.getVariable("volumeGroupName") - execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName) + //cloudSiteId - def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") - execution.setVariable("DOUPVfMod_cloudSiteId", cloudSiteId) + def cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId) logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled) //vnfType @@ -150,7 +150,10 @@ public class DoUpdateVfModule extends VfModuleBase { logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled) //modelCustomizationUuid - def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationId") + def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") + if (modelCustomizationUuid == null) { + modelCustomizationUuid = "" + } execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled) @@ -158,7 +161,7 @@ public class DoUpdateVfModule extends VfModuleBase { def vfModuleId = execution.getVariable("vfModuleId") execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId) logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled) - def requestId = execution.getVariable("requestId") + def requestId = execution.getVariable("msoRequestId") execution.setVariable("DOUPVfMod_requestId", requestId) logDebug("requestId: " + requestId, isDebugLogEnabled) // Set mso-request-id to request-id for VNF Adapter interface @@ -194,7 +197,7 @@ public class DoUpdateVfModule extends VfModuleBase { execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion) logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) //personaModelId - execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId")) + execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid")) //personaModelVersion execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion")) //Get or Generate UUID @@ -211,6 +214,10 @@ public class DoUpdateVfModule extends VfModuleBase { if (isVidRequest == null || isVidRequest.isEmpty()) { execution.setVariable("isVidRequest", "true") } + //usePreload + def usePreload = execution.getVariable("usePreload") + execution.setVariable("DOUPVfMod_usePreload", usePreload) + logDebug("usePreload: " + usePreload, isDebugLogEnabled) //globalSubscriberId String globalSubscriberId = execution.getVariable("globalSubscriberId") execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId) @@ -323,8 +330,8 @@ public class DoUpdateVfModule extends VfModuleBase { } /** - * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. Currently, - * there is really nothing to do, so we just log that we're passing through. + * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. + * Determine cloud region id for the volume group. * * @param execution The flow's execution instance. */ @@ -332,21 +339,54 @@ public class DoUpdateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + 'execution=' + execution.getId() + ')' + + def prefix = execution.getVariable("prefix") def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) try { - // Nothing to do - just log that we're passing through here + String cloudRegion = execution.getVariable(prefix + "aicCloudRegion") - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage()) + // Prepare AA&I url + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + utils.logAudit("CloudRegion Request: " + queryCloudRegionRequest) + + execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + utils.log("DEBUG", prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugLogEnabled) + + cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion) + + if ((cloudRegion != "ERROR")) { + if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){ + execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25") + }else{ + execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion) + } + execution.setVariable(prefix + "isCloudRegionGood", true) + } else { + String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode") + utils.log("DEBUG", errorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + execution.setVariable(prefix + "isCloudRegionGood", false) + } + utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"), isDebugLogEnabled) + + } catch(BpmnError b){ + utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugLogEnabled) + throw b + }catch (Exception e) { + // try error + String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage() + utils.log("ERROR", " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage()) } + logDebug('Exited ' + method, isDebugLogEnabled) + } - + /** * Prepare a Request for invoking the SDNC Adapter subflow to perform * a VNF topology 'changeassign' operation. @@ -362,6 +402,10 @@ public class DoUpdateVfModule extends VfModuleBase { try { def requestId = execution.getVariable('DOUPVfMod_requestId') + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis() + } def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') def serviceId = execution.getVariable('DOUPVfMod_serviceId') @@ -373,6 +417,13 @@ public class DoUpdateVfModule extends VfModuleBase { def vfModuleName = vfModule.getElementText('vf-module-name') def tenantId = execution.getVariable('DOUPVfMod_tenantId') def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion') + boolean usePreload = execution.getVariable("DOUPVfMod_usePreload") + String usePreloadToSDNC = usePreload ? "Y" : "N" + def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid") + def modelCustomizationUuidString = "" + if (!usePreload) { + modelCustomizationUuidString = "" + modelCustomizationUuid + "" + } // Retrieve vnf name from AAI response def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI') @@ -386,7 +437,7 @@ public class DoUpdateVfModule extends VfModuleBase { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${serviceInstanceId} changeassign vnf-topology-operation @@ -415,6 +466,8 @@ public class DoUpdateVfModule extends VfModuleBase { ${vnfType} ${tenantId} ${aicCloudRegion} + ${modelCustomizationUuidString} + ${usePreloadToSDNC} ${vnfNetworks} @@ -448,6 +501,10 @@ public class DoUpdateVfModule extends VfModuleBase { logDebug('Entered ' + method, isDebugLogEnabled) try { + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis() + } def requestId = execution.getVariable('DOUPVfMod_requestId') def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') @@ -469,7 +526,7 @@ public class DoUpdateVfModule extends VfModuleBase { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${svcInstId} query /VNF-API:vnfs/vnf-list/${vfModuleId} @@ -513,6 +570,7 @@ public class DoUpdateVfModule extends VfModuleBase { def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') def tenantId = execution.getVariable('DOUPVfMod_tenantId') def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId') + def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId') def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule') def heatStackId = vfModule.getElementText('heat-stack-id') def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion') @@ -552,6 +610,7 @@ public class DoUpdateVfModule extends VfModuleBase { ${modelCustomizationUuid} ${vfModuleModelName} ${volumeGroupId} + ${volumeGroupStackId} ${baseVfModuleId} ${baseVfModuleStackId} true @@ -671,7 +730,7 @@ public class DoUpdateVfModule extends VfModuleBase { def personaModelCustomizationIdElement = '' def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid') if (modelCustomizationId != null) { - personaModelCustomizationIdElement = '' + modelCustomizationId + '' + personaModelCustomizationIdElement = '' + modelCustomizationId + '' } String updateAAIVfModuleRequest = """ @@ -716,6 +775,10 @@ public class DoUpdateVfModule extends VfModuleBase { logDebug('Entered ' + method, isDebugLogEnabled) try { + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis() + } def requestId = execution.getVariable('DOUPVfMod_requestId') def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') @@ -730,6 +793,14 @@ public class DoUpdateVfModule extends VfModuleBase { def tenantId = execution.getVariable('DOUPVfMod_tenantId') def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion') + boolean usePreload = execution.getVariable("DOUPVfMod_usePreload") + String usePreloadToSDNC = usePreload ? "Y" : "N" + def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid") + def modelCustomizationUuidString = "" + if (!usePreload) { + modelCustomizationUuidString = "" + modelCustomizationUuid + "" + } + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) @@ -738,7 +809,7 @@ public class DoUpdateVfModule extends VfModuleBase { xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - ${requestId} + ${uuid} ${serviceInstanceId} activate vnf-topology-operation @@ -767,6 +838,8 @@ public class DoUpdateVfModule extends VfModuleBase { ${vnfType} ${tenantId} ${aicCloudRegion} + ${modelCustomizationUuidString} + ${usePreloadToSDNC} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy new file mode 100644 index 0000000000..7d7505f307 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -0,0 +1,391 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts + +import java.io.ObjectInputStream.BlockDataInputStream +import java.util.UUID; + +import org.json.JSONObject; +import org.json.JSONArray; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +import org.hibernate.jpa.criteria.predicate.IsEmptyPredicate + +import static org.apache.commons.lang3.StringUtils.*; + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.ModuleResource +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.WorkflowException +import org.springframework.web.util.UriUtils; + +/** + * This class supports the VID Flow + * with the update of a generic vnf and related VF modules. + */ +class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { + + String Prefix="DUVAM_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED DoUpdateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) + + try{ + // Get Variables + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("requestId", requestId) + execution.setVariable("mso-request-id", requestId) + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + + String vnfId = execution.getVariable("vnfId") + utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) + + String source = "VID" + execution.setVariable("DUVAM_source", source) + utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DUVAM_sdncVersion", sdncVersion) + utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) + + VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition") + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + String serviceModelInfo = execution.getVariable("serviceModelInfo") + + String serviceId = execution.getVariable("productFamilyId") + execution.setVariable("DUVAM_serviceId", serviceId) + utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) + + String modelUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid") + execution.setVariable("DUVAM_modelUuid", modelUuid) + utils.log("DEBUG", "Incoming modelUuid is: " + modelUuid, isDebugEnabled) + + String modelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") + execution.setVariable("DUVAM_modelCustomizationUuid", modelCustomizationUuid) + utils.log("DEBUG", "Incoming Model Customization Uuid is: " + modelCustomizationUuid, isDebugEnabled) + + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DUVAM_cloudSiteId", cloudSiteId) + utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DUVAM_tenantId", tenantId) + utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if (globalSubscriberId == null) { + globalSubscriberId = "" + } + execution.setVariable("DUVAM_globalSubscriberId", globalSubscriberId) + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + + execution.setVariable("DUVAM_moduleCount", 0) + execution.setVariable("DUVAM_nextModule", 0) + + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error Occured in DoUpdateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoUpdateVnfAndModules PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED DoUpdateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) + } + + /** + * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. + * A 200 response is expected with the VNF info in the response body. Will find out the base module info. + * + * @param execution The flow's execution instance. + */ + public void queryAAIVfModule(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def method = getClass().getSimpleName() + '.queryAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + utils.logAudit("AAI endPoint: " + endPoint) + + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def aaiRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', aaiRequestId). + addHeader('X-FromAppId', 'MSO'). + addHeader('Content-Type', 'application/xml'). + addHeader('Accept','application/xml'); + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + APIResponse response = client.httpGet() + utils.logAudit("createVfModule - invoking httpGet() to AAI") + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) + + } + + utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) + utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('DUVAM_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DUVAM_queryAAIVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + //Map[] vfModules = new HashMap[] + def vfModulesList = new ArrayList>() + def vfModules = null + def vfModuleBaseEntry = null + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + logDebug("vModulesText: " + vfModulesText, isDebugLogEnabled) + if (vfModulesText != null && !vfModulesText.trim().isEmpty()) { + def xmlVfModules= new XmlSlurper().parseText(vfModulesText) + vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} + execution.setVariable("DUVAM_moduleCount", vfModules.size()) + int vfModulesSize = 0 + for (i in 0..vfModules.size()-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + + Map vfModuleEntry = new HashMap() + def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") + vfModuleEntry.put("vfModuleId", vfModuleId) + def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name") + vfModuleEntry.put("vfModuleName", vfModuleName) + def modelInvariantUuid = utils.getNodeText1(vfModuleXml, "model-invariant-id") + vfModuleEntry.put("modelInvariantUuid", modelInvariantUuid) + def modelUuid = utils.getNodeText1(vfModuleXml, "model-version-id") + vfModuleEntry.put("modelUuid", modelUuid) + def modelCustomizationUuid = utils.getNodeText1(vfModuleXml, "model-customization-id") + vfModuleEntry.put("modelCustomizationUuid", modelCustomizationUuid) + + def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") + vfModuleEntry.put("isBaseVfModule", isBaseVfModule) + // Save base vf module to add it to the start of the list later + if (isBaseVfModule == "true") { + vfModuleBaseEntry = vfModuleEntry + } + else { + vfModulesList.add(vfModuleEntry) + } + } + // Start the list with the base module if any + if (vfModuleBaseEntry != null) { + vfModulesList.add(0, vfModuleBaseEntry) + } + } + + } + } + else { + logDebug('Response code from AAI GET is: ' + response.getStatusCode(), isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Response code from AAI GET is: ' + response.getStatusCode()) + } + execution.setVariable("DUVAM_vfModules", vfModulesList) + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + public void prepareNextModuleToUpdate(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED prepareNextModuleToUpdate ======== ", isDebugLogEnabled) + + try { + int i = execution.getVariable("DUVAM_nextModule") + def vfModules = execution.getVariable("DUVAM_vfModules") + def vfModule = vfModules[i] + + def vfModuleId = vfModule.get("vfModuleId") + execution.setVariable("DUVAM_vfModuleId", vfModuleId) + + def vfModuleName = vfModule.get("vfModuleName") + execution.setVariable("DUVAM_vfModuleName", vfModuleName) + + def isBaseVfModule = vfModule.get("isBaseVfModule") + execution.setVariable("DUVAM_isBaseVfModule", isBaseVfModule) + + String modelInvariantUuid = vfModule.get("modelInvariantUuid") + logDebug("ModelInvariantUuid: " + modelInvariantUuid, isDebugLogEnabled) + + execution.setVariable("DUVAM_volumeGroupId", "") + execution.setVariable("DUVAM_volumeGroupName", "") + + VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition") + List moduleResources = vnfResource.getVfModules() + + for (j in 0..moduleResources.size()-1) { + ModelInfo modelInfo = moduleResources[j].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled) + + if (modelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + String vfModuleModelInfo = modelInfo.toJsonString() + String vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfo, "modelInfo") + execution.setVariable("DUVAM_vfModuleModelInfo", vfModuleModelInfoValue) + logDebug("vfModuleModelInfo: " + vfModuleModelInfoValue, isDebugLogEnabled) + break + } + + } + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToUpdate Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED prepareNextModuleToUpdate ======== ", isDebugLogEnabled) + } + + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(Execution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('vnfId') + VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition") + ModelInfo vnfDecompModelInfo = vnfResource.getModelInfo() + String vnfModelInfo = execution.getVariable("vnfModelInfo") + String modelUuid = execution.getVariable("DUVAM_modelUuid") + if (modelUuid == null || modelUuid.isEmpty()) { + modelUuid = vnfDecompModelInfo.getModelUuid() + } + String modelCustomizationUuid = execution.getVariable("DUVAM_modelCustomizationUuid") + if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { + modelCustomizationUuid = vnfDecompModelInfo.getModelCustomizationUuid() + } + String nfType = vnfResource.getNfType() + String nfTypeString = '' + if (nfType != null && !nfType.isEmpty()) { + nfTypeString = "" + nfType + "" + } + String nfRole = vnfResource.getNfRole() + String nfRoleString = '' + if (nfRole != null && !nfRole.isEmpty()) { + nfRoleString = "" + nfRole + "" + } + String nfFunction = vnfResource.getNfFunction() + String nfFunctionString = '' + if (nfFunction != null && !nfFunction.isEmpty()) { + nfFunctionString = "" + nfFunction + "" + } + String nfNamingCode = vnfResource.getNfNamingCode() + String nfNamingCodeString = '' + if (nfNamingCode != null && !nfNamingCode.isEmpty()) { + nfNamingCodeString = "" + nfNamingCode + "" + } + + String updateAAIGenericVnfRequest = """ + + ${vnfId} + ${modelUuid} + ${modelCustomizationUuid} + ${nfTypeString} + ${nfRoleString} + ${nfFunctionString} + ${nfNamingCodeString} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DUVAM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) + + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * APP-C Call - placeholder. + * + * @param execution The flow's execution instance. + */ + public void callAppCf(Execution execution) { + def method = getClass().getSimpleName() + '.callAppC(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy new file mode 100644 index 0000000000..7dbd7a9c57 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -0,0 +1,694 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper +import groovy.util.Node +import groovy.util.XmlParser; +import groovy.xml.QName + +import java.io.Serializable; +import java.util.UUID; +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.openecomp.mso.bpmn.common.scripts.VidUtils; +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.client.aai.* + +import org.openecomp.mso.client.appc.ApplicationControllerClient; +import org.openecomp.mso.client.appc.ApplicationControllerSupport; +import org.openecomp.appc.client.lcm.model.Action; +import org.openecomp.appc.client.lcm.model.ActionIdentifiers; +import org.openecomp.appc.client.lcm.model.LockInput +import org.openecomp.appc.client.lcm.model.UnlockInput +import org.openecomp.appc.client.lcm.model.HealthCheckInput +import org.openecomp.appc.client.lcm.model.StartInput +import org.openecomp.appc.client.lcm.model.StopInput +import org.openecomp.appc.client.lcm.model.Flags +import org.openecomp.appc.client.lcm.model.Status + + + +public class ReplaceVnfInfra extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + ApplicationControllerClient appcClient = new ApplicationControllerClient() + def prefix = "RPLVnfI_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'RPLVnfI_') + execution.setVariable('RPLVnfI_Request', null) + execution.setVariable('RPLVnfI_requestInfo', null) + execution.setVariable('RPLVnfI_requestId', null) + execution.setVariable('RPLVnfI_source', null) + execution.setVariable('RPLVnfI_vnfInputs', null) + execution.setVariable('RPLVnfI_vnfId', null) + execution.setVariable('RPLVnfI_tenantId', null) + execution.setVariable('RPLVnfI_vnfParams', null) + execution.setVariable('RPLVnfI_cloudConfiguration', null) + execution.setVariable('ReplaceVnfSuccessIndicator', false) + execution.setVariable('RPLVnfI_serviceType', null) + execution.setVariable('RPLVnfI_nfRole', null) + execution.setVariable('RPLVnfI_currentActivity', 'RPLVnfI') + execution.setVariable('RPLVnfI_workStep', null) + execution.setVariable('RPLVnfI_failedActivity', null) + execution.setVariable('RPLVnfI_errorCode', "0") + execution.setVariable('RPLVnfI_errorText', null) + execution.setVariable('RPLVnfI_healthCheckIndex', 1) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + initProcessVariables(execution) + + def incomingRequest = execution.getVariable('bpmnRequest') + + utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId) + execution.setVariable(prefix + 'vnfId', vnfId) + execution.setVariable("isVidRequest", "true") + + def asdcServiceModelVersion = '' + def serviceModelInfo = null + + def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + utils.log("DEBUG", "PROCESSING SERVICE INFO", isDebugLogEnabled) + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + utils.log("DEBUG", "ServiceModelInfo: " + serviceModelInfo, isDebugLogEnabled) + def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid") + utils.log("DEBUG", "modelInvariant: " + modelInvariant, isDebugLogEnabled) + } + + } + } + + execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion) + execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo) + def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo) + def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid") + execution.setVariable(prefix + 'vnfModelInvariantUuid', vnfModelInvariantUuid) + logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled) + + def vnfType = execution.getVariable('vnfType') + execution.setVariable(prefix + 'vnfType', vnfType) + + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value) + } + } + + utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled) + + execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable(prefix + 'requestId', requestId) + + + def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null + execution.setVariable(prefix + 'vnfName', vnfName) + + def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null + execution.setVariable(prefix + 'requestorId', requestorId) + + def usePreload = reqMap.requestDetails?.requestParameters?.usePreload + execution.setVariable(prefix + 'usePreload', usePreload) + + def cloudConfiguration = jsonOutput.toJson(reqMap.requestDetails?.cloudConfiguration) + execution.setVariable(prefix + 'cloudConfiguration', cloudConfiguration) + def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId") + execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId") + execution.setVariable(prefix + 'tenantId', tenantId) + + def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' + execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId) + + execution.setVariable(prefix + 'sdncVersion', '1702') + + execution.setVariable("ReplaceVnfInfraSuccessIndicator", false) + + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable(prefix + "source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + REPLACE + ${source} + """ + + execution.setVariable(prefix + "requestInfo", requestInfo) + + logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + + } + catch(groovy.json.JsonException je) { + utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(Execution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + + try { + def requestInfo = execution.getVariable('RPLVnfI_requestInfo') + def requestId = execution.getVariable('RPLVnfI_requestId') + def source = execution.getVariable('RPLVnfI_source') + def progress = getNodeTextForce(requestInfo, 'progress') + if (progress.isEmpty()) { + progress = '0' + } + def startTime = getNodeTextForce(requestInfo, 'start-time') + if (startTime.isEmpty()) { + startTime = System.currentTimeMillis() + } + + // RESTResponse (for API Handler (APIH) Reply Task) + def vnfId = execution.getVariable("vnfId") + String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() + + sendWorkflowResponse(execution, 200, synchResponse) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + + /** + * Get VnfResource decomposition object for this VNF. + * + * + * @param execution The flow's execution instance. + */ + public void getVnfResourceDecomposition(Execution execution) { + def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String vnfModelInvariantUuid = execution.getVariable(prefix + 'vnfModelInvariantUuid') + logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled) + List vnfResources = serviceDecomposition.getServiceVnfs() + + for (i in 0..vnfResources.size()-1) { + ModelInfo modelInfo = vnfResources[i].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled) + + if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + VnfResource vnfResourceDecomposition = vnfResources[i] + execution.setVariable(prefix + 'vnfResourceDecomposition', vnfResourceDecomposition) + def nfRole = vnfResourceDecomposition.getNfRole() + execution.setVariable(prefix + 'nfRole', nfRole) + logDebug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString(), isDebugLogEnabled) + break + } + else { + //exception! + } + + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage()) + } + } + + /** + * Check if this VNF is already in maintenance in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfVnfInMaintInAAI(Execution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + execution.setVariable(prefix + "workStep", "checkIfVnfInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + AAIRestClientImpl client = new AAIRestClientImpl() + AAIValidatorImpl aaiValidator = new AAIValidatorImpl() + aaiValidator.setClient(client) + def vnfId = execution.getVariable("vnfId") + boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled) + execution.setVariable(prefix + 'isVnfInMaintenance', isInMaint) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) + } + } + + + /** + * Check if this VNF's pservers are locked in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfPserversInMaintInAAI(Execution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable(prefix + "workStep", "checkIfPserversInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + AAIRestClientImpl client = new AAIRestClientImpl() + AAIValidatorImpl aaiValidator = new AAIValidatorImpl() + aaiValidator.setClient(client) + def vnfId = execution.getVariable("vnfId") + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + logDebug("areLocked result: " + areLocked, isDebugLogEnabled) + execution.setVariable(prefix + 'arePserversLocked', areLocked) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage()) + } + } + + /** + * Set inMaint flag for this VNF to the specified value in A&AI. + * + * + * @param execution The flow's execution instance. + * @param inMaint The boolean value of the flag to set + */ + public void setVnfInMaintFlagInAAI(Execution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + if (inMaint) { + execution.setVariable(prefix + "workStep", "setVnfInMaintFlagInAAI") + } + else { + execution.setVariable(prefix + "workStep", "unsetVnfInMaintFlagInAAI") + } + execution.setVariable("failedActivity", "AAI") + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + AAIRestClientImpl client = new AAIRestClientImpl() + AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl() + aaiUpdator.setClient(client) + def vnfId = execution.getVariable("vnfId") + if (inMaint) { + aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) + } + } + + /** + * Call APP-C client to execute specified APP-C command for this VNF. + * + * + * @param execution The flow's execution instance. + * @param action The action to take in APP-C. + */ + public void runAppcCommand(Execution execution, Action action) { + def method = getClass().getSimpleName() + '.runAppcCommand(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled) + String vnfId = execution.getVariable('vnfId') + String msoRequestId = execution.getVariable(prefix + 'requestId') + execution.setVariable('msoRequestId', msoRequestId) + execution.setVariable(prefix + "failedActivity", "APP-C") + + ApplicationControllerSupport support = new ApplicationControllerSupport() + appcClient.appCSupport=support + org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.openecomp.appc.client.lcm.model"); + Flags flags = new Flags(); + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + Status appcStatus + switch(action) { + case Action.Lock: + execution.setVariable(prefix + 'workStep', "LockVNF") + appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,flags,null,msoRequestId) + break + case Action.Unlock: + execution.setVariable(prefix + 'workStep', "UnlockVNF") + appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,flags,null,msoRequestId) + break + case Action.HealthCheck: + def healthCheckIndex = execution.getVariable(prefix + 'healthCheckIndex') + execution.setVariable(prefix + 'workStep', "HealthCheckVNF" + healthCheckIndex) + execution.setVariable(prefix + 'healthCheckIndex', healthCheckIndex + 1) + appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,flags,null,msoRequestId) + break + case Action.Start: + execution.setVariable(prefix + 'workStep', "StartVNF") + appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,flags,null,msoRequestId) + break + case Action.Stop: + execution.setVariable(prefix + 'workStep', "StopVNF") + appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,flags,null,msoRequestId) + break + default: + break + } + logDebug("Completed AppC request", isDebugLogEnabled) + int appcCode = appcStatus.getCode() + logDebug("AppC status code is: " + appcCode, isDebugLogEnabled) + logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled) + if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { + execution.setVariable(prefix + "errorCode", Integer.toString(appcCode)) + execution.setVariable(prefix + "errorText", appcStatus.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //throw e; + } catch (java.lang.NoSuchMethodError e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in ' + method + ': ' + e.getMessage()) + } + } + + + + + /** + * Builds a "CompletionHandler" request and stores it in the specified execution variable. + * + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + */ + public void completionHandlerPrep(Execution execution, String resultVar) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def requestInfo = getVariable(execution, 'RPLVnfI_requestInfo') + + appcClient.shutdownclient() + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Prepare DoDeleteVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoDeleteVnfAndModules(Execution execution) { + def method = getClass().getSimpleName() + '.prepDoDeleteVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable(prefix + "workStep", "doDeleteVnfAndModules") + execution.setVariable("failedActivity", "MSO Delete VNF") + logDebug('Exited ' + method, isDebugLogEnabled) + + } + + /** + * Prepare DoCreateVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoCreateVnfAndModules(Execution execution) { + def method = getClass().getSimpleName() + '.prepDoReplaceVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable(prefix + "workStep", "doReplaceVnfAndModules") + execution.setVariable("failedActivity", "MSO Replace VNF") + logDebug('Exited ' + method, isDebugLogEnabled) + + } + + /** + * Builds a "FalloutHandler" request and stores it in the specified execution variable. + * + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + */ + public void falloutHandlerPrep(Execution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def prefix = execution.getVariable('prefix') + def request = getVariable(execution, prefix+'Request') + def requestInformation = execution.getVariable(prefix + "requestInfo") + + appcClient.shutdownclient() + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") + } + + String content = """ + + ${requestInformation} + + ${encErrorResponseMsg} + ${errorResponseCode} + + + """ + content = utils.formatXml(content) + logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(Execution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def errorText = execution.getVariable(prefix + "errorText") + def errorCode = execution.getVariable(prefix + "errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + /** + * Handle Manual disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void manualProcessing(Execution execution) { + def method = getClass().getSimpleName() + '.manualProcessing(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def taskId = execution.getVariable("RPLVnfI_taskId") + + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Processing halted - manual task created: " + taskId) + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy index 68b0e58b57..c1a32c7bf9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy @@ -102,7 +102,6 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) } - // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { execution.setVariable("mso-request-id", requestId) @@ -184,15 +183,12 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { try { - // "networkModelInfo" is expected to be sent - String networkModelInfo = execution.getVariable("networkModelInfo") - utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) - - // "serviceModelInfo" is expected to be sent - String serviceModelInfo = execution.getVariable("serviceModelInfo") - utils.log("DEBUG", " serviceModelInfo - " + serviceModelInfo, isDebugEnabled) - - + // For Ala-Carte (sdnc = 1610): + // 1. the Network ModelInfo is expected to be sent + // via requestDetails.modelInfo (modelType = network), ex: modelCustomizationId + // 2. the Service ModelInfo is expected to be sent but will be IGNORE + // via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service) + } catch (Exception ex) { sendSyncError(execution) String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() @@ -233,6 +229,9 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { try { utils.log("DEBUG", " ***** Inside prepareDBRequestError() of UpdateNetworkInstance ***** ", isDebugEnabled) + // set DB Header Authorization + setBasicDBAuthHeader(execution, isDebugEnabled) + String statusMessage = "" WorkflowException wfe = null if (execution.getVariable("WorkflowException") instanceof WorkflowException) { @@ -378,12 +377,16 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) + utils.log("DEBUG", "DB updateInfraRequest ResponseCode: " + execution.getVariable(Prefix + "dbReturnCode"), isDebugEnabled) + utils.log("DEBUG", "DB updateInfraRequest Response: " + execution.getVariable(Prefix + "createDBResponse"), isDebugEnabled) + utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) - + String falloutHandlerRequest = "" String requestId = execution.getVariable("mso-request-id") try { + WorkflowException wfe = execution.getVariable("WorkflowException") String errorCode = String.valueOf(wfe.getErrorCode()) String errorMessage = wfe.getErrorMessage() @@ -407,8 +410,8 @@ public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) } catch (Exception ex) { - String errorException = " Bpmn error encountered in UpdateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - utils.log("DEBUG", errorException, isDebugEnabled) + String errorException = " Bpmn error encountered in UpdateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + utils.log("DEBUG", "Exception error in UpdateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage(), isDebugEnabled) falloutHandlerRequest = """ userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value) + } + } + + utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled) + + execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap) + + def isBaseVfModule = "false" + if (execution.getVariable('isBaseVfModule') == true) { + isBaseVfModule = "true" + } + + execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable(prefix + 'requestId', requestId) + + def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo) + + def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback + + + def backoutOnFailure = "" + if(suppressRollback != null){ + if ( suppressRollback == true) { + backoutOnFailure = "false" + } else if ( suppressRollback == false) { + backoutOnFailure = "true" + } + } + + execution.setVariable('disableRollback', suppressRollback) + + def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null + execution.setVariable(prefix + 'vfModuleName', vfModuleName) + + def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: '' + execution.setVariable(prefix + 'serviceId', serviceId) + + def usePreload = reqMap.requestDetails?.requestParameters?.usePreload + execution.setVariable(prefix + 'usePreload', usePreload) + + def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration + def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + def tenantId = cloudConfiguration.tenantId + execution.setVariable(prefix + 'tenantId', tenantId) + + def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' + execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId) + + execution.setVariable(prefix + 'sdncVersion', '1702') + + execution.setVariable("UpdateVfModuleInfraSuccessIndicator", false) + + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable(prefix + "source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + UPDATE + ${source} + """ + + execution.setVariable(prefix + "requestInfo", requestInfo) + + //backoutOnFailure + + logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) } catch(groovy.json.JsonException je) { @@ -114,35 +223,7 @@ public class UpdateVfModuleInfra extends AbstractServiceTaskProcessor { String restFaultMessage = e.getMessage() utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) - } - - - try { - - String request = validateInfraRequest(execution) - - def requestInfo = getRequiredNodeXml(execution, request, 'request-info') - execution.setVariable('UPDVfModI_requestInfo', requestInfo) - execution.setVariable('UPDVfModI_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) - execution.setVariable('UPDVfModI_source', getNodeTextForce(requestInfo, 'source')) - - def vnfInputs = getRequiredNodeXml(execution, request, 'vnf-inputs') - execution.setVariable('UPDVfModI_vnfInputs', vnfInputs) - execution.setVariable('UPDVfModI_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) - execution.setVariable('UPDVfModI_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) - execution.setVariable('UPDVfModI_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) - execution.setVariable('UPDVfModI_volumeGroupId', getNodeTextForce(vnfInputs, 'volume-group-id')) - - def vnfParams = utils.getNodeXml(request, 'vnf-params') - execution.setVariable('UPDVfModI_vnfParams', vnfParams) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) - } + } } /** @@ -322,7 +403,7 @@ public class UpdateVfModuleInfra extends AbstractServiceTaskProcessor { try { def prefix = execution.getVariable('prefix') def request = getVariable(execution, prefix+'Request') - def requestInformation = utils.getNodeXml(request, 'request-info', false) + def requestInformation = execution.getVariable(prefix + "requestInfo") def WorkflowException workflowException = execution.getVariable("WorkflowException") def errorResponseCode = workflowException.getErrorCode() diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy new file mode 100644 index 0000000000..eefe33d725 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy @@ -0,0 +1,473 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts + + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper +import groovy.util.Node +import groovy.util.XmlParser; +import groovy.xml.QName +import inventory.aai.att.com.v10.GenericVnf +import inventory.aai.att.com.v10.GenericVnfs +import inventory.aai.att.com.v10.Pserver + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd +import org.camunda.bpm.engine.runtime.Execution + +import java.io.Serializable; +import java.util.List + +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.springframework.beans.factory.annotation.Autowired + +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.client.aai.AAIValidatorImpl +import org.openecomp.mso.client.aai.AAIUpdatorImpl +import org.openecomp.mso.client.appc.ApplicationControllerClient +import org.openecomp.mso.client.sdno.SDNOValidatorImpl + + + +public class UpdateVfModuleInfraV2 { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + boolean preProcessRequestCheck = true; + boolean sendSynchResponseCheck = true; + boolean checkPserverFlagCheck = true; + boolean vfFlagCheckSetCheck = true; + boolean lockAppCCheck = true; + boolean healthDiagnosticSDNOCheck = true; + boolean healthCheckAppCCheck = true; + boolean stopVfModuleControllerCheck = true; + boolean healthCheckControllerCheck = true; + boolean doUpdateVfModulePrepCheck = true; + boolean completionHandlerPrepCheck = true; + boolean startVfModuleControllerCheck = true; + boolean vFFlagUnsetCheck = true; + boolean unlockAppCCheck = true; + boolean postUpgradeHealthCheckControllerCheck = true; + + + + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'UPDVfModI_') + execution.setVariable('UPDVfModI_Request', null) + execution.setVariable('UPDVfModI_requestInfo', null) + execution.setVariable('UPDVfModI_requestId', null) + execution.setVariable('UPDVfModI_source', null) + execution.setVariable('UPDVfModI_vnfInputs', null) + execution.setVariable('UPDVfModI_vnfId', null) + execution.setVariable('UPDVFModI_moduleUuid', null) + execution.setVariable('UPDVfModI_vfModuleId', null) + execution.setVariable('UPDVfModI_tenantId', null) + execution.setVariable('UPDVfModI_volumeGroupId', null) + execution.setVariable('UPDVfModI_vnfParams', null) + execution.setVariable('UPDVfModI_updateInfraRequest', null) + execution.setVariable('UpdateVfModuleSuccessIndicator', false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + System.out.print("*****************************PreProcessRequest**************************") + + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + //logDebug('Entered ' + method, isDebugLogEnabled) + + initProcessVariables(execution) + + def prefix = "UPDVfModI_" + + def incomingRequest = execution.getVariable('bpmnRequest') + + //utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + //utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + def moduleUuid = execution.getVariable('moduleUuid') + execution.setVariable(prefix + 'moduleUuid',moduleUuid) + execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId) + execution.setVariable(prefix+'vnfId', vnfId) + execution.setVariable("isVidRequest", "true") + + def vnfName = '' + def asdcServiceModelVersion = '' + def serviceModelInfo = null + def vnfModelInfo = null + + def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + } + if (it.relatedInstance.modelInfo.modelType == 'vnf') { + vnfName = it.relatedInstance.instanceName ?: '' + vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + } + } + } + + execution.setVariable(prefix + 'vnfName', vnfName) + execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion) + execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo) + execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo) + + def vnfType = execution.getVariable('vnfType') + execution.setVariable(prefix + 'vnfType', vnfType) + def vfModuleId = execution.getVariable('vfModuleId') + execution.setVariable(prefix + 'vfModuleId', vfModuleId) + def volumeGroupId = execution.getVariable('volumeGroupId') + execution.setVariable(prefix + 'volumeGroupId', volumeGroupId) + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value) + } + } + + //utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled) + + execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap) + + def isBaseVfModule = "false" + if (execution.getVariable('isBaseVfModule') == true) { + isBaseVfModule = "true" + } + + execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable(prefix + 'requestId', requestId) + + def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo) + + def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback + + + def backoutOnFailure = "" + if(suppressRollback != null){ + if ( suppressRollback == true) { + backoutOnFailure = "false" + } else if ( suppressRollback == false) { + backoutOnFailure = "true" + } + } + + execution.setVariable('disableRollback', suppressRollback) + + def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null + execution.setVariable(prefix + 'vfModuleName', vfModuleName) + + def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: '' + execution.setVariable(prefix + 'serviceId', serviceId) + + def usePreload = reqMap.requestDetails?.requestParameters?.usePreload + execution.setVariable(prefix + 'usePreload', usePreload) + + def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration + def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + def tenantId = cloudConfiguration.tenantId + execution.setVariable(prefix + 'tenantId', tenantId) + + def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' + execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId) + + execution.setVariable(prefix + 'sdncVersion', '1702') + + execution.setVariable("UpdateVfModuleInfraSuccessIndicator", false) + + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable(prefix + "source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + UPDATE + ${source} + """ + + execution.setVariable(prefix + "requestInfo", requestInfo) + + //backoutOnFailure + + //logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled) + + //logDebug('Exited ' + method, isDebugLogEnabled) + + } + catch(groovy.json.JsonException je) { + //utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + //utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the synchronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(Execution execution) { + System.out.print("*****************************SendSynchResponse**************************") + + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + //logDebug('Entered ' + method, isDebugLogEnabled) + + + try { + def requestInfo = execution.getVariable('UPDVfModI_requestInfo') + def requestId = execution.getVariable('UPDVfModI_requestId') + def source = execution.getVariable('UPDVfModI_source') + + def progress = getNodeTextForce(requestInfo, 'progress') + if (progress.isEmpty()) { + progress = '0' + } + def startTime = getNodeTextForce(requestInfo, 'start-time') + if (startTime.isEmpty()) { + startTime = System.currentTimeMillis() + } + // RESTResponse (for API Handler (APIH) Reply Task) + def vfModuleId = execution.getVariable("vfModuleId") + String synchResponse = """{"requestReferences":{"instanceId":"${vfModuleId}","requestId":"${requestId}"}}""".trim() + sendWorkflowResponse(execution, 200, synchResponse) + //logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + //logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + //check to see if the Pserver Flag is locked + public void checkPserverFlag(Execution execution) { + + System.out.println("*****************************CheckingPserverFlag*************************") + String vnfId = (String)execution.getVariable('vnfId') + String uuid = (String)execution.getVariable('moduleUuid') + AAIValidatorImpl aaiVI = new AAIValidatorImpl() + boolean flag = aaiVI.isPhysicalServerLocked(vnfId, uuid) + } + + //check to see if the VFFlag is locked + public void vfFlagCheck(Execution execution) { + + System.out.print("*****************************VfFlagCheck*************************") + String vnfId = (String)execution.getVariable('vnfId') + String uuid = (String)execution.getVariable('moduleUuid') + AAIValidatorImpl aaiVI = new AAIValidatorImpl() + boolean flag = aaiVI.isVNFLocked(vnfId, uuid) + + } + //lock the VF Flag + public void vfFlagSet(Execution execution) { + + System.out.print("*****************************VfFlagSet*************************") + String vnfId = (String)execution.getVariable('vnfId') + String uuid = (String)execution.getVariable('moduleUuid') + AAIValidatorImpl aaiVI = new AAIValidatorImpl() + aaiVI.updateVnfToLocked(vnfId,uuid); + + } + + //Lock AppC + public void lockAppC(Execution execution) { + + System.out.print("*****************************lockAppC*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("Lock",vfModuleId) + + + } + //run health check + public void healthCheckAppC(Execution execution) { + + System.out.print("*****************************healthCheckAppC*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("HealthCheck",vfModuleId) + + } + //SDNO health diagnostic + public void healthDiagnosticSDNO(Execution execution) { + + System.out.print("*****************************healthDiagnosticSDNO is currently ignored*************************") + //SDNOValidatorImpl.healthDiagnostic("",""); + + } + //stop VF module controller + public void stopVfModuleController(Execution execution) { + + System.out.print("*****************************stopVfModuleController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("Stop",vfModuleId) + + + } + + public void doUpdateVfModulePrep(Execution execution) { + + System.out.print("*****************************doUpdateVfModulePrep*************************") + def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + //logDebug('Entered ' + method, isDebugLogEnabled) + + try { + + //logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + //logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) + + } + + } + + public void completionHandlerPrep(Execution execution,String resultVar) { + + System.out.print("*****************************completionHandlerPrep*************************") + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + //logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def requestInfo = getVariable(execution, 'UPDVfModI_requestInfo') + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + //logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + + //logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + //logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + + } + + } + + public void healthCheckController(Execution execution) { + + System.out.print("*****************************healthCheckController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("HealthCheck",vfModuleId) + + } + + public void startVfModuleController(Execution execution) { + + System.out.print("*****************************startVfModuleController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("Start",vfModuleId) + + } + + public void vFFlagUnset(Execution execution) { + + System.out.print("*****************************vFFlagUnset*************************") + String vnfId = (String)execution.getVariable('vnfId') + String uuid = (String)execution.getVariable('moduleUuid') + AAIValidatorImpl aaiVI = new AAIValidatorImpl() + aaiVI.updateVnfToUnLocked(vnfId,uuid); + + + } + + public void unlockAppC(Execution execution) { + + System.out.print("*****************************unlockAppC*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("Unlock",vfModuleId) + + } + + public void postUpgradeHealthCheckController(Execution execution) { + + System.out.print("*****************************postUpgradeHealthCheckController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(); + def status = aCC.runCommand("HealthCheck",vfModuleId) + + } + +} + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index ffe122aed6..e1d567a37d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -95,9 +95,10 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI - def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantId ?: '' + def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: '' execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId) + utils.log("DEBUG", "modelInvariantId from request: " + modelInvariantId, isDebugLogEnabled) utils.log("DEBUG", "XML request:\n" + request, isDebugLogEnabled) } catch(groovy.json.JsonException je) { @@ -123,18 +124,8 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id')) - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + setBasicDBAuthHeader(execution, isDebugLogEnabled) + def volumeParams = utils.getNodeXml(request, 'volume-params') execution.setVariable('UPDVfModVol_volumeParams', volumeParams) } @@ -303,7 +294,13 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { utils.logAudit('Query AAI VF Module: ' + queryAAIVfModuleRequest) logDebug('Query AAI VF Module: ' + queryAAIVfModuleRequest, isDebugLogEnabled) - APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVfModuleRequest) + def aaiUrl = execution.getVariable("URN_aai_endpoint") + logDebug('A&AI URL: ' + aaiUrl, isDebugLogEnabled) + + def requestEndpoint = aaiUrl + queryAAIVfModuleRequest + logDebug('A&AI request endpoint: ' + requestEndpoint, isDebugLogEnabled) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint) String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() @@ -318,7 +315,12 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { ExceptionUtil exceptionUtil = new ExceptionUtil() if ((returnCode == '200') || (returnCode == '204')) { - def personaModelId = utils.getNodeText1(aaiResponseAsString, 'persona-model-id') + def personaModelId = utils.getNodeText1(aaiResponseAsString, 'model-invariant-id') + if(personaModelId == null) { + //check old attribute name + personaModelId = utils.getNodeText1(aaiResponseAsString, 'persona-model-id') + } + logDebug("vfModule personaModelId: " + personaModelId, isDebugLogEnabled) execution.setVariable('UPDVfModVol_personaModelId', personaModelId) } else if (returnCode == '404') { @@ -353,7 +355,11 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse') def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id') def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name') - def modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-persona-model-customization-id') + def modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-model-customization-id') + if(modelCustomizationId == null) { + // 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') @@ -430,6 +436,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { public void prepDbInfraDbRequest(Execution execution, isDebugLogEnabled) { def requestId = execution.getVariable('UPDVfModVol_requestId') + ExceptionUtil exceptionUtil = new ExceptionUtil(); String updateInfraRequest = """ ${requestId} - CREATE + UPDATE ${source} BPMN VF Module Volume action: UPDATE @@ -480,8 +487,15 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { * @param execution The flow's execution instance. */ public void prepFalloutHandler(Execution execution, isDebugLogEnabled) { + def requestId = execution.getVariable('UPDVfModVol_requestId') + def source = execution.getVariable('UPDVfModVol_source') - def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') + String requestInfo = """ + + ${requestId} + UPDATE + ${source} + """ def WorkflowException workflowException = execution.getVariable("WorkflowException") def errorResponseCode = workflowException.getErrorCode() @@ -495,7 +509,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { + xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1"> ${requestInfo} ${encErrorResponseMsg} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy new file mode 100644 index 0000000000..47121a38d1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -0,0 +1,676 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure.scripts + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper +import groovy.util.Node +import groovy.util.XmlParser; +import groovy.xml.QName + +import java.beans.MetaData.java_lang_Class_PersistenceDelegate +import java.io.Serializable; +import java.util.UUID; +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.openecomp.mso.bpmn.common.scripts.VidUtils; +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.client.aai.* + +import org.openecomp.mso.client.appc.ApplicationControllerClient; +import org.openecomp.mso.client.appc.ApplicationControllerSupport; +import org.openecomp.appc.client.lcm.model.Action; +import org.openecomp.appc.client.lcm.model.ActionIdentifiers; +import org.openecomp.appc.client.lcm.model.LockInput +import org.openecomp.appc.client.lcm.model.UnlockInput +import org.openecomp.appc.client.lcm.model.HealthCheckInput +import org.openecomp.appc.client.lcm.model.StartInput +import org.openecomp.appc.client.lcm.model.StopInput +import org.openecomp.appc.client.lcm.model.Flags +import org.openecomp.appc.client.lcm.model.Status + + + +public class UpdateVnfInfra extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + ApplicationControllerClient appcClient = new ApplicationControllerClient() + def prefix = "UPDVnfI_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution execution) { + execution.setVariable('prefix', 'UPDVnfI_') + execution.setVariable('UPDVnfI_Request', null) + execution.setVariable('UPDVnfI_requestInfo', null) + execution.setVariable('UPDVnfI_requestId', null) + execution.setVariable('UPDVnfI_source', null) + execution.setVariable('UPDVnfI_vnfInputs', null) + execution.setVariable('UPDVnfI_vnfId', null) + execution.setVariable('UPDVnfI_tenantId', null) + execution.setVariable('UPDVnfI_vnfParams', null) + execution.setVariable('UpdateVnfSuccessIndicator', false) + execution.setVariable('UPDVnfI_serviceType', null) + execution.setVariable('UPDVnfI_nfRole', null) + execution.setVariable('UPDVnfI_currentActivity', 'UPDVnfI') + execution.setVariable('UPDVnfI_workStep', null) + execution.setVariable('UPDVnfI_failedActivity', null) + execution.setVariable('UPDVnfI_errorCode', "0") + execution.setVariable('UPDVnfI_errorText', null) + execution.setVariable('UPDVnfI_healthCheckIndex', 1) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + initProcessVariables(execution) + + def incomingRequest = execution.getVariable('bpmnRequest') + + utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId) + execution.setVariable(prefix + 'vnfId', vnfId) + execution.setVariable("isVidRequest", "true") + + def asdcServiceModelVersion = '' + def serviceModelInfo = null + + def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + utils.log("DEBUG", "PROCESSING SERVICE INFO", isDebugLogEnabled) + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + utils.log("DEBUG", "ServiceModelInfo: " + serviceModelInfo, isDebugLogEnabled) + def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid") + utils.log("DEBUG", "modelInvariant: " + modelInvariant, isDebugLogEnabled) + } + + } + } + + execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion) + execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo) + def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo) + def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid") + execution.setVariable(prefix + 'vnfModelInvariantUuid', vnfModelInvariantUuid) + logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled) + + def vnfType = execution.getVariable('vnfType') + execution.setVariable(prefix + 'vnfType', vnfType) + + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value) + } + } + + utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled) + + execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable(prefix + 'requestId', requestId) + execution.setVariable('msoRequestId', requestId) + + + def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null + execution.setVariable(prefix + 'vnfName', vnfName) + + def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null + execution.setVariable(prefix + 'requestorId', requestorId) + + def usePreload = reqMap.requestDetails?.requestParameters?.usePreload + execution.setVariable(prefix + 'usePreload', usePreload) + + def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration + def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + def tenantId = cloudConfiguration.tenantId + execution.setVariable(prefix + 'tenantId', tenantId) + + def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' + execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId) + + execution.setVariable(prefix + 'sdncVersion', '1702') + + execution.setVariable("UpdateVnfInfraSuccessIndicator", false) + + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable(prefix + "source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + UPDATE + ${source} + """ + + execution.setVariable(prefix + "requestInfo", requestInfo) + + logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + + } + catch(groovy.json.JsonException je) { + utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(Execution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + + try { + def requestInfo = execution.getVariable('UPDVnfI_requestInfo') + def requestId = execution.getVariable('UPDVnfI_requestId') + def source = execution.getVariable('UPDVnfI_source') + def progress = getNodeTextForce(requestInfo, 'progress') + if (progress.isEmpty()) { + progress = '0' + } + def startTime = getNodeTextForce(requestInfo, 'start-time') + if (startTime.isEmpty()) { + startTime = System.currentTimeMillis() + } + + // RESTResponse (for API Handler (APIH) Reply Task) + def vnfId = execution.getVariable("vnfId") + String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() + + sendWorkflowResponse(execution, 200, synchResponse) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + + /** + * Get VnfResource decomposition object for this VNF. + * + * + * @param execution The flow's execution instance. + */ + public void getVnfResourceDecomposition(Execution execution) { + def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String vnfModelInvariantUuid = execution.getVariable(prefix + 'vnfModelInvariantUuid') + logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled) + List vnfResources = serviceDecomposition.getServiceVnfs() + + for (i in 0..vnfResources.size()-1) { + ModelInfo modelInfo = vnfResources[i].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled) + + if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + VnfResource vnfResourceDecomposition = vnfResources[i] + execution.setVariable(prefix + 'vnfResourceDecomposition', vnfResourceDecomposition) + def nfRole = vnfResourceDecomposition.getNfRole() + execution.setVariable(prefix + 'nfRole', nfRole) + logDebug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString(), isDebugLogEnabled) + break + } + else { + //exception! + } + + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage()) + } + } + + /** + * Check if this VNF is already in maintenance in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfVnfInMaintInAAI(Execution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + execution.setVariable(prefix + "workStep", "checkIfVnfInMaintInAAI") + execution.setVariable(prefix + "failedActivity", "AAI") + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + AAIRestClientImpl client = new AAIRestClientImpl() + AAIValidatorImpl aaiValidator = new AAIValidatorImpl() + aaiValidator.setClient(client) + def vnfId = execution.getVariable("vnfId") + boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled) + execution.setVariable(prefix + 'isVnfInMaintenance', isInMaint) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) + } + } + + + /** + * Check if this VNF's pservers are locked in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfPserversInMaintInAAI(Execution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable(prefix + "workStep", "checkIfPserversInMaintInAAI") + execution.setVariable(prefix + "failedActivity", "AAI") + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + AAIRestClientImpl client = new AAIRestClientImpl() + AAIValidatorImpl aaiValidator = new AAIValidatorImpl() + aaiValidator.setClient(client) + def vnfId = execution.getVariable("vnfId") + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + logDebug("areLocked result: " + areLocked, isDebugLogEnabled) + execution.setVariable(prefix + 'arePserversLocked', areLocked) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage()) + } + } + + /** + * Set inMaint flag for this VNF to the specified value in A&AI. + * + * + * @param execution The flow's execution instance. + * @param inMaint The boolean value of the flag to set + */ + public void setVnfInMaintFlagInAAI(Execution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + if (inMaint) { + execution.setVariable(prefix + "workStep", "setVnfInMaintFlagInAAI") + } + else { + execution.setVariable(prefix + "workStep", "unsetVnfInMaintFlagInAAI") + } + execution.setVariable(prefix + "failedActivity", "AAI") + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + AAIRestClientImpl client = new AAIRestClientImpl() + AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl() + aaiUpdator.setClient(client) + def vnfId = execution.getVariable("vnfId") + if (inMaint) { + aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) + } + } + + /** + * Call APP-C client to execute specified APP-C command for this VNF. + * + * + * @param execution The flow's execution instance. + * @param action The action to take in APP-C. + */ + public void runAppcCommand(Execution execution, Action action) { + def method = getClass().getSimpleName() + '.runAppcCommand(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled) + String vnfId = execution.getVariable('vnfId') + String msoRequestId = execution.getVariable(prefix + 'requestId') + execution.setVariable('msoRequestId', msoRequestId) + execution.setVariable(prefix + "failedActivity", "APP-C") + + ApplicationControllerSupport support = new ApplicationControllerSupport() + appcClient.appCSupport=support + org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.openecomp.appc.client.lcm.model"); + Flags flags = new Flags(); + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + Status appcStatus + switch(action) { + case Action.Lock: + execution.setVariable(prefix + 'workStep', "LockVNF") + appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,flags,null,msoRequestId) + break + case Action.Unlock: + execution.setVariable(prefix + 'workStep', "UnlockVNF") + appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,flags,null,msoRequestId) + break + case Action.HealthCheck: + def healthCheckIndex = execution.getVariable(prefix + 'healthCheckIndex') + execution.setVariable(prefix + 'workStep', "HealthCheckVNF" + healthCheckIndex) + execution.setVariable(prefix + 'healthCheckIndex', healthCheckIndex + 1) + appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,flags,null,msoRequestId) + break + case Action.Start: + execution.setVariable(prefix + 'workStep', "StartVNF") + appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,flags,null,msoRequestId) + break + case Action.Stop: + execution.setVariable(prefix + 'workStep', "StopVNF") + appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,flags,null,msoRequestId) + break + default: + break + } + logDebug("Completed AppC request", isDebugLogEnabled) + int appcCode = appcStatus.getCode() + logDebug("AppC status code is: " + appcCode, isDebugLogEnabled) + logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled) + if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { + execution.setVariable(prefix + "errorCode", Integer.toString(appcCode)) + execution.setVariable(prefix + "errorText", appcStatus.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //throw e; + } catch (java.lang.NoSuchMethodError e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + //throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + execution.setVariable(prefix + "errorCode", "1002") + execution.setVariable(prefix + "errorText", e.getMessage()) + + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in ' + method + ': ' + e.getMessage()) + } + } + + + + + + /** + * Builds a "CompletionHandler" request and stores it in the specified execution variable. + * + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + */ + public void completionHandlerPrep(Execution execution, String resultVar) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + + try { + appcClient.shutdownclient() + def requestInfo = getVariable(execution, 'UPDVnfI_requestInfo') + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Prepare DoUpdateVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoUpdateVnfAndModules(Execution execution) { + def method = getClass().getSimpleName() + '.prepDoUpdateVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + execution.setVariable(prefix + 'errorCode', "0") + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable(prefix + "workStep", "doUpdateVnfAndModules") + execution.setVariable(prefix + "failedActivity", "MSO Update VNF") + logDebug('Exited ' + method, isDebugLogEnabled) + + } + + /** + * Builds a "FalloutHandler" request and stores it in the specified execution variable. + * + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + */ + public void falloutHandlerPrep(Execution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def prefix = execution.getVariable('prefix') + def request = getVariable(execution, prefix+'Request') + def requestInformation = execution.getVariable(prefix + "requestInfo") + + appcClient.shutdownclient() + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") + } + + String content = """ + + ${requestInformation} + + ${encErrorResponseMsg} + ${errorResponseCode} + + + """ + content = utils.formatXml(content) + logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) + execution.setVariable(resultVar, content) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(Execution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def errorText = execution.getVariable(prefix + "errorText") + def errorCode = execution.getVariable(prefix + "errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + /** + * Handle Manual disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void manualProcessing(Execution execution) { + def method = getClass().getSimpleName() + '.manualProcessing(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def taskId = execution.getVariable("UPDVnfI_taskId") + + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Processing halted - manual task created: " + taskId) + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/MSOInfrastructureApplication.java index 07ec8ff5dc..9fc494043d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -35,7 +35,7 @@ import org.openecomp.mso.logger.MsoLogger; * @since Version 1.0 * */ -@ProcessApplication("MSO Infrastructure Application") +@ProcessApplication(name="MSO Infrastructure Application", deploymentDescriptors={"../processes.xml"}) public class MSOInfrastructureApplication extends ServletProcessApplication { private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowAsyncInfrastructureResource.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowAsyncInfrastructureResource.java deleted file mode 100644 index 0cc81bf0c6..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowAsyncInfrastructureResource.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure.workflow.service; - -import javax.ws.rs.Path; - -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.ProcessEngines; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource; - - -/** - * - * @version 1.0 - * Asynchronous Workflow processing using JAX RS RESTeasy implementation - * Both Synchronous and Asynchronous BPMN process can benefit from this implementation since the workflow gets executed in the background - * and the server thread is freed up, server scales better to process more incoming requests - * - * Usage: For synchronous process, when you are ready to send the response invoke the callback to write the response - * For asynchronous process - the activity may send a acknowledgement response and then proceed further on executing the process - */ -@Path("/async") -public class WorkflowAsyncInfrastructureResource extends WorkflowAsyncResource { - - protected ProcessEngineServices getProcessEngineServices() { - return pes4junit.orElse(ProcessEngines.getProcessEngine("infrastructure")); - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java deleted file mode 100644 index 84a9bae051..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/service/WorkflowResourceApplication.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure.workflow.service; - -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; - -/** - * @version 1.0 - * RESTeasy workflow application which wires synchronous and asynchronous response - * - */ -@ApplicationPath("/") -public class WorkflowResourceApplication extends Application { - private Set singletons = new HashSet(); - private Set> classes = new HashSet>(); - - public WorkflowResourceApplication() { - singletons.add(new WorkflowResource()); - singletons.add(new WorkflowAsyncInfrastructureResource()); - singletons.add(new WorkflowMessageResource()); - } - - @Override - public Set> getClasses() { - return classes; - } - - @Override - public Set getSingletons() { - return singletons; - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn deleted file mode 100644 index a3a36529da..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn +++ /dev/null @@ -1,1243 +0,0 @@ - - - - - SequenceFlow_7 - SequenceFlow_3 - - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_7 - - - - - SequenceFlow_10o22u2 - - - - SequenceFlow_0afe2pg - SequenceFlow_29 - - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_8 - - - - SequenceFlow_8 - SequenceFlow_6 - - - - - SequenceFlow_6 - - - - - SequenceFlow_2 - - - - SequenceFlow_5 - - - - SequenceFlow_2 - SequenceFlow_5 - - - - - - SequenceFlow_12ilko1 - - - - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_1bwbn7r - SequenceFlow_12ag2bk - - - SequenceFlow_0cmebdc - SequenceFlow_0dfkfh1 - SequenceFlow_1bwbn7r - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0j6sjye - SequenceFlow_1ky2sv9 - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_1h77psn - SequenceFlow_0qi5uxg - - - SequenceFlow_0bvecvm - SequenceFlow_1h77psn - - - - SequenceFlow_0xowenu - - - - SequenceFlow_3 - - - - - SequenceFlow_0zq7i3q - SequenceFlow_0zpbskl - SequenceFlow_0dhf2js - - - SequenceFlow_0zq7i3q - - - - SequenceFlow_0zpbskl - SequenceFlow_1sx5llu - SequenceFlow_02o4yqx - - - SequenceFlow_0sdb3on - SequenceFlow_05lo85t - SequenceFlow_0xtr1g5 - - - SequenceFlow_05lo85t - SequenceFlow_09xerwk - SequenceFlow_19mxskt - SequenceFlow_0tmepzk - - - - - - - - - - - SequenceFlow_0807ukc - SequenceFlow_19yywk8 - - - SequenceFlow_19yywk8 - - - SequenceFlow_19mxskt - SequenceFlow_1brxd2r - SequenceFlow_08s0ew2 - - - SequenceFlow_0jg47xm - SequenceFlow_0807ukc - - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0xtr1g5 - SequenceFlow_09xerwk - - - - - - - - - - - SequenceFlow_0136s37 - SequenceFlow_1fqmrda - SequenceFlow_1dmsx0d - - - SequenceFlow_1ieiew4 - SequenceFlow_1os9x7w - SequenceFlow_0g7scsg - - - - - - - - - - SequenceFlow_1os9x7w - SequenceFlow_1f1hd3l - - - SequenceFlow_1sx5llu - SequenceFlow_0dhf2js - SequenceFlow_1rabks0 - SequenceFlow_0jg47xm - - - - - - - - - - - SequenceFlow_1dmsx0d - SequenceFlow_1otyild - - - - SequenceFlow_1otyild - SequenceFlow_0136s37 - SequenceFlow_12u8ufr - - - - - 0 }]]> - - - - SequenceFlow_0tmepzk - SequenceFlow_1fqmrda - SequenceFlow_1brxd2r - - - - - - - - - - SequenceFlow_12u8ufr - SequenceFlow_08s0ew2 - SequenceFlow_1ieiew4 - SequenceFlow_0sezboq - - - - - - - - - SequenceFlow_1f1hd3l - SequenceFlow_0g7scsg - SequenceFlow_0sezboq - SequenceFlow_0f4u373 - - - SequenceFlow_02o4yqx - SequenceFlow_0sdb3on - - - - SequenceFlow_0f4u373 - SequenceFlow_1rabks0 - - - - - - - - SequenceFlow_1vwssu7 - SequenceFlow_19etqmx - - - - SequenceFlow_0hvcwa1 - SequenceFlow_0j6sjye - - - - SequenceFlow_12ilko1 - SequenceFlow_0afe2pg - - - - - - - - - SequenceFlow_1vwssu7 - - - - SequenceFlow_13uceka - - - - SequenceFlow_19etqmx - SequenceFlow_0cmebdc - SequenceFlow_1f26zbk - - - SequenceFlow_04vlq8r - SequenceFlow_1n7r495 - SequenceFlow_0dfkfh1 - - - - - - 0}]]> - - - SequenceFlow_1n7r495 - SequenceFlow_1f26zbk - SequenceFlow_1j7n6qx - - - - SequenceFlow_1j7n6qx - - - - - - - SequenceFlow_10tbv62 - - - - SequenceFlow_10tbv62 - SequenceFlow_0bvecvm - SequenceFlow_0w7328u - - - SequenceFlow_0qi5uxg - SequenceFlow_0w7328u - SequenceFlow_0xowenu - - - - 0}]]> - - - in 1702 scope only one VNF will be created - - - - - SequenceFlow_12ag2bk - SequenceFlow_04vlq8r - - - - - - - - - - ${URN_mso_adapters_db_endpoint} - - - - application/soap+xml - - - POST - - soap-http-connector - - - SequenceFlow_0vj46ej - SequenceFlow_13uceka - - - - SequenceFlow_1ky2sv9 - SequenceFlow_0vj46ej - - - - - - - - - - - - - - - SequenceFlow_00h6hmd - SequenceFlow_0hvcwa1 - - - SequenceFlow_1eu60rt - SequenceFlow_00h6hmd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateNetworkInstance.bpmn index 52627a5e33..24a9a6d73c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateNetworkInstance.bpmn @@ -116,7 +116,7 @@ CreateNetworkInstance.prepareDBRequestError(execution)]]> - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} ${CRENI_createDBRequest} @@ -273,10 +273,10 @@ CreateNetworkInstance.sendSyncResponse(execution)]]> - + - + @@ -286,52 +286,52 @@ CreateNetworkInstance.sendSyncResponse(execution)]]> - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - - + + - + @@ -342,10 +342,10 @@ CreateNetworkInstance.sendSyncResponse(execution)]]> - - + + - + @@ -370,4 +370,4 @@ CreateNetworkInstance.sendSyncResponse(execution)]]> - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn index c58fec9dd9..72c275380f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -10,10 +10,10 @@ - + - + @@ -70,10 +70,11 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} application/soap+xml + #{BasicAuthHeaderValueDB} ${CVFMI_updateInfraRequest} @@ -123,30 +124,10 @@ createVfModule.postProcessResponse(execution)]]> - - SequenceFlow_17 - SequenceFlow_21 - - - - - - - - - - - SequenceFlow_19 - SequenceFlow_17 - - - SequenceFlow_13 + SequenceFlow_0wsgnab - @@ -163,36 +144,22 @@ createVfModule.validateRollbackResponse(execution)]]> - SequenceFlow_22 + SequenceFlow_018p5wf SequenceFlow_10 - - SequenceFlow_21 - isRollbackOnNoSequenceFlow - SequenceFlow_22 - - - - SequenceFlow_13 - isRollbackOnNoSequenceFlow - IsRollbackOnYesSequenceFlow - - - - IsRollbackOnYesSequenceFlow - SequenceFlow_19 + + + + SequenceFlow_0wsgnab + SequenceFlow_018p5wf +def createVfModule = new CreateVfModuleInfra() +createVfModule.sendErrorResponse(execution)]]> - - - - SequenceFlow_14 @@ -222,6 +189,24 @@ def createVfModule = new CreateVfModuleInfra() createVfModule.preProcessRequest(execution)]]> + + + SequenceFlow_1qvgrvq + SequenceFlow_1jqizzo + + + + SequenceFlow_1jqizzo + + + SequenceFlow_1qvgrvq + + + + + @@ -349,57 +334,57 @@ createVfModule.preProcessRequest(execution)]]> - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + @@ -413,80 +398,57 @@ createVfModule.preProcessRequest(execution)]]> - - - - - + + - - + + - - + + - + - - - - - + + - + - - - - - - + + + + - + - - - - + + + - + - - - - - + + + + + - + - - - - - - + + + - + - - + + - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn index 0fc889bfd6..ec4afa4ea4 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn @@ -1,61 +1,107 @@ - + SequenceFlow_1 - + - SequenceFlow_14 - + SequenceFlow_1tfi3sp + - - - SequenceFlow_14 - SequenceFlow_syncResponseSent - SequenceFlow_syncResponseNotSent + + SequenceFlow_1tfi3sp + SequenceFlow_0x34g02 + SequenceFlow_1q9kksk - - #{CVMVINFRAV1_syncResponseSent == true} - - SequenceFlow_syncResponseNotSent + SequenceFlow_0x34g02 SequenceFlow_22 - - + - SequenceFlow_22 - SequenceFlow_syncResponseSent + SequenceFlow_1v1jx7y SequenceFlow_18 - + - - - - - - - + + + + + + + SequenceFlow_18 SequenceFlow_19 - + SequenceFlow_19 - + + + SequenceFlow_1q9kksk + SequenceFlow_1cu5t8k + SequenceFlow_1tfh1vm + + + SequenceFlow_1tfh1vm + SequenceFlow_0b1nrfk + + + + + + + + + + + + + + SequenceFlow_0b1nrfk + SequenceFlow_08vm13o + + + SequenceFlow_08vm13o + SequenceFlow_097zy8w + + + + SequenceFlow_22 + SequenceFlow_1cu5t8k + SequenceFlow_097zy8w + SequenceFlow_1v1jx7y + + + + + + + + + + + + + + SequenceFlow_1 @@ -64,7 +110,7 @@ createVfModuleVolumeInfraV1.executeMethod('prepareFalloutHandlerRequest', execut def createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.executeMethod('preProcessRequest', execution, isDebugLogEnabled)]]> - + SequenceFlow_4 SequenceFlow_3 @@ -72,16 +118,16 @@ createVfModuleVolumeInfraV1.executeMethod('preProcessRequest', execution, isDebu def createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.executeMethod('sendSyncResponse', execution, isDebugLogEnabled)]]> - + SequenceFlow_3 SequenceFlow_volGrpNamePresent SequenceFlow_volGrpNameMissing - - + + - + SequenceFlow_volGrpNameMissing SequenceFlow_7 @@ -89,40 +135,38 @@ createVfModuleVolumeInfraV1.executeMethod('sendSyncResponse', execution, isDebug def createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.executeMethod('buildWorkflowException', execution, 2500, "Volume group name not present in request.", isDebugLogEnabled)]]> - + SequenceFlow_7 - + - + - - - - - + + + + + + + + + + + + + + + + + + + + + SequenceFlow_volGrpNamePresent - SequenceFlow_5 + SequenceFlow_0djjra2 - - - - - - - - - - - - - - - SequenceFlow_serviceInstanceFound - SequenceFlow_2 - - SequenceFlow_12 SequenceFlow_13 @@ -130,20 +174,20 @@ createVfModuleVolumeInfraV1.executeMethod('buildWorkflowException', execution, 2 def createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.executeMethod('setSuccessIndicator', execution, true)]]> - + - - - - - - + + + + + + SequenceFlow_11 SequenceFlow_12 - + SequenceFlow_8 SequenceFlow_11 @@ -151,330 +195,320 @@ createVfModuleVolumeInfraV1.executeMethod('setSuccessIndicator', execution, true def createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.executeMethod('postProcessResponse', execution, isDebugLogEnabled)]]> - + - http-connector - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} ${CVMVINFRAV1_createDBRequest} application/soap+xml + #{BasicAuthHeaderValueDB} POST ${response} ${statusCode} + http-connector SequenceFlow_6 SequenceFlow_8 - + SequenceFlow_13 - + - SequenceFlow_2 + SequenceFlow_0djjra2 SequenceFlow_6 - - - SequenceFlow_5 - SequenceFlow_serviceInstanceFound - SequenceFlow_serviceInstanceNotFound - - - - - - - - SequenceFlow_16 - - - - SequenceFlow_serviceInstanceNotFound - SequenceFlow_16 - - - + + - + - + - + - - + + - + - + - + - + - + - + - - + + - - - - - + + + - + - - + + - + - - + + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - + + - + - - + + - + - - + + - + - + - - + + - + - - - - + + - - - - - - - - - - + - + - + - - + + - + - - + + - + - + - + - - - - - + + + + + + + - + - - + + + + + + + + - - - - - + + + + + + + + - + + + + + + + + - - - - - + + + - + - - - - - + + + - + - - - - - - - - - - - + + + + + + - - + + + - + - - - - + + + + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn index b10e98b56f..e78bde6f29 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn @@ -20,7 +20,7 @@ createVnf.preProcessRequest(execution)]]> CreateVnfInfra createVnf = new CreateVnfInfra() createVnf.sendSyncResponse(execution)]]> - + @@ -38,15 +38,16 @@ createVnf.sendSyncResponse(execution)]]> + - SequenceFlow_3 + SequenceFlow_0ed0uiq SequenceFlow_0lso26t SequenceFlow_8 SequenceFlow_9 - @@ -61,7 +62,7 @@ exceptionUtil.processJavaException(execution)]]> - + @@ -110,7 +111,7 @@ createVnf.prepareCompletionHandlerRequest(execution)]]> SequenceFlow_17 - + @@ -122,6 +123,14 @@ createVnf.prepareCompletionHandlerRequest(execution)]]> + + + SequenceFlow_3 + SequenceFlow_0ed0uiq + + @@ -144,29 +153,29 @@ createVnf.prepareCompletionHandlerRequest(execution)]]> - + - + - + - + - - + + - + - + - + @@ -254,32 +263,42 @@ createVnf.prepareCompletionHandlerRequest(execution)]]> - + - - + + - + - + - - + + - + - - + + - + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn deleted file mode 100644 index bb2c487e8a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn +++ /dev/null @@ -1,773 +0,0 @@ - - - - - SequenceFlow_7 - SequenceFlow_3 - - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_7 - - - - - SequenceFlow_10o22u2 - - - - SequenceFlow_12ilko1 - SequenceFlow_29 - - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_8 - - - - SequenceFlow_8 - SequenceFlow_6 - - - - - SequenceFlow_6 - - - - - SequenceFlow_2 - - - - SequenceFlow_5 - - - - SequenceFlow_2 - SequenceFlow_5 - - - - - - SequenceFlow_12ilko1 - - - - - - - - - - - - - - - - - - - SequenceFlow_1bwbn7r - SequenceFlow_12ag2bk - - - SequenceFlow_0cmebdc - SequenceFlow_0dfkfh1 - SequenceFlow_1bwbn7r - - - - - - - - - - - - - - - SequenceFlow_10o22u2 - SequenceFlow_04ao07f - - - - - - - - - - - - - - - - SequenceFlow_1h77psn - SequenceFlow_1dmn40p - - - SequenceFlow_0bvecvm - SequenceFlow_0mr8jgt - SequenceFlow_1h77psn - - - - SequenceFlow_0xowenu - - - - SequenceFlow_3 - - - - - SequenceFlow_06llof4 - - - - - - - - - - - - SequenceFlow_0807ukc - SequenceFlow_19yywk8 - - - SequenceFlow_19yywk8 - - - SequenceFlow_06llof4 - SequenceFlow_0807ukc - - - - - - - - - - - - - SequenceFlow_1vwssu7 - - - - SequenceFlow_04ao07f - - - - SequenceFlow_1vwssu7 - SequenceFlow_0cmebdc - SequenceFlow_1f26zbk - - - SequenceFlow_04vlq8r - SequenceFlow_1n7r495 - SequenceFlow_0dfkfh1 - - - - - - 0}]]> - - - SequenceFlow_1n7r495 - SequenceFlow_1f26zbk - SequenceFlow_1j7n6qx - - - - SequenceFlow_1j7n6qx - - - - - - SequenceFlow_10tbv62 - - - - SequenceFlow_10tbv62 - SequenceFlow_0bvecvm - SequenceFlow_0w7328u - - - SequenceFlow_0w7328u - SequenceFlow_1wc8h5g - SequenceFlow_0xowenu - - - - 0}]]> - - - - - SequenceFlow_12ag2bk - SequenceFlow_04vlq8r - - - - - - - - - - - - - - - - SequenceFlow_0jek18q - SequenceFlow_1ttswdr - - - SequenceFlow_1ttswdr - SequenceFlow_18103ca - - - - SequenceFlow_0jek18q - - - - SequenceFlow_18103ca - - - - - - - - SequenceFlow_1dmn40p - SequenceFlow_0g2cw86 - - - - SequenceFlow_0g2cw86 - SequenceFlow_0mr8jgt - SequenceFlow_1wc8h5g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteNetworkInstance.bpmn index 951ae3c0b5..079599d7ca 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteNetworkInstance.bpmn @@ -116,7 +116,7 @@ DeleteNetworkInstance.prepareDBRequestError(execution)]]> - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} ${DELNI_deleteDBRequest} @@ -368,4 +368,4 @@ DeleteNetworkInstance.sendSyncResponse(execution)]]> - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleInfra.bpmn index 04369acba0..a687d5df87 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleInfra.bpmn @@ -79,11 +79,12 @@ dvfm.completionHandlerPrep(execution, 'DELVfModI_CompletionHandlerRequest') - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} POST application/soap+xml + #{BasicAuthHeaderValueDB} ${DELVfModI_updateInfraRequest} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn index d0051de976..21f74a2a29 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -10,11 +10,11 @@ deleteVfMod.executeMethod('preProcessRequest', execution, isDebugLogEnabled) ]]> - + SequenceFlow_1 - + SequenceFlow_7 SequenceFlow_12 @@ -22,7 +22,7 @@ deleteVfMod.executeMethod('preProcessRequest', execution, isDebugLogEnabled) def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('sendSyncResponse', execution, isDebugLogEnabled)]]> - + SequenceFlow_12 SequenceFlow_6 @@ -37,10 +37,10 @@ delVfModuleVol.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLo def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLogEnabled)]]> - + SequenceFlow_22 - + SequenceFlow_13 @@ -50,21 +50,21 @@ deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLo - + - - - - - - - + + + + + + + SequenceFlow_2 SequenceFlow_5 - + SequenceFlow_8 SequenceFlow_13 @@ -73,7 +73,7 @@ def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('queryAAIForVolumeGroup', execution, isDebugLogEnabled) ]]> - + SequenceFlow_21 SequenceFlow_22 @@ -81,27 +81,27 @@ deleteVfMod.executeMethod('queryAAIForVolumeGroup', execution, isDebugLogEnabled def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled)]]> - - + + SequenceFlow_6 SequenceFlow_4 SequenceFlow_8 - + SequenceFlow_4 - + SequenceFlow_23 - + - + SequenceFlow_23 SequenceFlow_responseNotSent @@ -114,7 +114,7 @@ deleteVfMod.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('sendSyncError', execution, isDebugLogEnabled)]]> - + #{DELVfModVol_syncResponseSent == true} @@ -127,27 +127,27 @@ def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('prepareFalloutHandler', execution, isDebugLogEnabled) ]]> - + - - - - - - - - + + + + + + + + SequenceFlow_25 SequenceFlow_19 - + SequenceFlow_19 - + - + SequenceFlow_35 @@ -158,7 +158,7 @@ deleteVfMod.executeMethod('prepareDBRequest', execution, isDebugLogEnabled) ]]> - + SequenceFlow_27 SequenceFlow_29 @@ -167,55 +167,56 @@ def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('prepareCompletionHandlerRequest', execution, isDebugLogEnabled) ]]> - + SequenceFlow_10 SequenceFlow_24 - + - - - - - - - - + + + + + + + + SequenceFlow_29 SequenceFlow_10 - + SequenceFlow_24 - + - http-connector - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} ${DELVfModVol_updateInfraRequest} application/soap+xml + #{BasicAuthHeaderValueDB} POST ${response} ${statusCode} + http-connector SequenceFlow_37 SequenceFlow_27 - + SequenceFlow_vnfAdapterCallOK SequenceFlow_35 @@ -223,7 +224,7 @@ execution.setVariable("DELVfModVol_TransactionSuccessIndicator", true)]]> - + SequenceFlow_5 SequenceFlow_vnfAdapterCallOK @@ -234,334 +235,334 @@ deleteVfMod.executeMethod('deleteVolGrpId', execution, isDebugLogEnabled)]]> SequenceFlow_vnfAdapterCallNotOK - + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - + + + + - + - - + + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + - + - - + + - + - - - - + + + + - + - + - + - - + + - + - + - + - - + + - + - + - - - - + + + + - + - - + + - + - + - + - + - - + + - + - - - - + + + + - + - + - + - - - - + + + + - + - + - - + + - + - + - + - + - + - + - - - - + + + + - + - - - - + + + + - + - - - - + + + + - + - + - + - - + + - + - + - + - - - - + + + + - + - + - - - - + + + + - + - - + + - + - - - - - - + + + + + + - + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/ReplaceVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/ReplaceVnfInfra.bpmn new file mode 100644 index 0000000000..6c5e8f6522 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/ReplaceVnfInfra.bpmn @@ -0,0 +1,1177 @@ + + + + + SequenceFlow_5 + SequenceFlow_0y0jt4l + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_3 + SequenceFlow_17 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_19ba94v + SequenceFlow_0gzzeru + + + + + + + + + + + + + SequenceFlow_0y0jt4l + SequenceFlow_1w35ov3 + + + + SequenceFlow_1w35ov3 + SequenceFlow_053qjfy + + + + + SequenceFlow_16mo99z + SequenceFlow_193t8ts + SequenceFlow_2 + + + + + + + SequenceFlow_0baosqi + SequenceFlow_18u8p2k + SequenceFlow_0k3fx7p + + + + SequenceFlow_19lg15d + SequenceFlow_1lsfn19 + SequenceFlow_12mfil6 + + + + SequenceFlow_053qjfy + SequenceFlow_0usxnlk + + + + + + + SequenceFlow_1bkhs8m + SequenceFlow_0eueu1t + SequenceFlow_0xx8y1s + + + + SequenceFlow_0qy68ib + SequenceFlow_1sla5dr + SequenceFlow_0a6pdza + + + + SequenceFlow_0q0qan8 + SequenceFlow_0iektwg + SequenceFlow_13h26h9 + + + + + + SequenceFlow_04zwhw4 + SequenceFlow_1uno5rs + + + + SequenceFlow_162mm0m + SequenceFlow_1hx1ur7 + SequenceFlow_1c79909 + + + + + SequenceFlow_197t3qk + SequenceFlow_0ukzynj + SequenceFlow_1xfbwpi + + + + SequenceFlow_0usxnlk + SequenceFlow_16mo99z + SequenceFlow_1qmz2ez + + + + SequenceFlow_2 + SequenceFlow_0baosqi + SequenceFlow_03rkfbo + + + + + + + + + + + + + + + + + + + SequenceFlow_1qmz2ez + SequenceFlow_03rkfbo + SequenceFlow_1lsm3bn + SequenceFlow_0bduwog + SequenceFlow_0uwar5b + SequenceFlow_0i7hfj2 + SequenceFlow_13yjc85 + SequenceFlow_0waedj5 + SequenceFlow_1hg9c2l + SequenceFlow_0gej71y + SequenceFlow_0pfydeg + SequenceFlow_10ek8l4 + SequenceFlow_0v0u7mf + + + + + + + + + + SequenceFlow_1qr8msw + + + + + + + + + SequenceFlow_0k3fx7p + SequenceFlow_1bkhs8m + SequenceFlow_1lsm3bn + + + + + + + SequenceFlow_0xx8y1s + SequenceFlow_0qy68ib + SequenceFlow_0bduwog + + + + SequenceFlow_0a6pdza + SequenceFlow_0q0qan8 + SequenceFlow_0uwar5b + + + + SequenceFlow_13h26h9 + SequenceFlow_1c0vdki + SequenceFlow_0i7hfj2 + + + + + + + + + + + + + SequenceFlow_0gzzeru + SequenceFlow_10ek8l4 + SequenceFlow_0bxgny0 + + + + + + + SequenceFlow_1uno5rs + SequenceFlow_162mm0m + SequenceFlow_0waedj5 + + + + SequenceFlow_1c79909 + SequenceFlow_197t3qk + SequenceFlow_1hg9c2l + + + + SequenceFlow_1xfbwpi + SequenceFlow_19lg15d + SequenceFlow_0gej71y + + + + SequenceFlow_12mfil6 + SequenceFlow_13yjc85 + SequenceFlow_3 + + + + + + + + + + + + + + + + SequenceFlow_0vpd06n + SequenceFlow_051zp79 + + + + SequenceFlow_0v0u7mf + SequenceFlow_0vpd06n + SequenceFlow_1qr8msw + SequenceFlow_05gpym3 + + + SequenceFlow_05gpym3 + SequenceFlow_1sla5dr + SequenceFlow_0iektwg + SequenceFlow_1ttepat + SequenceFlow_1hx1ur7 + SequenceFlow_0ukzynj + SequenceFlow_1lsfn19 + SequenceFlow_051zp79 + SequenceFlow_193t8ts + SequenceFlow_18u8p2k + SequenceFlow_0eueu1t + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1c0vdki + SequenceFlow_1ttepat + SequenceFlow_19ba94v + + + + SequenceFlow_0bxgny0 + SequenceFlow_1qm0ygo + + + + SequenceFlow_1qm0ygo + SequenceFlow_0he2w4b + + + SequenceFlow_0he2w4b + SequenceFlow_0pfydeg + SequenceFlow_04zwhw4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/TestHelloWorld.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/TestHelloWorld.bpmn new file mode 100644 index 0000000000..15399f4488 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/TestHelloWorld.bpmn @@ -0,0 +1,52 @@ + + + + + SequenceFlow_0bav304 + + + + SequenceFlow_02tq5ta + + + + SequenceFlow_0bav304 + SequenceFlow_02tq5ta + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstance.bpmn index a19e0c632b..7e54b805e1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstance.bpmn @@ -116,11 +116,12 @@ UpdateNetworkInstance.prepareDBRequestError(execution)]]> - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} ${UPDNI_createDBRequest} application/soap+xml + #{BasicAuthHeaderValueDB} POST diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfra.bpmn index 1d20bd099c..fd554e0729 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfra.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_5 @@ -8,7 +8,7 @@ def uvfm = new UpdateVfModuleInfra() uvfm.sendSynchResponse(execution)]]> - + SequenceFlow_4 SequenceFlow_5 @@ -17,7 +17,7 @@ def uvfm = new UpdateVfModuleInfra() uvfm.preProcessRequest(execution) ]]> - + SequenceFlow_2 SequenceFlow_9 @@ -25,32 +25,21 @@ uvfm.preProcessRequest(execution) def uvfm = new UpdateVfModuleInfra() uvfm.prepDoUpdateVfModule(execution)]]> - - - - - - - - - SequenceFlow_9 - SequenceFlow_3 - - + - - - - + + + + SequenceFlow_17 SequenceFlow_14 - + SequenceFlow_6 - + SequenceFlow_14 @@ -58,7 +47,7 @@ uvfm.prepDoUpdateVfModule(execution)]]> - + SequenceFlow_3 SequenceFlow_17 @@ -67,13 +56,13 @@ def uvfm = new UpdateVfModuleInfra() uvfm.completionHandlerPrep(execution, 'UPDVfModI_CompletionHandlerRequest') ]]> - + SequenceFlow_1 - + - + SequenceFlow_1 SequenceFlow_7 @@ -82,192 +71,225 @@ def uvfm = new UpdateVfModuleInfra() uvfm.falloutHandlerPrep(execution, 'UPDVfModI_FalloutHandlerRequest') ]]> - + - + - + SequenceFlow_7 SequenceFlow_19 SequenceFlow_19 - + - + SequenceFlow_12 - + SequenceFlow_12 - + - + SequenceFlow_4 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_9 + SequenceFlow_3 + + - + - + - + - + - + - - + + - + - + - - + + - + - + - - - - + + + + - + - + - - + + - + - + - + - + - - + + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - - + + - + - - - - - + + + + + + + + - - - - - - + + + + + + - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfraV2.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfraV2.bpmn new file mode 100644 index 0000000000..ebdd459288 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleInfraV2.bpmn @@ -0,0 +1,412 @@ + + + + + SequenceFlow_07r1tup + + + + SequenceFlow_09izs9b + SequenceFlow_0gyzpu9 + + + + SequenceFlow_07r1tup + SequenceFlow_04cyigk + + + + SequenceFlow_04cyigk + SequenceFlow_09izs9b + + + + SequenceFlow_0gyzpu9 + SequenceFlow_16xzdgi + + + + SequenceFlow_1oa0jsk + SequenceFlow_1ozbxok + + + + SequenceFlow_1ozbxok + SequenceFlow_17c5hhe + + + + SequenceFlow_17c5hhe + SequenceFlow_1pqikpt + + + + SequenceFlow_1pqikpt + SequenceFlow_0m6q3pf + + + + SequenceFlow_0vj0wfl + SequenceFlow_0cskhwy + + + + SequenceFlow_0cskhwy + SequenceFlow_067f4jv + + + + SequenceFlow_067f4jv + SequenceFlow_1trqy93 + + + + SequenceFlow_1trqy93 + SequenceFlow_0fc550l + + + + SequenceFlow_0fc550l + SequenceFlow_1uquo5r + + + + + + + + + + + + + SequenceFlow_0m6q3pf + SequenceFlow_1ykv4yr + + + + SequenceFlow_1x3xeba + SequenceFlow_01yr04k + + + + SequenceFlow_1rfmnuo + SequenceFlow_0vj0wfl + + + + + + + + SequenceFlow_1uquo5r + + + + + + SequenceFlow_16xzdgi + SequenceFlow_1oa0jsk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1ykv4yr + SequenceFlow_1x3xeba + + + + + + + + + + + SequenceFlow_01yr04k + SequenceFlow_1rfmnuo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn index 96c0681c48..15b5bc7fcf 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn @@ -1,44 +1,45 @@ - + SequenceFlow_1 - + - - - - - + + + + + SequenceFlow_13 SequenceFlow_14 - + - http-connector - ${URN_mso_adapters_db_endpoint} + ${URN_mso_openecomp_adapters_db_endpoint} ${UPDVfModVol_updateInfraRequest} aapplication/soap+xml + #{BasicAuthHeaderValueDB} POST ${response} ${statusCode} + http-connector SequenceFlow_11 SequenceFlow_12 - + SequenceFlow_22 SequenceFlow_21 @@ -46,7 +47,7 @@ def uvmv = new UpdateVfModuleVolumeInfraV1() uvmv.executeMethod('prepVnfAdapterRest', execution, isDebugLogEnabled)]]> - + SequenceFlow_12 SequenceFlow_13 @@ -54,20 +55,20 @@ uvmv.executeMethod('prepVnfAdapterRest', execution, isDebugLogEnabled)]]> - + - - - - - - + + + + + + SequenceFlow_21 SequenceFlow_19 - + SequenceFlow_19 SequenceFlow_11 @@ -75,14 +76,14 @@ uvmv.executeMethod('prepCompletionHandlerRequest', execution, UPDVfModVol_reques def uvmv = new UpdateVfModuleVolumeInfraV1() uvmv.executeMethod('prepDbInfraDbRequest', execution, isDebugLogEnabled)]]> - + SequenceFlow_14 SequenceFlow_1 - + SequenceFlow_noVfModuleRelation SequenceFlow_personaModelIdMatchYes @@ -91,13 +92,13 @@ execution.setVariable("UpdateVfModuleVolumeSuccessIndicator", true)]]> SequenceFlow_7 - + SequenceFlow_6 - + - + SequenceFlow_7 SequenceFlow_4 @@ -105,24 +106,24 @@ execution.setVariable("UpdateVfModuleVolumeSuccessIndicator", true)]]> - + - - - - - - - + + + + + + + SequenceFlow_4 SequenceFlow_6 - + - - + + SequenceFlow_8 SequenceFlow_personaModelIdMatchYes SequenceFlow_personaModelidMatchNo @@ -130,7 +131,7 @@ uvmv.executeMethod('prepFalloutHandler', execution, isDebugLogEnabled)]]> #{UPDVfModVol_modelInvariantId == UPDVfModVol_personaModelId} - + SequenceFlow_YesVfModuleRelation SequenceFlow_8 @@ -138,7 +139,7 @@ uvmv.executeMethod('prepFalloutHandler', execution, isDebugLogEnabled)]]> - + SequenceFlow_personaModelidMatchNo SequenceFlow_18 @@ -146,10 +147,10 @@ uvmv.executeMethod('queryAAIForVfModule', execution, isDebugLogEnabled)]]> - + SequenceFlow_18 - + SequenceFlow_3 @@ -158,11 +159,11 @@ uvmv.executeMethod('handlePersonaModelIdMismatch', execution, isDebugLogEnabled) def uvmv = new UpdateVfModuleVolumeInfraV1() uvmv.executeMethod('preProcessRequest', execution, isDebugLogEnabled)]]> - + SequenceFlow_3 - + SequenceFlow_2 SequenceFlow_20 @@ -170,22 +171,22 @@ uvmv.executeMethod('preProcessRequest', execution, isDebugLogEnabled)]]> - + SequenceFlow_tenantIsMatch SequenceFlow_YesVfModuleRelation SequenceFlow_noVfModuleRelation - #{UPDVfModVol_relatedVfModuleLink != ''} + - + SequenceFlow_15 SequenceFlow_NoTenantMatch SequenceFlow_tenantIsMatch - + #{UPDVfModVol_tenantId == UPDVfModVol_volumeGroupTenantId} @@ -196,10 +197,10 @@ uvmv.executeMethod('sendSynchResponse', execution, isDebugLogEnabled)]]> - + SequenceFlow_17 - + SequenceFlow_5 @@ -208,7 +209,7 @@ uvmv.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled)]]> - + SequenceFlow_20 SequenceFlow_5 @@ -216,301 +217,301 @@ uvmv.executeMethod('queryAAIForVolumeGroup', execution, isDebugLogEnabled)]]> - + - + - + - + - - - - + + + + - + - + - + - + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - - + + - + - - - - + + + + - + - + - - + + - + - + - + - + - + - + - - + + - + - + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - - - - + + + + - + - + - + - + - - - + + + - + - - + + - + - + - + - - - - + + + + - + - - - + + + - + - + - + - + - - + + - + - - + + - + - - + + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVnfInfra.bpmn new file mode 100644 index 0000000000..2631da1987 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateVnfInfra.bpmn @@ -0,0 +1,1123 @@ + + + + + SequenceFlow_5 + SequenceFlow_0y0jt4l + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_3 + SequenceFlow_17 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_19ba94v + SequenceFlow_0gzzeru + + + + + + + + + + + + + SequenceFlow_0y0jt4l + SequenceFlow_1w35ov3 + + + + SequenceFlow_1w35ov3 + SequenceFlow_053qjfy + + + + + SequenceFlow_16mo99z + SequenceFlow_0fxuur5 + SequenceFlow_2 + + + + + + + SequenceFlow_0baosqi + SequenceFlow_1wax44p + SequenceFlow_0k3fx7p + + + + SequenceFlow_19lg15d + SequenceFlow_1lsfn19 + SequenceFlow_12mfil6 + + + + SequenceFlow_053qjfy + SequenceFlow_0usxnlk + + + + + + + SequenceFlow_1bkhs8m + SequenceFlow_1nlqlwn + SequenceFlow_0xx8y1s + + + + SequenceFlow_0qy68ib + SequenceFlow_1sla5dr + SequenceFlow_0a6pdza + + + + SequenceFlow_0q0qan8 + SequenceFlow_0iektwg + SequenceFlow_13h26h9 + + + + + + SequenceFlow_04zwhw4 + SequenceFlow_1uno5rs + + + + SequenceFlow_162mm0m + SequenceFlow_1hx1ur7 + SequenceFlow_1c79909 + + + + + SequenceFlow_197t3qk + SequenceFlow_0ukzynj + SequenceFlow_1xfbwpi + + + + SequenceFlow_0usxnlk + SequenceFlow_16mo99z + SequenceFlow_1qmz2ez + + + + SequenceFlow_2 + SequenceFlow_0baosqi + SequenceFlow_03rkfbo + + + + + + + + + + + + + + + + + + + SequenceFlow_1qmz2ez + SequenceFlow_03rkfbo + SequenceFlow_1lsm3bn + SequenceFlow_0bduwog + SequenceFlow_0uwar5b + SequenceFlow_0i7hfj2 + SequenceFlow_10ek8l4 + SequenceFlow_13yjc85 + SequenceFlow_0waedj5 + SequenceFlow_1hg9c2l + SequenceFlow_0gej71y + SequenceFlow_0v0u7mf + + + + + + + + + + SequenceFlow_1qr8msw + + + + + + + + + SequenceFlow_0k3fx7p + SequenceFlow_1bkhs8m + SequenceFlow_1lsm3bn + + + + + + + SequenceFlow_0xx8y1s + SequenceFlow_0qy68ib + SequenceFlow_0bduwog + + + + SequenceFlow_0a6pdza + SequenceFlow_0q0qan8 + SequenceFlow_0uwar5b + + + + SequenceFlow_13h26h9 + SequenceFlow_1c0vdki + SequenceFlow_0i7hfj2 + + + + + + + + + + + + + SequenceFlow_0gzzeru + SequenceFlow_04zwhw4 + SequenceFlow_10ek8l4 + + + + + + + SequenceFlow_1uno5rs + SequenceFlow_162mm0m + SequenceFlow_0waedj5 + + + + SequenceFlow_1c79909 + SequenceFlow_197t3qk + SequenceFlow_1hg9c2l + + + + SequenceFlow_1xfbwpi + SequenceFlow_19lg15d + SequenceFlow_0gej71y + + + + SequenceFlow_12mfil6 + SequenceFlow_13yjc85 + SequenceFlow_3 + + + + + + + + + + + + + + + + SequenceFlow_0vpd06n + SequenceFlow_1c022sy + + + + SequenceFlow_0v0u7mf + SequenceFlow_0vpd06n + SequenceFlow_1qr8msw + SequenceFlow_05gpym3 + + + SequenceFlow_05gpym3 + SequenceFlow_1sla5dr + SequenceFlow_0iektwg + SequenceFlow_1ttepat + SequenceFlow_1hx1ur7 + SequenceFlow_0ukzynj + SequenceFlow_1lsfn19 + SequenceFlow_0fxuur5 + SequenceFlow_1wax44p + SequenceFlow_1nlqlwn + SequenceFlow_1c022sy + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1c0vdki + SequenceFlow_1ttepat + SequenceFlow_19ba94v + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties b/bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties deleted file mode 100644 index d071fdabf8..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties +++ /dev/null @@ -1,20 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ECOMP MSO -# ================================================================================ -# 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========================================================= -### -processEngineName=infrastructure diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn index 5488350afc..24ccc4d514 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn @@ -158,13 +158,13 @@ DoCreateNetworkInstance.prepareSDNCRollbackRequest(execution)]]> - + sdncOk_Yeso_ExclusiveGateway isSdncRpc4Yes_SequenceFlow4 isSdncRpc4No_SequenceFlow4 - + @@ -364,16 +364,11 @@ DoCreateNetworkInstance.callRESTQueryAAINetworkName(execution)]]> siFoundNo - SequenceFlow_30 - +exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Service Instance Not Found") +]]> - - - SequenceFlow_30 - - SequenceFlow_16 SequenceFlow_15 @@ -474,14 +469,14 @@ DoCreateNetworkInstance.validateRpcSDNCActivateResponse(execution)]]>SequenceFlow_0s51ns0 - + SequenceFlow_32 isSdncRpc1No_SequenceFlow1 isSdncRpc1Yes_SequenceFlow1 - + @@ -498,13 +493,13 @@ DoCreateNetworkInstance.validateRpcSDNCActivateResponse(execution)]]> - + SequenceFlow_1ipz2ze isSdncRpc2Yes_SequenceFlow2 isSdncRpc2No_SequenceFlow2 - + @@ -925,12 +920,6 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - - - - - - @@ -941,13 +930,6 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - - - - - - - @@ -1097,7 +1079,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + @@ -1135,7 +1117,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + @@ -1156,7 +1138,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn index 00ef41c168..eb60d42c2b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn @@ -97,7 +97,7 @@ DoCreateNetworkInstanceRollback.validateRollbackResponses(execution)]]> - + SequenceFlow_0yto4gz @@ -514,4 +514,4 @@ wasDeleted - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModule.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModule.bpmn index fecb720666..5383dc871e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModule.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModule.bpmn @@ -37,9 +37,7 @@ SequenceFlow_21 - + @@ -180,9 +178,7 @@ doCreateVfModule.validateSDNCResponse(execution, response, "activate")]]>SequenceFlow_30 - + @@ -314,29 +310,9 @@ def doCreateVfModule = new DoCreateVfModule() return doCreateVfModule.queryCloudRegion(execution)]]> - + - - - SequenceFlow_9 - SequenceFlow_38 - - - - - SequenceFlow_9 - - - - - SequenceFlow_38 - - SequenceFlow_1 SequenceFlow_4 @@ -354,7 +330,7 @@ doCreateVfModule.preProcessRequest(execution)]]> - + @@ -498,6 +474,64 @@ doCreateVfModule.validateSDNCResponse(execution, response, "get")]]>SequenceFlow_05og7iw SequenceFlow_1f53tby + + + SequenceFlow_02lc25j + + + + SequenceFlow_0z2rczk + SequenceFlow_1pgo10r + + + + + + + + + + + + SequenceFlow_1i1q78e + SequenceFlow_0112l2c + + + SequenceFlow_04bd5in + SequenceFlow_1i1q78e + + + + SequenceFlow_0112l2c + SequenceFlow_0z2rczk + + + + + + + + SequenceFlow_02lc25j + SequenceFlow_04bd5in + SequenceFlow_1nh7m8d + + + + + + + SequenceFlow_1nh7m8d + SequenceFlow_1pgo10r + + + + @@ -925,38 +959,6 @@ doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1162,6 +1164,92 @@ doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn index 7a7f369e42..cb6538c73a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn @@ -6,7 +6,7 @@ - SequenceFlow_5 + SequenceFlow_11er1t8 SequenceFlow_6 SequenceFlow_9 @@ -17,7 +17,7 @@ def dcvfmr = new DoCreateVfModuleRollback() dcvfmr.preProcessRequest(execution)]]> - + @@ -33,13 +33,13 @@ dcvfmr.preProcessRequest(execution)]]> - + SequenceFlow_8 SequenceFlow_9 SequenceFlow_10 SequenceFlow_15 - + SequenceFlow_1p0v6yk SequenceFlow_16 - + @@ -59,12 +59,12 @@ dcvfmr.prepVNFAdapterRequest(execution)]]> SequenceFlow_16 SequenceFlow_11 - - + + - - + + SequenceFlow_13 SequenceFlow_14 - + @@ -98,19 +98,19 @@ dcvfmr.prepUpdateAAIVfModule(execution)]]> SequenceFlow_19 SequenceFlow_20 - + - - SequenceFlow_19 + + SequenceFlow_1rpg6ac SequenceFlow_32 - + @@ -126,14 +126,15 @@ dcvfmr.prepSDNCAdapterRequest(execution)]]> SequenceFlow_20 SequenceFlow_4 + SequenceFlow_12otwa4 SequenceFlow_21 SequenceFlow_24 - + - + @@ -143,12 +144,12 @@ dcvfmr.prepSDNCAdapterRequest(execution)]]> SequenceFlow_34 SequenceFlow_35 - + - SequenceFlow_35 - SequenceFlow_21 + SequenceFlow_0ggp8wz + SequenceFlow_1h8ve60 - + SequenceFlow_24 SequenceFlow_34 SequenceFlow_22 - + + - SequenceFlow_12 + SequenceFlow_02fx6z6 SequenceFlow_22 - + + + SequenceFlow_12 + SequenceFlow_02fx6z6 + + SequenceFlow_23 @@ -199,15 +208,15 @@ dcvfmr.saveWorkflowException(execution, 'DCVFMR_CaughtWorkflowException1')]]> - + SequenceFlow_0djpj3r - SequenceFlow_15 + SequenceFlow_0n58kg1 SequenceFlow_185bo77 SequenceFlow_111l1he - SequenceFlow_10 + SequenceFlow_0unumxv SequenceFlow_0djpj3r + + SequenceFlow_5 + SequenceFlow_11er1t8 + SequenceFlow_0ggp8wz + + + + + + + SequenceFlow_06rm0hg + SequenceFlow_15 + SequenceFlow_0n58kg1 + SequenceFlow_0unumxv + + + SequenceFlow_10 + SequenceFlow_0ugalf8 + + + + + + + + + + + + + SequenceFlow_0ugalf8 + SequenceFlow_0n78x37 + + + SequenceFlow_0n78x37 + SequenceFlow_06rm0hg + + + + + + + + + + + + + SequenceFlow_16ghmax + SequenceFlow_1iufuuu + + + + + + + + + + + + + SequenceFlow_1iufuuu + SequenceFlow_1l4n37b + + + SequenceFlow_1l4n37b + SequenceFlow_12otwa4 + + + + SequenceFlow_19 + SequenceFlow_1rpg6ac + SequenceFlow_16ghmax + + + + + + + + + SequenceFlow_21 + SequenceFlow_35 + SequenceFlow_1h8ve60 + + @@ -260,13 +368,13 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - + - + - + @@ -276,62 +384,62 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - + - + - - + + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - - - + + + - + @@ -341,18 +449,16 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - - - - + + - + - + @@ -388,47 +494,47 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - - + + - + - + - + - - - - + + + + - + - - - - + + + + - + - - + + - + - + - + @@ -436,230 +542,380 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - - + + - + - - + + - + - - - + + + - + - - - - - - + + + + + - + - + - + - - - - - - + + + + + + + - + - - - - + + - + - - - - - + + + + + - + - + - - + + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - + + - + - + - + - + - + - + - - - + + + - + - + - + - - - - + + + + - + - - - - + + + + - + - - - - + + + + - + - - - + + + - + - - - - - + + + + + - + - - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn new file mode 100644 index 0000000000..fd2889f642 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn @@ -0,0 +1,247 @@ + + + + + + SequenceFlow_0xktw7v + SequenceFlow_0soe5t3 + + + + SequenceFlow_0xktw7v + + + + SequenceFlow_0soe5t3 + + + + + + SequenceFlow_0qreiaa + + + + SequenceFlow_1xah9es + SequenceFlow_11y7faf + SequenceFlow_1wberw3 + + + SequenceFlow_11y7faf + SequenceFlow_0h7k68j + SequenceFlow_10dawse + + + + + + + + + + SequenceFlow_0h7k68j + SequenceFlow_0bv04qn + + + + + + SequenceFlow_0bv04qn + SequenceFlow_17k6oyz + SequenceFlow_13nb3n0 + + + + + + + SequenceFlow_10dawse + SequenceFlow_17k6oyz + SequenceFlow_1do0853 + + + + + + + SequenceFlow_1do0853 + SequenceFlow_1wberw3 + + + SequenceFlow_13nb3n0 + + + + + + SequenceFlow_0qreiaa + SequenceFlow_1xah9es + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV1.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV1.bpmn deleted file mode 100644 index de88284db6..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV1.bpmn +++ /dev/null @@ -1,675 +0,0 @@ - - - - - SequenceFlow_1 - SequenceFlow_22 - - - - - SequenceFlow_22 - SequenceFlow_23 - - - - - SequenceFlow_volGrpName404No - SequenceFlow_7 - - - - - SequenceFlow_19 - SequenceFlow_6 - SequenceFlow_volGrpName404Yes - SequenceFlow_volGrpName404No - - - #{DCVFMODVOLV1_AaiReturnCode == '404'} - - - - SequenceFlow_23 - SequenceFlow_14 - - - - - SequenceFlow_19 - - - - - SequenceFlow_14 - SequenceFlow_6 - - - - - SequenceFlow_volGrpName404Yes - SequenceFlow_9 - - - - - - - - - - - - - - - SequenceFlow_10 - SequenceFlow_3 - - - - SequenceFlow_11 - - - - - SequenceFlow_3 - SequenceFlow_vnfAdapterFail - SequenceFlow_vnfAdapterSuccess - - - - #{VNFREST_SuccessIndicator == true} - - - SequenceFlow_vnfAdapterSuccess - SequenceFlow_28 - - - - - - - - SequenceFlow_5 - SequenceFlow_8 - - - - - - - - SequenceFlow_28 - SequenceFlow_5 - - - - - SequenceFlow_8 - - - SequenceFlow_9 - SequenceFlow_10 - - - - - - - - SequenceFlow_4 - SequenceFlow_12 - - - - - SequenceFlow_rollbackIsEnabled1 - SequenceFlow_4 - - - - - SequenceFlow_11 - SequenceFlow_17 - SequenceFlow_rollbackIsEnabled1 - SequenceFlow_rollbackIsNotEnabled1 - - - #{DCVFMODVOLV1_rollbackEnabled == true} - - - - SequenceFlow_rollbackIsEnabled2 - SequenceFlow_15 - - - - - SequenceFlow_vnfAdapterFail - SequenceFlow_rollbackIsEnabled2 - SequenceFlow_rollbackIsNotEnabled2 - - - #{DCVFMODVOLV1_rollbackEnabled == true} - - - - SequenceFlow_1 - - - - - - - - - - - - - - SequenceFlow_rollbackEnabledYes91 - SequenceFlow_16 - - - - - SequenceFlow_13 - SequenceFlow_rollbackEnabledYes91 - SequenceFlow_rollbackNotEnabled92 - - - #{DCVFMODVOLV1_rollbackEnabled == true} - - - - SequenceFlow_13 - - - - - SequenceFlow_16 - SequenceFlow_rollbackNotEnabled92 - - - - SequenceFlow_17 - - - - - SequenceFlow_rollbackIsNotEnabled1 - SequenceFlow_12 - - - SequenceFlow_rollbackIsNotEnabled2 - SequenceFlow_15 - - - SequenceFlow_7 - - - WorkflowException should already have been created in VNF create subflow - - - - - - Catch MsoException triggered by Plugin. The vnfAdapterRest subflow is currently not directly throwing the BPMNError(MSOException. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn new file mode 100644 index 0000000000..693fd36575 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn @@ -0,0 +1,362 @@ + + + + + SequenceFlow_1 + SequenceFlow_1wi1cf9 + + + + SequenceFlow_1dpt7ul + SequenceFlow_23 + + + + + SequenceFlow_volGrpName404No + SequenceFlow_7 + + + + + SequenceFlow_19 + SequenceFlow_6 + SequenceFlow_volGrpName404Yes + SequenceFlow_volGrpName404No + + + + + + + SequenceFlow_23 + SequenceFlow_14 + + + + + SequenceFlow_19 + + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_volGrpName404Yes + SequenceFlow_9 + + + + + + + + + + + + + + + SequenceFlow_10 + SequenceFlow_1qwurc5 + + + SequenceFlow_1gbt2n5 + SequenceFlow_28 + + + + + SequenceFlow_5 + SequenceFlow_8 + + + + + SequenceFlow_28 + SequenceFlow_5 + + + + + SequenceFlow_8 + + + SequenceFlow_9 + SequenceFlow_10 + + + + + SequenceFlow_1 + + + + SequenceFlow_7 + + + SequenceFlow_1qwurc5 + SequenceFlow_1gbt2n5 + + + + + + + + + + + + + SequenceFlow_1wi1cf9 + SequenceFlow_1vmbvy8 + + + SequenceFlow_1vmbvy8 + SequenceFlow_1dpt7ul + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn index 8411c56bef..5aa4d22b0c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -8,7 +8,7 @@ SequenceFlow_1 SequenceFlow_2 - @@ -88,7 +88,7 @@ exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist vnfExistNo VnfNameNotSpecified1 SequenceFlow_11 - @@ -136,7 +136,7 @@ exceptionUtil.processJavaException(execution)]]> SdncInteractionEnabled SequenceFlow_1q6udwm - @@ -155,9 +155,8 @@ createVnf.preProcessSDNCAssignRequest(execution)]]> SequenceFlow_15knw0q - SequenceFlow_0lnh79j - + SequenceFlow_1q1poly VnfNameSpecified2 SequenceFlow_1lalmvp - @@ -187,7 +186,7 @@ createVnf.preProcessSDNCActivateRequest(execution)]]> SequenceFlow_0eb41vb SequenceFlow_15z3gpq - SequenceFlow_0seif8n SequenceFlow_1gc18ih - @@ -655,4 +654,4 @@ doCreateVnf.prepUpdateAAIGenericVnf(execution)]]> - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn index be54119bda..a90c816bc3 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn @@ -25,11 +25,11 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> - + - + @@ -44,7 +44,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> SequenceFlow_1ixcnb6 - + @@ -59,11 +59,11 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> - + - + @@ -95,8 +95,8 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> - SequenceFlow_07gl6gw SequenceFlow_1a6wyuu + SequenceFlow_0j52dxv SequenceFlow_132bohl SequenceFlow_0jz6bqn @@ -115,7 +115,7 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> - + @@ -123,9 +123,11 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> + + - SequenceFlow_1xd3ri5 - SequenceFlow_08i3uo6 + SequenceFlow_19ohb1a + SequenceFlow_07u8e3l SequenceFlow_0jz6bqn @@ -135,13 +137,12 @@ def doCreateVnfAndModules = new DoCreateVnfAndModules() doCreateVnfAndModules.preProcessAddOnModule(execution)]]> - SequenceFlow_08i3uo6 - SequenceFlow_1ifw9tw + SequenceFlow_1xd3ri5 + SequenceFlow_19ohb1a - SequenceFlow_1mguf2m SequenceFlow_12x4dvf @@ -155,9 +156,7 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> - - - + @@ -169,7 +168,7 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> - SequenceFlow_1ifw9tw + SequenceFlow_07u8e3l SequenceFlow_1hf7k7q @@ -187,13 +186,6 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> - - SequenceFlow_1vrogpr - SequenceFlow_07gl6gw - - @@ -203,24 +195,55 @@ doCreateVnfAndModules.finisthProcessingInitialCountDeployment(execution)]]> - - - SequenceFlow_11bmhi4 - SequenceFlow_1kjlzrn - - - - SequenceFlow_1kjlzrn + + + SequenceFlow_1h74w1v - - SequenceFlow_11bmhi4 - + + + + + + + + + + SequenceFlow_03v8mmc + SequenceFlow_0yu0im2 + + + SequenceFlow_1l0rxnh + SequenceFlow_03v8mmc + + + + SequenceFlow_0yu0im2 + SequenceFlow_1h74w1v + + + + + + + + SequenceFlow_1l0rxnh + - - + + + + + SequenceFlow_1vrogpr + SequenceFlow_0j52dxv + + @@ -247,9 +270,9 @@ exceptionUtil.processJavaException(execution)]]> - + - + @@ -287,21 +310,14 @@ exceptionUtil.processJavaException(execution)]]> - + - + - - - - - - - @@ -337,24 +353,10 @@ exceptionUtil.processJavaException(execution)]]> - - - - - - - - - - - - - - - - + + - + @@ -384,9 +386,6 @@ exceptionUtil.processJavaException(execution)]]> - - - @@ -404,38 +403,85 @@ exceptionUtil.processJavaException(execution)]]> - - - - - + + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + - - - + + + - + - - - + + + - + + + + + + + + + + + + - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn index 2fba166dc4..aa362021e0 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn @@ -9,9 +9,9 @@ SequenceFlow_22 - + - SequenceFlow_12 + SequenceFlow_1wch84s SequenceFlow_22 + + + SequenceFlow_12 + SequenceFlow_1wch84s + + SequenceFlow_23 @@ -32,19 +40,21 @@ dcvfmr.saveWorkflowException(execution, 'DCVFMR_CaughtWorkflowException1')]]>SequenceFlow_1537b7m - SequenceFlow_0bmsi5h SequenceFlow_1srw52v + SequenceFlow_0zjzorm + SequenceFlow_19xaddm SequenceFlow_1r6wyy6 SequenceFlow_0v85t87 - SequenceFlow_1r6wyy6 + SequenceFlow_1g6psjt + SequenceFlow_152tazp SequenceFlow_1kr0r4a SequenceFlow_1yas9ol - SequenceFlow_04yd2yr - SequenceFlow_1yas9ol + SequenceFlow_0mk9lrj + SequenceFlow_03cc9y6 @@ -54,8 +64,8 @@ dcvfmr.saveWorkflowException(execution, 'DCVFMR_CaughtWorkflowException1')]]> - - + + SequenceFlow_0v85t87 SequenceFlow_1ycq005 @@ -63,26 +73,30 @@ dcvamr.preProcessRequest(execution)]]> def dcvamr = new DoCreateVnfAndModulesRollback() dcvamr.preProcessCreateVfModuleRollback(execution)]]> - + - + + + + + SequenceFlow_1ycq005 SequenceFlow_181hb2a - + 0}]]> - + - - + + @@ -92,7 +106,7 @@ dcvamr.preProcessCreateVfModuleRollback(execution)]]> SequenceFlow_1kr0r4a SequenceFlow_04yd2yr - + SequenceFlow_181hb2a SequenceFlow_1srw52v @@ -101,13 +115,111 @@ def dcvamr = new DoCreateVnfAndModulesRollback() dcvamr.postProcessCreateVfModuleRollback(execution)]]> + + SDNCDeactivateYes + SequenceFlow_0nysmc9 + + + + SequenceFlow_1hc04x2 + SequenceFlow_19xaddm + + + + + + + + + + + + + SequenceFlow_0nysmc9 + SequenceFlow_1hc04x2 + + + + + SequenceFlow_1rezswi + SequenceFlow_0zjzorm + SDNCDeactivateYes + + + + + + + + SequenceFlow_1r6wyy6 + SequenceFlow_1g6psjt + SequenceFlow_01am36p + + + + SequenceFlow_01am36p + SequenceFlow_0a5ecvu + + + + + + + + + + + + + SequenceFlow_0a5ecvu + SequenceFlow_1ilok6u + + + SequenceFlow_1ilok6u + SequenceFlow_152tazp + + + + + + + + + + SequenceFlow_0bmsi5h + SequenceFlow_1rezswi + SequenceFlow_0mk9lrj + + + + + + + + SequenceFlow_1yas9ol + SequenceFlow_04yd2yr + SequenceFlow_03cc9y6 + + - + @@ -116,167 +228,313 @@ dcvamr.postProcessCreateVfModuleRollback(execution)]]> - + - + - + - + - + - + - + - + - + - - - - + + - + - - + + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - + + + + - + - - + + - + - + - - + + - - - - - + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - + + - + - + - - + + - + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn index 3c581865cc..6f58f62476 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn @@ -268,7 +268,7 @@ DoDeleteNetworkInstance.postProcessResponse(execution) - + SequenceFlow_20 SequenceFlow_0r3pvf8 SequenceFlow_0kqnddy @@ -298,7 +298,7 @@ prepareSDNCRequest.prepareRpcSDNCRequest(execution) - + SequenceFlow_1 @@ -699,7 +699,7 @@ DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(execution)]]> - + @@ -930,4 +930,4 @@ DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(execution)]]> - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn index 2c5fa5ae4b..fabcb5e2e5 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn @@ -121,7 +121,7 @@ DoDeleteNetworkInstanceRollback.processJavaException(execution)]]> - + @@ -543,4 +543,4 @@ wasDeleted - + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn index 49274bd8a6..10f688b30f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn @@ -7,7 +7,7 @@ SequenceFlow_0jfgn05 SequenceFlow_1jqc16k - @@ -41,13 +41,13 @@ ddsi.preProcessRequest(execution) - SequenceFlow_0rtflal + SequenceFlow_0yohjl7 SequenceFlow_0k28xib SequenceFlow_0k28xib SequenceFlow_1w8ao21 - SequenceFlow_1dwch0k - SequenceFlow_0rtflal - SequenceFlow_1ju26o1 + - SequenceFlow_1up0j5r SequenceFlow_1hcfvcj @@ -101,7 +100,7 @@ ddsi.preProcessSDNCDelete(execution)]]> SequenceFlow_1grea1r SequenceFlow_1up0j5r - @@ -110,7 +109,7 @@ ddsi.postProcessAAIGET(execution)]]> SequenceFlow_05wu9i7 SequenceFlow_1wyvxwi - @@ -126,7 +125,7 @@ ddsi.postProcessAAIDEL(execution)]]> SequenceFlow_0u33vy6 SequenceFlow_0hevfee - @@ -143,6 +142,7 @@ ex.processJavaException(execution)]]> SequenceFlow_1w8ao21 + SequenceFlow_1swzrij SequenceFlow_14x55db @@ -156,6 +156,16 @@ ddsi.postProcessSDNCDelete(execution, response, "delete")]]> + + SequenceFlow_1ju26o1 + SequenceFlow_0yohjl7 + SequenceFlow_1swzrij + + + + + + @@ -168,7 +178,7 @@ ddsi.postProcessSDNCDelete(execution, response, "delete")]]> - + @@ -187,61 +197,52 @@ ddsi.postProcessSDNCDelete(execution, response, "delete")]]> - + - + - + - - - + - + - + - - - - - - - - + - + - - + + - + - + - + - - + + - + @@ -252,58 +253,53 @@ ddsi.postProcessSDNCDelete(execution, response, "delete")]]> - + - + - - + + - + - - + + + - + - + - - - - + + - + - + - - - - + + - + - - - - + + - + @@ -368,6 +364,35 @@ ddsi.postProcessSDNCDelete(execution, response, "delete")]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn new file mode 100644 index 0000000000..bc42e6094b --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + SequenceFlow_32 + SequenceFlow_33 + + + + SequenceFlow_0kx9e3s + SequenceFlow_4 + + + + SequenceFlow_0ltm4jt + SequenceFlow_32 + + + + + + + + + + + + + SequenceFlow_4 + SequenceFlow_0hia88a + + + SequenceFlow_1eemrjp + + + SequenceFlow_33 + SequenceFlow_2 + + + + + SequenceFlow_1 + SequenceFlow_0qbjihn + + + + + SequenceFlow_0coa90m + SequenceFlow_0ltm4jt + + + + SequenceFlow_0hia88a + SequenceFlow_0coa90m + + + + + SequenceFlow_1 + + + + + + + + SequenceFlow_1igsfgk + SequenceFlow_0y4td40 + + + + + + + + + + + + + SequenceFlow_0y4td40 + SequenceFlow_12q2r4i + + + SequenceFlow_12q2r4i + SequenceFlow_0kx9e3s + + + + + + SequenceFlow_0qbjihn + SequenceFlow_1c2lvlc + + + + + SequenceFlow_1c2lvlc + SequenceFlow_1igsfgk + + + + + SequenceFlow_095634c + + + + SequenceFlow_0yvjvhu + + + SequenceFlow_095634c + SequenceFlow_0yvjvhu + + + + + + + + + + + + + SequenceFlow_092kvy3 + SequenceFlow_1eemrjp + + + SequenceFlow_2 + SequenceFlow_092kvy3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn new file mode 100644 index 0000000000..fec3f93521 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn @@ -0,0 +1,208 @@ + + + + + SequenceFlow_1gvfdp4 + + + SequenceFlow_1vy2ojp + SequenceFlow_1dlcqmc + + + + SequenceFlow_1dlcqmc + SequenceFlow_1kjccf1 + + + + SequenceFlow_1kjccf1 + SequenceFlow_1tgngf7 + + + + + + + + + + + + + SequenceFlow_1tgngf7 + SequenceFlow_1x3luyj + + + SequenceFlow_0cy0y9t + SequenceFlow_13c3cv2 + + + + SequenceFlow_1sgtwr2 + + + + + + SequenceFlow_1gvfdp4 + SequenceFlow_1vy2ojp + + + + + + SequenceFlow_1x3luyj + SequenceFlow_0cy0y9t + SequenceFlow_1rgd8dg + + + + #{VNFREST_SuccessIndicator == true} + + + SequenceFlow_1rgd8dg + + + + + SequenceFlow_13c3cv2 + SequenceFlow_1sgtwr2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn index 078e0107ba..9850552a9e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn @@ -66,7 +66,7 @@ exceptionUtil.processJavaException(execution)]]> - + SequenceFlow_1xujrk5 diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn index 45e1a49f8a..53c419e6a6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn @@ -155,7 +155,7 @@ DoUpdateNetworkInstance.postProcessResponse(execution)]]> - + SequenceFlow_23 @@ -238,18 +238,12 @@ def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() DoUpdateNetworkInstance.callRESTQueryAAINetworkId(execution)]]> - - SequenceFlow_30 - - siFoundNo - SequenceFlow_30 - +exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Service Instance Not Found")]]> - SequenceFlow_3 siFoundYes @@ -259,7 +253,7 @@ exceptionUtil.buildWorkflowException(execution, 404, "Service Instance Not Found - + @@ -714,12 +708,6 @@ DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(execution)]]> - - - - - - @@ -731,13 +719,6 @@ DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(execution)]]> - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn index 6fd0565f3a..a8ea29b15c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn @@ -82,7 +82,7 @@ DoUpdateNetworkInstanceRollback.validateRollbackResponses(execution)]]> - + SequenceFlow_0yto4gz @@ -149,7 +149,7 @@ wasDeleted - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVfModule.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVfModule.bpmn index 5911067a49..ce96a3593a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVfModule.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVfModule.bpmn @@ -1,7 +1,7 @@ - + - This flow expects its incoming request to be in the variable 'DoUpdateVfModuleRequest'. This flow produces no output. + SequenceFlow_38 SequenceFlow_2 @@ -9,16 +9,16 @@ def duvm = new DoUpdateVfModule() duvm.prepPrepareUpdateAAIVfModule(execution)]]> - + - - - - - - - + + + + + + + SequenceFlow_2 SequenceFlow_15 @@ -30,7 +30,7 @@ duvm.prepPrepareUpdateAAIVfModule(execution)]]> def duvm = new DoUpdateVfModule() duvm.preProcessRequest(execution)]]> - + SequenceFlow_6 @@ -41,24 +41,24 @@ duvm.handleWorkflowException(execution)]]> SequenceFlow_35 - + - + SequenceFlow_6 - + - + SequenceFlow_36 - + SequenceFlow_36 - + - + SequenceFlow_9 SequenceFlow_18 @@ -67,19 +67,19 @@ duvm.handleWorkflowException(execution)]]> def duvm = new DoUpdateVfModule() duvm.prepUpdateAAIVfModule(execution)]]> - + - - - - - + + + + + SequenceFlow_25 SequenceFlow_26 - + SequenceFlow_26 SequenceFlow_27 @@ -87,16 +87,16 @@ duvm.prepUpdateAAIVfModule(execution)]]> def duvm = new DoUpdateVfModule() duvm.prepSDNCTopologyAct(execution)]]> - + - - - - - - - + + + + + + + SequenceFlow_27 SequenceFlow_7 @@ -108,32 +108,33 @@ duvm.prepSDNCTopologyAct(execution)]]> def duvm = new DoUpdateVfModule() duvm.prepUpdateAAIGenericVnf(execution)]]> - + - - - - - + + + + + SequenceFlow_14 SequenceFlow_9 - - + + SequenceFlow_13 SequenceFlow_14 SequenceFlow_18 - + - ${execution.getVariable('DOUPVfMod_skipUpdateGenericVnf')} == true + SequenceFlow_1 - + SequenceFlow_16 SequenceFlow_17 @@ -142,33 +143,33 @@ duvm.prepUpdateAAIGenericVnf(execution)]]> def duvm = new DoUpdateVfModule() duvm.prepSDNCTopologyChg(execution)]]> - + - - - - - - - + + + + + + + SequenceFlow_12 SequenceFlow_3 - - - - - - + + + + + + SequenceFlow_21 SequenceFlow_24 - + SequenceFlow_23 SequenceFlow_21 @@ -176,7 +177,7 @@ duvm.prepSDNCTopologyChg(execution)]]> def duvm = new DoUpdateVfModule() duvm.prepVnfAdapterRest(execution)]]> - + SequenceFlow_22 SequenceFlow_23 @@ -187,13 +188,13 @@ duvm.validateSDNCResponse(execution, response, "query")]]> - - - - - - - + + + + + + + SequenceFlow_19 SequenceFlow_22 @@ -206,8 +207,8 @@ String response = execution.getVariable("DOUPVfMod_sdncChangeAssignResponse") def duvm = new DoUpdateVfModule() duvm.validateSDNCResponse(execution, response, "changeassign")]]> - - + + SequenceFlow_5 SequenceFlow_19 @@ -215,29 +216,30 @@ duvm.validateSDNCResponse(execution, response, "changeassign")]]> def duvm = new DoUpdateVfModule() duvm.prepSDNCTopologyQuery(execution)]]> - - - + + + SequenceFlow_15 SequenceFlow_28 SequenceFlow_30 - + - - - - - - - + + + + + + + + SequenceFlow_11 SequenceFlow_17 - + SequenceFlow_10 SequenceFlow_11 @@ -245,16 +247,17 @@ duvm.prepSDNCTopologyQuery(execution)]]> def duvm = new DoUpdateVfModule() duvm.prepConfirmVolumeGroupTenant(execution)]]> - - + + SequenceFlow_29 SequenceFlow_10 SequenceFlow_16 - ${execution.getVariable('DOUPVfMod_volumeGroupId').isEmpty()} == false + - + @@ -265,15 +268,15 @@ duvm.prepConfirmVolumeGroupTenant(execution)]]> def doUpdateVfModule = new DoUpdateVfModule() doUpdateVfModule.queryAAIVfModule(execution)]]> - - + + SequenceFlow_28 SequenceFlow_34 SequenceFlow_29 - - + + SequenceFlow_7 SequenceFlow_20 @@ -288,381 +291,381 @@ duvm.validateSDNCResponse(execution, response, "activate")]]> - + SequenceFlow_4 - + - + - + - + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - - - - + + + + - + - + - - + + - + - + - + - + - - + + - + - - - - + + + + - + - - - - - + + + + + - + - + - - + + - + - + - + - - + + - + - + - + - - - - + + + + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - - + + - + - + - + - - + + - + - + - - + + - + - + - + - - + + - + - - - - + + + + - + - + - + - - + + - + - - - + + + - + - + - + - - + + - - + + - + - - + + - - + + - + - + - + - + - + - - - - + + + + - - + + - + - - + + - + - - - + + + - + - - - - + + + + - + - + - - + + - + - - + + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn new file mode 100644 index 0000000000..c110580f5c --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn @@ -0,0 +1,274 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_08nd69s + + + + + SequenceFlow_19 + + + SequenceFlow_18 + + + + + SequenceFlow_18 + SequenceFlow_19 + + + + + + SequenceFlow_0of4kmm + + + + SequenceFlow_0t4yszi + SequenceFlow_1f4mbkc + SequenceFlow_1qrkdn3 + SequenceFlow_19c7hcw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_04o61yk + SequenceFlow_1p4ycii + + + + + SequenceFlow_08nd69s + SequenceFlow_1f4mbkc + + + + SequenceFlow_1qrkdn3 + SequenceFlow_04o61yk + + + + SequenceFlow_1p4ycii + SequenceFlow_0t4yszi + + + + + + + + + + + + + + + SequenceFlow_1ltycz6 + SequenceFlow_0of4kmm + + + SequenceFlow_19c7hcw + SequenceFlow_1ltycz6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml new file mode 100644 index 0000000000..0492cebbe9 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml index eb5df6038e..cd114a85dc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml +++ b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml @@ -25,13 +25,17 @@ org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher javax.ws.rs.Application - org.openecomp.mso.bpmn.infrastructure.workflow.service.WorkflowResourceApplication + org.openecomp.mso.bpmn.common.workflow.service.WorkflowResourceApplication resteasy-servlet /* + + contextConfigLocation + /WEB-INF/applicationContext.xml + mso.configuration MSO_PROP_TOPOLOGY=topology.properties @@ -44,6 +48,9 @@ resteasy.resources org.openecomp.mso.logger.MsoLoggingServlet,org.openecomp.mso.bpmn.core.HealthCheckHandler + + org.springframework.web.context.ContextLoaderListener + LogFilter org.openecomp.mso.logger.LogFilter diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..13e107e8ad --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy @@ -0,0 +1,360 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +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.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class CreateNetworkInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + String Prefix="CRENI_" + def utils = new MsoUtils() + + String createDBRequestError = +""" + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error from SDN-C: No availability zone available + + FAILED + <network-id></network-id><network-name></network-names> + + + """ + + String falloutHandlerRequest = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + CREATE + VID + + + Received error from SDN-C: No availability zone available. + 5300 + + """ + + String completeMsoProcessRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CREATE + VID + + Network has been created successfully. + BPMN Network action: CREATE +""" + + +String jsonIncomingRequest = +"""{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "someUserParam1", + "value": "someValue1" + } + ] + } + }}""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables(Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "Success", false) + + verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") + verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") + verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) + + } + + @Test + //@Ignore + public void preProcessRequest() { + + println "************ preProcessRequest() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + + + // preProcessRequest(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + initializeVariables(mockExecution) + //verify(mockExecution).setVariable(Prefix + "Success", false) + + } + + + @Test + //@Ignore + public void getNetworkModelInfo() { + + println "************ getNetworkModelInfo() ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.getNetworkModelInfo(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + @Test + //@Ignore + public void sendSyncResponse() { + + println "************ sendSyncResponse ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + // preProcessRequest(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.sendSyncResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("CreateNetworkInstanceResponseCode", "202") + + } + + @Test + //@Ignore + public void sendSyncError() { + + println "************ sendSyncError ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.sendSyncError(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("CreateNetworkInstanceResponseCode", "500") + + } + + @Test + //@Ignore + public void prepareDBRequestError() { + + println "************ prepareDBRequestError ************* " + + WorkflowException sndcWorkflowException = new WorkflowException("CreateNetworkInstance", 500, "Received error from SDN-C: No availability zone available") + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + //when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("networkId")).thenReturn("") + when(mockExecution.getVariable("networkName")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.prepareDBRequestError(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "createDBRequest", createDBRequestError) + + } + + + @Test + //@Ignore + public void prepareCompletion() { + + println "************ postProcessResponse ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + 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") + + // postProcessResponse(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.prepareCompletion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", true) + verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", completeMsoProcessRequest) + + } + + @Test + //@Ignore + public void buildErrorResponse() { + + println "************ buildErrorResponse ************* " + + + WorkflowException sndcWorkflowException = new WorkflowException("CreateNetworkInstance", 5300, "Received error from SDN-C: No availability zone available.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") + //when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + + // buildErrorResponse(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.buildErrorResponse(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", "CRENI_") + verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + } + + @Test + //@Ignore + public void postProcessResponse() { + + println "************ postProcessResponse() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("CMSO_ResponseCode")).thenReturn("200") + + // postProcessResponse(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.postProcessResponse(mockExecution) + + //verify(mockExecution).getVariable("isDebugLogEnabled") + //verify(mockExecution).setVariable("prefix", Prefix) + + verify(mockExecution).setVariable(Prefix + "Success", true) + + } + + @Test + //@Ignore + public void processRollbackData() { + + println "************ callDBCatalog() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.processRollbackData(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("CreateNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("CreateNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("CreateNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy index 4f5375719f..0cf97922ae 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy @@ -27,10 +27,11 @@ import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.mockito.ArgumentCaptor import org.mockito.MockitoAnnotations import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest import org.junit.Before +import org.junit.Ignore; import org.junit.Test import org.junit.runner.RunWith -import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest; @RunWith(MockitoJUnitRunner.class) @@ -64,8 +65,8 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { "instanceId": "{service-instance-id}", "modelInfo": { "modelType": "service", - "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "Test", "modelVersion": "2.0" } @@ -79,7 +80,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1", - "modelCustomizationName": "vSAMP12" + "modelInstanceName": "vSAMP12" } } } @@ -162,6 +163,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { @Test + @Ignore public void testPreProcessRequest() { ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1') @@ -171,6 +173,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { when(mockExecution.getVariable("serviceInstanceId")).thenReturn('') when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id') when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn('true') CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.preProcessRequest(mockExecution, 'true') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy new file mode 100644 index 0000000000..304697891f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy @@ -0,0 +1,397 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +import org.apache.commons.lang3.* +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.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.junit.WireMockRule + + +@RunWith(MockitoJUnitRunner.class) +class DeleteNetworkInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + String Prefix="DELNI_" + def utils = new MsoUtils() + + String falloutHandlerRequest = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + DELETE + PORTAL + + + Received error from SDN-C: No availability zone available + 5300 + 200 + + """ + + String falloutHandlerRequestObj = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + DELETE + PORTAL + + + Received error from SDN-C: No availability zone available + 7000 + + """ + + String completeMsoProcessRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + VID + + Network has been deleted successfully. + BPMN Network action: DELETE +""" + +String deleteDBRequest = +""" + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Network successfully deleted. + + COMPLETED + 100 + <network-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> + + +""" + +String deleteDBRequestErrorObj = +""" + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error from SDN-C: No availability zone available + + FAILED + + <network-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> + + + """ + +String deleteDBRequestErrorString = +""" + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error from SDN-C: No availability zone available + + FAILED + + <network-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> + + + """ + + String jsonIncomingRequest = + """{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "someUserParam1", + "value": "someValue1" + } + ] + } + }}""" + +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + //@Ignore + public void preProcessRequest() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + + } + + public void initializeVariables (Execution mockExecution) { + + + verify(mockExecution).setVariable(Prefix + "Success", false) + + verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") + verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") + verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) + + } + + + @Test + //@Ignore + public void getNetworkModelInfo() { + + println "************ getNetworkModelInfo() ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.getNetworkModelInfo(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + @Test + //@Ignore + public void sendSyncResponse() { + + println "************ sendSyncResponse ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + // preProcessRequest(Execution execution) + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.sendSyncResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("DeleteNetworkInstanceResponseCode", "202") + + } + + + @Test + //@Ignore + public void sendSyncError() { + + println "************ sendSyncError ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.sendSyncError(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("DeleteNetworkInstanceResponseCode", "500") + + } + + + @Test + //@Ignore + public void prepareCompletion() { + + println "************ postProcessResponse ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("PORTAL") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + // postProcessResponse(Execution execution) + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.prepareCompletion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", completeMsoProcessRequest) + + } + + + @Test + //@Ignore + public void prepareDBRequestError() { + + println "************ prepareDBRequestError ************* " + + WorkflowException sndcWorkflowExceptionObj = new WorkflowException("CreateNetworkV2", 500, "Received error from SDN-C: No availability zone available") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowExceptionObj) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.prepareDBRequestError(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "deleteDBRequest", deleteDBRequestErrorObj) + + } + + + @Test + //@Ignore + public void postProcessResponse() { + + println "************ postProcessResponse ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("CMSO_ResponseCode")).thenReturn("200") + + // postProcessResponse(Execution execution) + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.postProcessResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", true) + + + } + + + @Test + //@Ignore + public void buildErrorResponse_FalloutHandlerRequest() { + + println "************ buildErrorResponse ************* " + + WorkflowException sndcWorkflowExceptionObj = new WorkflowException("DeleteNetworkInstance", 7000, "Received error from SDN-C: No availability zone available") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowExceptionObj) + when(mockExecution.getVariable(Prefix + "source")).thenReturn("PORTAL") + + // buildErrorResponse(Execution execution) + DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() + DeleteNetworkInstance.buildErrorResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", false) + verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequestObj) + + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DeleteNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DeleteNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DeleteNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DeleteNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy index 2e6b35eaba..fac156e86d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy @@ -26,6 +26,7 @@ import static org.mockito.Mockito.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.mockito.MockitoAnnotations @@ -121,11 +122,14 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { } @Test + //@Ignore public void testPrepareDbRequest() { ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') when(mockExecution.getVariable("DELVfModVol_volumeOutputs")).thenReturn('') + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() myproc.prepareDBRequest(mockExecution, 'true') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..2bb88632db --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy @@ -0,0 +1,349 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.delegate.BpmnError +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.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.junit.Before +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith + +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapterRestRollbackDelete; +import static org.junit.Assert.*; + +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.apache.commons.lang3.* + + +@RunWith(MockitoJUnitRunner.class) +class DoCreateNetworkInstanceRollbackTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + def utils = new MsoUtils() + String Prefix="CRENWKIR_" + + + String rollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String rollbackActivateSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String rollbackSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "WorkflowException", null) + + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) + verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", null) + verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCRequest", null) + verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "Success", false) + verify(mockExecution).setVariable(Prefix + "fullRollback", false) + verify(mockExecution).setVariable(Prefix + "networkId", "") + verify(mockExecution).setVariable(Prefix + "urlRollbackPoNetwork", "") + + } + + @Test + //@Ignore + public void preProcessRequest() { + + println "************ preProcessRequest ************* " + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + Map rollbackData = new HashMap(); + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") + + + // preProcessRequest(Execution execution) + DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() + DoCreateNetworkInstanceRollback.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + } + + @Test + //@Ignore + public void callPONetworkAdapter() { + + MockNetworkAdapterRestRollbackDelete("deleteNetworkResponse_Success.xml","8abc633a-810b-4ca5-8b3a-09511d13a2ce"); + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn( rollbackNetworkRequest) + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() + DoCreateNetworkInstanceRollback.callPONetworkAdapter(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable(Prefix + "urlRollbackPoNetwork", "http://localhost:28090/networks/NetworkAdapter/8abc633a-810b-4ca5-8b3a-09511d13a2ce/rollback") + + } + + @Test + //@Ignore + public void validateRollbackResponses_Good() { + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowException = new WorkflowException("DoCreateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC activate rollback completed. + PO Network rollback completed. + SNDC assign rollback completed.") + + println "************ validateRollbackResponses_Good() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) + + DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() + DoCreateNetworkInstanceRollback.validateRollbackResponses(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) + verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) + verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) + //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) + } + + @Test + //@Ignore + public void validateRollbackResponses_FullRollback() { + + Map rollbackData = new HashMap(); + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + + println "************ validateRollbackResponses_FullRollback() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "workflowException")).thenReturn(null) + when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) + when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) + + DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() + DoCreateNetworkInstanceRollback.validateRollbackResponses(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) + verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) + + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateNetworkInstanceRollback") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateNetworkInstanceRollback") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateNetworkInstanceRollback") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateNetworkInstanceRollback") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..d0b87b3737 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy @@ -0,0 +1,3988 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByName_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; +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.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.apache.commons.lang3.* + +@RunWith(MockitoJUnitRunner.class) +class DoCreateNetworkInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + def utils = new MsoUtils() + String Prefix="CRENWKI_" + +// ---- Start XML Zone ---- + String xmlIncomingRequest = + """ + + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + CREATE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + dvs-slcp3-01 + 3008 + MNS-25180-L-01-dmz_direct_net_1 + true + + + 1 + 0 + + + """ + + String expectedXMLNetworkRequest = +""" + + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + CREATE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + dvs-slcp3-01 + 3008 + MNS-25180-L-01-dmz_direct_net_1 + true + + + 1 + 0 + + +""" + + String expectedXMLNetworkInputs = +""" + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + dvs-slcp3-01 + 3008 + MNS-25180-L-01-dmz_direct_net_1 + true +""" + + String networkXMLOutputs = +"""""" + +// ---- End XML Zone ---- + +// ---- Start JSON Zone ---- + // JSON format Input + String jsonIncomingRequest = + """{ "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "someUserParam1", + "value": "someValue1" + } + ] + } + }}""" + + String expectedJSONNetworkRequest = + """ + + null + CREATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 + + + someValue1 + +""" + + String expectedJSONNetworkInputs = +""" + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 +""" + + String networkJSONOutputs = +""" + networkId + MNS-25180-L-01-dmz_direct_net_1 + """ + +// ---- End JSON Zone ---- + +// ---- Start vPIR Zone ---- + // expectedNetworkRequest + String expectedvIPRNetworkRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CREATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + + + HNGW Protected OAM + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 1.0 + + + 1702 + + +""" + + String expectedvIPRNetworkInputs = +""" + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + + + HNGW Protected OAM + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 1.0 + + + 1702 +""" + + String networkvIPROutputs = +""" + networkId + MNS-25180-L-01-dmz_direct_net_1 + """ + +// ---- End vPIR Zone ---- + + String vnfRequestFakeRegion = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + CREATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 7dd5365547234ee8937416c65507d266 + + + 1 + 0 + +""" + + // expectedNetworkRequest + String expectedNetworkRequest_Outputs = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + CREATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + + + MNS-25180-L-01-dmz_direct_net_1 + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + + + 1 + 0 + +""" + + + // expectedNetworkRequest + String networkInputs_404 = + """ + myOwn_Network + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + """ + + String networkInputs = + """ + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf +""" + + + + String queryAAIResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-create + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + +""" + + String queryIdAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + Contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + pending-create + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + subnetName + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + subnetName + + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + +""" + +String queryIdAIIResponse_segmentation = +""" + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + Contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + pending-create + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + subnetName + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + subnetName + + + + + + 1 + 1498507569188 + + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + +""" + +String queryIdAIIResponse_Ipv4 = +""" + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + Contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + pending-create + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + ipv4 + pending-create + true + subnetName + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + ipv4 + pending-create + true + subnetName + + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + +""" + +String queryIdAIIResponse_SRIOV = +""" + + 6cb1ae5a-d2db-4eb6-97bf-d52a506a53d8 + MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17 + SR_IOV_Provider2_1 + HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1 + AIC_SR_IOV + false + + 1487336177672 + PendingCreate + f70d7a32-0ac8-4bd5-a0fb-3c9336540d78 + 1.0 + Physnet21 + true + false + false + + + 10437 + MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17_S0 + 192.168.6.1 + 192.168.6.0 + 26 + 4 + PendingCreate + true + 192.168.6.3 + 192.168.6.62 + 1487336177359 + + + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn16/tenants/tenant/6accefef3cb442ff9e644d589fb04107 + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn16 + + + tenant.tenant-id + 6accefef3cb442ff9e644d589fb04107 + + + tenant.tenant-name + MSO_TEST_1702_A + + + + cloud-region + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn16 + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn16 + + + cloud-region.owner-defined-type + lcp + + + + service-instance + https://aai-ext1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/51d8336b-a993-4afe-a5fc-10b3afbd6560 + + customer.global-customer-id + MSO_1610_ST + + + service-subscription.service-type + MSO-dev-service-type + + + service-instance.service-instance-id + 51d8336b-a993-4afe-a5fc-10b3afbd6560 + + + service-instance.service-instance-name + HnportalProviderNetwork_17 + + + +""" + + String queryIdAIIResponseTestScenario01 = + """ + + 4da55fe4-7a9e-478c-a434-8a98d62265ab + GN_EVPN_direct_net_0_ST1 + CONTRAIL30_BASIC + GN_EVPN_direct + contrail + false + 9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + 1465398611 + pending-create + networkName + false + true + false + + + cb1a7b47-5428-44c9-89c2-8b17541c3228 + 108.239.40.1 + 108.239.40.0 + 28 + 4 + pending-create + true + 108.239.40.0 + 108.239.40.0 + 1465398611 + subnetName + + + + e2cc7c14-90f0-4205-840d-b4e07f04e621 + 2606:ae00:2e01:604::1 + 2606:ae00:2e01:604:: + 64 + 6 + pending-create + true + 2606:ae00:2e01:604:: + 2606:ae00:2e01:604:: + 1465398611 + subnetName + + + + + + 416 + 4132176 + + + + cloud-region + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ + + + cloud-region.cloud-region-id + AAIAIC25 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.owner-defined-type + + + + + tenant + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ + + tenant.tenant-id + 4ae1d3446a4c48b2bec44b6cfba06d68 + + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + AAIAIC25 + + + tenant.tenant-name + Ruchira Contrail 3.0 test + + + + vpn-binding + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + GN_EVPN_direct_net_0_ST1 + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + String queryIdAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-create + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + subnetName + + + + + + +""" + + String queryNameAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-create + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + + """ + + String queryNameAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + + + +""" + + String queryVpnBindingAAIResponse = + """ + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/ + + l3-network.network-id + 689ec39e-c5fc-4462-8db2-4f760763ad28 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/ + + l3-network.network-id + 1a49396b-19b3-40a4-8792-aa2fbd0f0704 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + +""" + + String createDBRequestError01 = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error unexpectedly from SDN-C. + + FAILED + <network-id></network-id><network-name></network-names> + + + """ + + String createDBRequest_Outputs = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Network successfully created. + + COMPLETED + 100 + <network-id>networkId</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> + networkId + + +""" + + String createNetworkRequest = + """ + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e222 + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + refFQDN1 + refFQDN2 + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_generated + +""" + +String createNetworkRequestAlaCarte = +""" + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + refFQDN1 + refFQDN2 + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + someValue1 + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_generated + +""" + +String createNetworkRequest_SRIOV = +""" + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 6cb1ae5a-d2db-4eb6-97bf-d52a506a53d8 + MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17 + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e222 + AIC_SR_IOV + + Physnet21 + + + + + 192.168.6.3 + 192.168.6.62 + + 192.168.6.0/26 + true + 192.168.6.1 + 4 + 10437 + MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17_S0 + + true + true + false + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_generated + +""" + + String createNetworkRequest_noPhysicalName = + """ + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + null + + messageId_generated + +""" + + String createNetworkResponseREST = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + true + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + + messageId_generated +""" + + String createRollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String createNetworkResponse = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + true + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + CONTRAIL_EXTERNAL + false + c4f4e878-cde0-4b15-ae9a-bda857759cea + 7dd5365547234ee8937416c65507d266 + +""" + + String updateContrailAAIPayloadRequest = + """ + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + Contrail + c4f4e878-cde0-4b15-ae9a-bda857759cea + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + Created + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Created + true + subnetName + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Created + true + subnetName + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + +String updateContrailAAIPayloadRequest_segmentation = +""" + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + Contrail + c4f4e878-cde0-4b15-ae9a-bda857759cea + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + Created + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Created + true + subnetName + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Created + true + subnetName + + + + + 1 + 1498507569188 + + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + String updateContrailAAIResponse = + """ + + + + + + + + +""" + + String createNetworkErrorResponse = + """ + 680bd458-5ec1-4a16-b77c-509022e53450INTERNAL + 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data + true + """ + + + String networkException500 = + """soap:VersionMismatch"http://org.openecomp.mso/network", the namespace on the "createNetworkContrail" element, is not a valid SOAP version.""" + + String aaiResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + + + """ + + String assignSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + assign + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + networkId + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String assignSDNCRequest_decodeUrlLink = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + assign + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + VIRTUAL USP + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + networkId + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String assignRpcSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + assign + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + 1.0 + HNGW Protected OAM + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + globalId_45678905678 + MSO_1610_dev + + + networkId + CONTRAIL_EXTERNAL + + sn5256d1-5a33-55df-13ab-12abad84e764 + sn5256d1-5a33-55df-13ab-12abad84e222 + sn5256d1-5a33-55df-13ab-12abad84e111 + 1 + CONTRAIL_EXTERNAL + + + + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + + + +""" + +String activateSDNCRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + activate + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + 1.0 + HNGW Protected OAM + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + globalId_45678905678 + MSO_1610_dev + + + networkId + CONTRAIL_EXTERNAL + + sn5256d1-5a33-55df-13ab-12abad84e764 + sn5256d1-5a33-55df-13ab-12abad84e222 + sn5256d1-5a33-55df-13ab-12abad84e111 + 1 + CONTRAIL_EXTERNAL + + + + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + + + +""" + +String assignResponse = +""" 006927ca-f5a3-47fd-880c-dfcbcd81a093 200 OK 200006927ca-f5a3-47fd-880c-dfcbcd81a093Ynotsurewecarea9a77d5a-123e-4ca2-9eb9-0b015d2ee0fbGN_EVPN_direct_net_0_ST_noGW8abc633a-810b-4ca5-8b3a-09511d13a2ce """ + + String sdncRollbackRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String sdncRpcRollbackRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + unassign + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DeleteNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + 1.0 + HNGW Protected OAM + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + globalId_45678905678 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + sn5256d1-5a33-55df-13ab-12abad84e764 + sn5256d1-5a33-55df-13ab-12abad84e222 + sn5256d1-5a33-55df-13ab-12abad84e111 + 1 + CONTRAIL_EXTERNAL + + + + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + + + +""" + +String sdncActivateRollbackRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + deactivate + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DeleteNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + 1.0 + HNGW Protected OAM + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + globalId_45678905678 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + sn5256d1-5a33-55df-13ab-12abad84e764 + sn5256d1-5a33-55df-13ab-12abad84e222 + sn5256d1-5a33-55df-13ab-12abad84e111 + 1 + CONTRAIL_EXTERNAL + + + + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + + + +""" + + String sdncAdapterWorkflowResponse = + """ + + + 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 + 200 + OK + + <output xmlns="com:att:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>MNS-25180-L-01-dmz_direct_net_1</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + +""" + + + String sdncAdapterWorkflowResponse_Error = + """ + + + + 400 + Error writing to l3-netework + Y + c79240d8-34b5-4853-af69-2021928dba00 + + + +""" + + String expected_sdncAdapterWorkflowResponse_Error = + """ + + + + 400 + Error writing to l3-netework + Y + c79240d8-34b5-4853-af69-2021928dba00 + + + +""" + + String sdncAdapterWorkflowFormattedResponse = + """ + + + 00703dc8-71ff-442d-a4a8-3adc5beef6a9 + 200 + Y + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + notsurewecare + + + +""" + +String sdncAdapterWorkflowAssignResponse = +""" + + + 79ec9006-3695-4fcc-93a8-be6f9e248beb + 200 + OK + + + + + 79ec9006-3695-4fcc-93a8-be6f9e248beb + + f805ec2b-b4d8-473e-8325-67f110139e5d + + 200 + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + restconf/config/GENERIC-RESOURCE-API:services/service/f805ec2b-b4d8-473e-8325-67f110139e5d/service-data/networks/network/f7e4db56-aab5-4065-8e65-cec1cd1de24f + + Y + + + +""" + + String rollbackNetworkRequest = +""" + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String rollbackActivateSDNCRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String rollbackSDNCRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +// - - - - - - - - + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "networkRequest", "") + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", null) + verify(mockExecution).setVariable(Prefix + "networkInputs", "") + //verify(mockExecution).setVariable(Prefix + "requestId", "") + verify(mockExecution).setVariable(Prefix + "messageId", "") + verify(mockExecution).setVariable(Prefix + "source", "") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") + verify(mockExecution).setVariable(Prefix + "serviceInstanceId","") + verify(mockExecution).setVariable("GENGS_type","") + verify(mockExecution).setVariable(Prefix + "rsrc_endpoint", null) + verify(mockExecution).setVariable(Prefix + "networkOutputs", "") + verify(mockExecution).setVariable(Prefix + "networkId","") + verify(mockExecution).setVariable(Prefix + "networkName","") + + // AAI query Name + verify(mockExecution).setVariable(Prefix + "queryNameAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryNameAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiNameReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isAAIqueryNameGood", false) + + // AAI query Cloud Region + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest","") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionReturnCode","") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionResponse","") + verify(mockExecution).setVariable(Prefix + "cloudRegionPo","") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc","") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", false) + + // AAI query Id + verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryIdAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "") + + // AAI query vpn binding + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") + verify(mockExecution).setVariable(Prefix + "vpnBindings", null) + verify(mockExecution).setVariable(Prefix + "vpnCount", 0) + verify(mockExecution).setVariable(Prefix + "routeCollection", "") + + // AAI query network policy + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") + verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", null) + verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 0) + verify(mockExecution).setVariable(Prefix + "networkCollection", "") + + // AAI query route table reference + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") + verify(mockExecution).setVariable(Prefix + "networkTableRefUriList", null) + verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 0) + verify(mockExecution).setVariable(Prefix + "tableRefCollection", "") + + // AAI requery Id + verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest","") + verify(mockExecution).setVariable(Prefix + "requeryIdAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "") + + // AAI update contrail + verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest","") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest","") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "createNetworkRequest", "") + verify(mockExecution).setVariable(Prefix + "createNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") + //verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "networkReturnCode", "") + //verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", false) + + verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "assignSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") + //verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "sdncReturnCode", "") + //verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", false) + verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + + verify(mockExecution).setVariable(Prefix + "activateSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "activateSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCRequest", "") + //verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "sdncActivateReturnCode", "") + //verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isSdncActivateRollbackNeeded", false) + verify(mockExecution).setVariable(Prefix + "sdncActivateResponseSuccess", false) + + verify(mockExecution).setVariable(Prefix + "orchestrationStatus", "") + verify(mockExecution).setVariable(Prefix + "isVnfBindingPresent", false) + verify(mockExecution).setVariable(Prefix + "Success", false) + + verify(mockExecution).setVariable(Prefix + "isException", false) + + } + + @Test + //@Ignore + public void preProcessRequest_vIPR_NetworkRequest() { + + println "************ preProcessRequest_Payload ************* " + + def networkModelInfo = """{"modelUuid": "sn5256d1-5a33-55df-13ab-12abad84e111", + "modelName": "CONTRAIL_EXTERNAL", + "modelType": "CONTRAIL_EXTERNAL", + "modelVersion": "1", + "modelCustomizationUuid": "sn5256d1-5a33-55df-13ab-12abad84e222", + "modelInvariantUuid": "sn5256d1-5a33-55df-13ab-12abad84e764" + }""".trim() + + def serviceModelInfo = """{"modelUuid": "36a3a8ea-49a6-4ac8-b06c-89a54544b9b6", + "modelName": "HNGW Protected OAM", + "modelType": "service", + "modelVersion": "1.0", + "modelInvariantUuid": "fcc85cb0-ad74-45d7-a5a1-17c8744fdb71" + }""".trim() + + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + + // Pre-defined value, testing Only + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + // Inputs: + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("networkId")).thenReturn("networkId") // optional + when(mockExecution.getVariable("networkName")).thenReturn("MNS-25180-L-01-dmz_direct_net_1") // optional + when(mockExecution.getVariable("productFamilyId")).thenReturn("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + when(mockExecution.getVariable("networkModelInfo")).thenReturn("CONTRAIL_EXTERNAL") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("tenantId")).thenReturn("7dd5365547234ee8937416c65507d266") + when(mockExecution.getVariable("failIfExists")).thenReturn("false") + when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) + when(mockExecution.getVariable("serviceModelInfo")).thenReturn(serviceModelInfo) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable("action")).thenReturn("CREATE") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "CREATE") + verify(mockExecution).setVariable(Prefix + "networkId","") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedvIPRNetworkRequest) + verify(mockExecution, atLeast(1)).setVariable(Prefix + "rollbackEnabled", false) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedvIPRNetworkInputs) + //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("mso-service-instance-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "VID") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable(Prefix + "serviceInstanceId","f70e927b-6087-4974-9ef8-c5e4d5847ca4") + verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") + //verify(mockExecution, atLeast(1)).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution, atLeast(1)).setVariable("msoRequestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("mso-service-instance-id","88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "networkId","") + verify(mockExecution).setVariable(Prefix + "networkOutputs", networkvIPROutputs) + verify(mockExecution).setVariable(Prefix + "networkName","") + + } + + @Test + //@Ignore + public void preProcessRequest_JSON_NetworkRequest() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + + // Pre-defined value, testing Only + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + // Inputs: + // when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("requestAction")).thenReturn("CREATE") + when(mockExecution.getVariable("networkId")).thenReturn("networkId") // optional + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) // JSON format + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") // 1610 default + when(mockExecution.getVariable("disableRollback")).thenReturn(true) + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "CREATE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedJSONNetworkRequest) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedJSONNetworkInputs) + //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "VID") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable(Prefix + "serviceInstanceId","f70e927b-6087-4974-9ef8-c5e4d5847ca4") + verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") + //verify(mockExecution, atLeast(1)).setVariable("msoRequestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("mso-service-instance-id","88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "networkId","") + verify(mockExecution).setVariable(Prefix + "networkOutputs", networkJSONOutputs) + verify(mockExecution).setVariable(Prefix + "networkName","") + + + } + + @Test + //@Ignore + public void preProcessRequest_XML_NetworkRequest() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + + // Pre-defined value, testing Only + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + // Inputs: + // when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(xmlIncomingRequest) // XML format + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedXMLNetworkRequest) + verify(mockExecution).setVariable("action", "CREATE") + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", true) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedXMLNetworkInputs) + //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "PORTAL") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable(Prefix + "serviceInstanceId","MNS-25180-L-01-dmz_direct_net_1") + verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") + //verify(mockExecution).setVariable("mso-service-instance-id","88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution, atLeast(1)).setVariable(Prefix + "networkId","") + verify(mockExecution).setVariable(Prefix + "networkOutputs", networkXMLOutputs) + verify(mockExecution).setVariable(Prefix + "networkName","") + + } + + + + @Test + //@Ignore + public void prepareCreateNetworkRequest() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + + verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest) + + } + + + @Test + //@Ignore + public void prepareCreateNetworkRequest_Ipv4() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse_Ipv4) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + + verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest) + + } + + @Test + //@Ignore + public void prepareCreateNetworkRequest_AlaCarte() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedJSONNetworkRequest) + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + + verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequestAlaCarte) + + } + + @Test + //@Ignore + public void prepareCreateNetworkRequest_SRIOV() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse_SRIOV) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + + verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest_SRIOV) + + } + + + @Test + //@Ignore + public void prepareSDNCRequest() { + + println "************ prepareSDNCRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareSDNCRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", assignSDNCRequest) + + } + + @Test + //@Ignore + public void prepareSDNCRequest_decodeUrlLink() { + + println "************ prepareSDNCRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/VIRTUAL%20USP/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareSDNCRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", assignSDNCRequest_decodeUrlLink) + + } + + @Test + //@Ignore + public void prepareRpcSDNCRequest() { + + println "************ prepareRpcSDNCRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareRpcSDNCRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", assignRpcSDNCRequest) + + } + + @Test + //@Ignore + public void prepareSDNCRollbackRequest() { + + println "************ prepareSDNCRollbackRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(assignResponse) + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("8abc633a-810b-4ca5-8b3a-09511d13a2ce") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareSDNCRollbackRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", sdncRollbackRequest) + + } + + @Test + //@Ignore + public void prepareRpcSDNCActivateRequest() { + + println "************ prepareRpcSDNCActivateRequest ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareRpcSDNCActivateRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "activateSDNCRequest", activateSDNCRequest) + + } + + + @Test + //@Ignore + public void prepareRpcSDNCRollbackRequest() { + + println "************ prepareRpcSDNCRollbackRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(assignResponse) + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("8abc633a-810b-4ca5-8b3a-09511d13a2ce") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareRpcSDNCRollbackRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", sdncRpcRollbackRequest) + + } + + @Test + //@Ignore + public void prepareRpcSDNCActivateRollback() { + + println "************ prepareRpcSDNCActivateRollback ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "activateSDNCResponse")).thenReturn(assignResponse) + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("8abc633a-810b-4ca5-8b3a-09511d13a2ce") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareRpcSDNCActivateRollback(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + //verify(mockExecution).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("mso-service-instance-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCRequest", sdncActivateRollbackRequest) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkName_200() { + + println "************ callRESTQueryAAINetworkName ************* " + + WireMock.reset(); + MockGetNetworkByName("MNS-25180-L-01-dmz_direct_net_1", "CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(networkInputs) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkName(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryNameAAIRequest", "http://localhost:8090/aai/v8/network/l3-networks/l3-network?network-name=MNS-25180-L-01-dmz_direct_net_1") + + verify(mockExecution).setVariable(Prefix + "aaiNameReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "orchestrationStatus", "PENDING-CREATE") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkName_404() { + + println "************ callRESTQueryAAINetworkName ************* " + + WireMock.reset(); + MockGetNetworkByName_404("CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml", "myOwn_Network"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(networkInputs_404) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkName(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryNameAAIRequest", "http://localhost:8090/aai/v8/network/l3-networks/l3-network?network-name=myOwn_Network") + verify(mockExecution).setVariable(Prefix + "aaiNameReturnCode", "404") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkId_200() { + + println "************ callRESTQueryAAINetworkId ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowAssignResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkId(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion30_200() { + + println "************ callRESTQueryAAICloudRegion30_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion25_200() { + + println "************ callRESTQueryAAICloudRegion25_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedvIPRNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion_NotFound() { + + println "************ callRESTQueryAAICloudRegionFake ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion_404("MDTWNJ21") + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestFakeRegion) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") + verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") + verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_vpn-binding_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_vpn-binding_uri")).thenReturn("") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "vpnCount", 2) + verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_vpn-binding_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_vpn-binding_uri")).thenReturn("") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "vpnCount", 1) + verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + //when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "vpnCount", 2) + verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_NotPresent() { + + println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "vpnCount", 0) + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", aaiVpnResponseStub) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkPolicy_200() { + + println "************ callRESTQueryAAINetworkPolicy_200 ************* " + + WireMock.reset(); + MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_policy_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkPolicy(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 1) + verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest", "http://localhost:8090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg?depth=all") + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkTableRef_200() { + + println "************ callRESTQueryAAINetworkTableRef_200 ************* " + + WireMock.reset(); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_table_reference_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_table_reference_uri")).thenReturn("") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_route_table_reference_uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkTableRef(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 2) + verify(mockExecution).setVariable(Prefix + "networkTableRefUriList", ['/aai/v8/network/route-table-references/route-table-reference/refFQDN1','/aai/v8/network/route-table-references/route-table-reference/refFQDN2']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIRequest", "http://localhost:8090/aai/v8/network/route-table-references/route-table-reference/refFQDN1?depth=all") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTReQueryAAINetworkId_200() { + + println "************ callRESTReQueryAAINetworkId ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + //old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTReQueryAAINetworkId(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTUpdateContrailAAINetworkREST_200() { + + println "************ callRESTUpdateContrailAAINetwork ************* " + + WireMock.reset(); + MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("false") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) + verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") + //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) + verify(mockExecution).setVariable(Prefix + "isPONR", true) + + } + + @Test + //@Ignore + public void callRESTUpdateContrailAAINetworkREST_200_segmentation() { + + println "************ callRESTUpdateContrailAAINetwork ************* " + + WireMock.reset(); + MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse_segmentation) + when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("false") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest_segmentation) + verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") + //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) + verify(mockExecution).setVariable(Prefix + "isPONR", true) + + } + + + + @Test + //@Ignore + public void validateCreateNetworkResponseREST() { + + println "************ validateNetworkResponse ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) + when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') + + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.validateCreateNetworkResponse(mockExecution) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "createNetworkResponse", createNetworkResponseREST) + verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", true) + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", createRollbackNetworkRequest) + + } + + @Test + //@Ignore + public void validateCreateNetworkResponseREST_Error() { + + println "************ validateNetworkResponse ************* " + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(networkException500) + when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('500') + + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + try { + DoCreateNetworkInstance.validateCreateNetworkResponse(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(workflowException, any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateSDNCResponse() { + + println "************ validateSDNCResponse ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) + + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + try { + DoCreateNetworkInstance.validateSDNCResponse(mockExecution) + verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + //verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + + } + + @Test + //@Ignore + public void validateSDNCResponse_Error() { + + println "************ validateSDNCResponse ************* " + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from SNDC Adapter: HTTP Status 500.") + + //ExecutionEntity mockExecution = mock(ExecutionEntity.class) + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) + when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + try { + DoCreateNetworkInstance.validateSDNCResponse(mockExecution) + } catch (Exception ex) { + println " Graceful Exit! - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + //verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + + } + + @Test + //@Ignore + public void validateRpcSDNCActivateResponse() { + + println "************ validateRpcSDNCActivateResponse ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "activateSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mockExecution.getVariable(Prefix + "sdncActivateReturnCode")).thenReturn("200") + + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + try { + DoCreateNetworkInstance.validateRpcSDNCActivateResponse(mockExecution) + verify(mockExecution).setVariable(Prefix + "isSdncActivateRollbackNeeded", true) + + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + //verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + + } + + @Test + //@Ignore + public void prepareRollbackData() { + + println "************ prepareRollbackData() ************* " + + + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn(rollbackActivateSDNCRequest) + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackNetworkRequest) + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareRollbackData(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + @Test + @Ignore + public void postProcessResponse() { + + println "************ postProcessResponse() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "isException")).thenReturn(false) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(sdncRpcRollbackRequest) + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn(sdncActivateRollbackRequest) + + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.postProcessResponse(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", true) + + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy deleted file mode 100644 index e9c27b040a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy +++ /dev/null @@ -1,218 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure.scripts; - -import static org.junit.Assert.* -import static org.mockito.Mockito.* - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Assert -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest - - -@RunWith(MockitoJUnitRunner.class) -class DoCreateVfModuleVolumeV1Test extends MsoGroovyTest { - - def volumeRequest = -""" - - 123abc - d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 - CREATE_VF_MODULE_VOL - SoapUI-bns-create-base-vol-1001-1 - - - Test/vSAMP12 - vSAMP12::base::module-0 - true - 2.0 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MDTWNJ21 - 897deadc2b954a6bac6d3c197fb3525e - MSOTESTVOL101a-vSAMP12_base_vol_module-0 - - - - value1" - value2" - value3" - -""" - - def genericVnfResponseXml = """ - - TEST-VNF-ID-0123 - 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 - - - - - - -""" - def String expectedCreateVnfRequestXml = """ - MDTWNJ21 - 897deadc2b954a6bac6d3c197fb3525e - TEST-VNF-ID-0123 - STMTN5MMSC20 - test-vol-group-id-123 - MSOTESTVOL101a-vSAMP12_base_vol_module-0 - Test/vSAMP12 - 2.0 - vSAMP12::base::module-0 - - - - vnf_id - TEST-VNF-ID-0123 - - - vnf_name - STMTN5MMSC20 - - - vf_module_id - test-vol-group-id-123 - - - vf_module_name - MSOTESTVOL101a-vSAMP12_base_vol_module-0 - - - param1 - value1 - - - param2 - value2 - - - param3 - value3 - - - true - true - true - - d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - 111 - http://localhost:28080/mso/WorkflowMessage/12345678 - -""" - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - @Test - public void TestPreProcessRequest() { - - ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV1') - - when(mockExecution.getVariable("DoCreateVfModuleVolumeV1Request")).thenReturn(volumeRequest) - when(mockExecution.getVariable("vnf-id")).thenReturn('test-vnf-id-123') - when(mockExecution.getVariable("volume-group-id")).thenReturn('test-volume-group-id-123') - when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123') - - DoCreateVfModuleVolumeV1 myprocess = new DoCreateVfModuleVolumeV1() - myprocess.preProcessRequest(mockExecution, 'true') - - verify(mockExecution).setVariable('DCVFMODVOLV1_serviceId', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') - verify(mockExecution).setVariable('DCVFMODVOLV1_source', 'SoapUI-bns-create-base-vol-1001-1') - verify(mockExecution, times(7)).setVariable(anyString(), anyString()) - } - - @Test - public void TestPrepareVnfAdapterCreateRequest() { - - ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV1') - - when(mockExecution.getVariable("DCVFMODVOLV1_Request")).thenReturn(volumeRequest) - when(mockExecution.getVariable("DCVFMODVOLV1_requestId")).thenReturn('d8d4fcfa-fd7e-4413-b19d-c95aa67291b8') - when(mockExecution.getVariable("DCVFMODVOLV1_serviceId")).thenReturn('a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') - when(mockExecution.getVariable("DCVFMODVOLV1_AAIQueryGenericVfnResponse")).thenReturn(genericVnfResponseXml) - when(mockExecution.getVariable("DCVFMODVOLV1_rollbackEnabled")).thenReturn(true) - when(mockExecution.getVariable("volume-group-id")).thenReturn('test-vol-group-id-123') - when(mockExecution.getVariable("URN_mso_workflow_message_endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') - when(mockExecution.getVariable("URN_mso_use_qualified_host")).thenReturn(true) - - DoCreateVfModuleVolumeV1 myprocess = new DoCreateVfModuleVolumeV1() - myprocess.prepareVnfAdapterCreateRequest(mockExecution, 'true') - - // Capture the arguments to setVariable - ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); - ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); - - verify(mockExecution, times(2)).setVariable(captor1.capture(), captor2.capture()) - - List arg2List = captor2.getAllValues() - String createVnfRequestXml = arg2List.get(0) - - //replace messageID value because it is random generated - createVnfRequestXml = createVnfRequestXml.replaceAll("(.+?)", "111") - .replaceAll("(.+?)", "http://localhost:28080/mso/WorkflowMessage/12345678") - - Assert.assertEquals(expectedCreateVnfRequestXml.trim(), createVnfRequestXml.trim()) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..96a84deb26 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy @@ -0,0 +1,323 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.delegate.BpmnError +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.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.junit.Before +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith + +import static org.junit.Assert.*; + +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.* + + +@RunWith(MockitoJUnitRunner.class) +class DoDeleteNetworkInstanceRollbackTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + def utils = new MsoUtils() + String Prefix="DELNWKIR_" + + + String rollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String rollbackDeActivateSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + activate + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String rollbackSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "WorkflowException", null) + + verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", null) + verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) + verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "Success", false) + verify(mockExecution).setVariable(Prefix + "fullRollback", false) + + } + + @Test + //@Ignore + public void preProcessRequest() { + + println "************ preProcessRequest ************* " + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + Map rollbackData = new HashMap(); + rollbackData.put("rollbackDeactivateSDNCRequest", rollbackDeActivateSDNCRequest) + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() + DoDeleteNetworkInstanceRollback.preProcessRequest(mockExecution) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + + @Test + //@Ignore + public void validateRollbackResponses_Good() { + + WorkflowException workflowException = new WorkflowException("DoDeleteNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowException = new WorkflowException("DoDeleteNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC deactivate rollback completed. + PO Network rollback completed. + SNDC unassign rollback completed.") + + println "************ validateRollbackResponses_Good() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) + + DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() + DoDeleteNetworkInstanceRollback.validateRollbackResponses(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) + verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) + verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) + //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) + } + + @Test + //@Ignore + public void validateRollbackResponses_FullRollback() { + + Map rollbackData = new HashMap(); + rollbackData.put("rollbackDeactivateSDNCRequest", rollbackDeActivateSDNCRequest) + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + + println "************ validateRollbackResponses_FullRollback() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(null) + when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) + when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) + + DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() + DoDeleteNetworkInstanceRollback.validateRollbackResponses(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) + verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) + + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteNetworkInstanceRollback") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteNetworkInstanceRollback") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoDeleteNetworkInstanceRollback") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteNetworkInstanceRollback") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy new file mode 100644 index 0000000000..0f87b6400e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy @@ -0,0 +1,1929 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +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.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.apache.commons.lang3.* + + +@RunWith(MockitoJUnitRunner.class) +class DoDeleteNetworkInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + def utils = new MsoUtils() + String Prefix="DELNWKI_" + + String incomingJsonRequest = + """{ "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "HSL_direct_net_2", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [] + } + }""" + + String expectedDoDeleteNetworkInstanceRequest = + """{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "HSL_direct_net_2", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [] + } + }""" + + // expectedVnfRequest + String expectedNetworkRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 + + +""" + + String expectedVperNetworkRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + + + + + + + + + 1702 + + +""" + + String expected_networkInput = + """ + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 +""" + + String expectedVper_networkInput = +""" + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + + + + + + + + + 1702 +""" + +// emptyRegionVnfRequest +String emptyRegionVnfRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + e81d842d3e8b45c5a59f57cd76af3aaf + + + 0 + +""" + +String vnfRequestCloudRegionNotFound = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + e81d842d3e8b45c5a59f57cd76af3aaf + + + 0 + +""" + + String vnfPayload = + """ + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + + + 0 + + +""" + + String vnfPayload_MissingId = +""" + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + + CONTRAIL_BASIC + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + + + 0 + + +""" + + String vnfRequestRESTPayload = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + PORTAL + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + + + id + name + + + 0 + + """ + + +String incomingRequestMissingCloudRegion = +"""{ "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "HSL_direct_net_2", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [] + } + }""" + + String expectedNetworkRequestMissingId = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + + HSL_direct_net_2 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 + + +""" + +String expectedNetworkRequestMissingCloudRegion = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + null + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 + + +""" + + // vnfRESTRequest + String vnfRESTRequest = +""" + + + + DELETE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + + + + + + +""" + + String networkInputs = + """ + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf +""" + +String networkInputsNoType = +""" + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf +""" + + String networkInputsMissingId = + """ + + HSL_direct_net_2 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 +""" + +String networkInputsMissingCloudRegion = +""" + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + null + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 +""" + + String MissingIdFault = "Invalid value or missing network-id element" + String MissingRegionFault = "Invalid value or missing 'aic-cloud-region' element" + + String invalidWorkflowException = """ + Invalid value of network-id element + 2500 + """ + + + String queryAAIResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + + +""" + + String deleteNetworkRequest = + """ + + + + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + CONTRAIL_BASIC + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + 0 + + + +""" + +String deleteNetworkRESTRequest = +""" + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + CONTRAIL_BASIC + sn5256d1-5a33-55df-13ab-12abad84e222 + true + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_value + +""" + +String deleteNetworkRESTRequestAlaCarte = +""" + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + CONTRAIL_BASIC + f21df226-8093-48c3-be7e-0408fcda0422 + true + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_value + +""" + + String deleteNetworkResponse_noRollback = +""" + true + +""" + + String deleteNetworkResponse = + """ + true + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + + """ + + String deleteRollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String deleteNetworkResponseFalseCompletion = + """ + false + """ + + String deleteNetworkErrorResponse = + """ + +680bd458-5ec1-4a16-b77c-509022e53450INTERNAL +400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data +true + +""" + + String deleteNetworkWorkflowException = + """ + Received error from Network Adapter: 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data + 7020 + """ + +String aaiWorkflowException = +""" + Bpmn error encountered in DoDeleteNetworkInstance flow. Unexpected Response from AAI Adapter - org.apache.http.conn.HttpHostConnectException: Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect + 2500 + """ + + String aaiResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + cloud-region + cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP/ + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + RDM2WAGPLCP + + + + + +""" + +String aaiResponseWithRelationship = +""" + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + vf-module + https://aai-app-e2e.ecomp.cci.com:8443/aai/v8/network/generic-vnfs/generic-vnf/105df7e5-0b3b-49f7-a837-4864b62827c4/vf-modules/vf-module/d9217058-95a0-49ee-b9a9-949259e89349/ + + generic-vnf.vnf-id + 105df7e5-0b3b-49f7-a837-4864b62827c4 + + + vf-module.vf-module-id + d9217058-95a0-49ee-b9a9-949259e89349 + + + + generic-vnf + https://aai-app-e2e.test.com:8443/aai/v8/network/generic-vnfs/generic-vnf/45f822d9-73ca-4255-9844-7cef401bbf47/ + + generic-vnf.vnf-id + 45f822d9-73ca-4255-9844-7cef401bbf47 + + + generic-vnf.vnf-name + zrdm1scpx05 + + + + + +""" + + String deleteSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + delete + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DisconnectNetworkRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + CONTRAIL_BASIC + HSL_direct_net_2 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String deleteRpcSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + unassign + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DeleteNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + 1.0 + HNGW Protected OAM + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + globalId_45678905678 + + + + networkId + CONTRAIL_EXTERNAL + + sn5256d1-5a33-55df-13ab-12abad84e764 + sn5256d1-5a33-55df-13ab-12abad84e222 + sn5256d1-5a33-55df-13ab-12abad84e111 + 1 + CONTRAIL_EXTERNAL + + + + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + + + +""" + + String sdncAdapaterDeactivateRollback = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + activate + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + 1.0 + HNGW Protected OAM + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + globalId_45678905678 + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + CONTRAIL_EXTERNAL + + sn5256d1-5a33-55df-13ab-12abad84e764 + sn5256d1-5a33-55df-13ab-12abad84e222 + sn5256d1-5a33-55df-13ab-12abad84e111 + 1 + CONTRAIL_EXTERNAL + + + + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + + + +""" + String sdncAdapterWorkflowResponse = + """ + + + 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 + 200 + OK + + <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + + """ + + String sdncAdapterWorkflowResponse_404 = + """ + <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>404</response-code><response-message>Service instance not found in config tree</response-message><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>MNS-25180-L-01-dmz_direct_net_1</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> +""" + + String expected_sdncAdapterWorkflowFormattedResponse_404 = +""" + + + 00703dc8-71ff-442d-a4a8-3adc5beef6a9 + 404 + Service instance not found in config tree + Y + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MNS-25180-L-01-dmz_direct_net_1 + notsurewecare + + + +""" + + String sdncAdapterWorkflowFormattedResponse = + """ + + + 19174929-3809-49ca-89eb-17f84a035389 + 200 + Y + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + HSL_direct_net_2 + notsurewecare + + + +""" + +String sdncAdapterWorkflowFormattedResponse_404 = +""" + + + 00703dc8-71ff-442d-a4a8-3adc5beef6a9 + 404 + Service instance not found in config tree + Y + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MNS-25180-L-01-dmz_direct_net_1 + notsurewecare + + + +""" + + String invalidRequest = "Invalid value of network-id element" + + + + String sndcWorkflowException = + """ + Received error from SDN-C: No availability zone available + 5300 + 200 +""" + + String sndcWorkflowErrorResponse = + """ + Received error from SDN-C: + <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>404</response-code><response-message>Service instance not found in config tree</response-message><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>MNS-25180-L-01-dmz_direct_net_1</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + + 5300 + """ + + String unexpectedErrorEncountered = + """ + bpel error deleting network + 5300 + """ + + + // expectedVnfRequest + String inputViprSDC_NetworkRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + DELETE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + CONTRAIL_EXTERNAL + + + HNGW Protected OAM + 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 + fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 + 1.0 + + service + + 1702 + + +""" +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + //@Ignore + public void preProcessRequest_Json() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("DELETE") + when(mockExecution.getVariable("networkId")).thenReturn("bdc5efe8-404a-409b-85f6-0dcc9eebae30") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + //when(mockExecution.getVariable("networkId")).thenReturn("") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(incomingJsonRequest) + when(mockExecution.getVariable("disableRollback")).thenReturn(true) + when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-service-instance-id")).thenReturn("FH/VLXM/003717//SW_INTERNET") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.preProcessRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "DELETE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequest) + + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + + verify(mockExecution).setVariable(Prefix + "networkInputs", expected_networkInput) + verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") + verify(mockExecution).setVariable(Prefix + "source", "VID") + + // Authentications + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + + + } + + @Test + //@Ignore + public void preProcessRequest_vPER() { + + def networkModelInfo = """{"modelUuid": "sn5256d1-5a33-55df-13ab-12abad84e111", + "modelName": "CONTRAIL_EXTERNAL", + "modelType": "CONTRAIL_EXTERNAL", + "modelVersion": "1", + "modelCustomizationUuid": "sn5256d1-5a33-55df-13ab-12abad84e222", + "modelInvariantUuid": "sn5256d1-5a33-55df-13ab-12abad84e764" + }""".trim() + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + // Inputs: + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("networkId")).thenReturn("bdc5efe8-404a-409b-85f6-0dcc9eebae30") // optional + when(mockExecution.getVariable("networkName")).thenReturn("MNS-25180-L-01-dmz_direct_net_1") // optional + when(mockExecution.getVariable("productFamilyId")).thenReturn("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + when(mockExecution.getVariable("networkModelInfo")).thenReturn("CONTRAIL_EXTERNAL") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("tenantId")).thenReturn("7dd5365547234ee8937416c65507d266") + when(mockExecution.getVariable("failIfExists")).thenReturn("false") + when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable("action")).thenReturn("DELETE") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") + when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.preProcessRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "DELETE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedVperNetworkRequest) + + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedVper_networkInput) + verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") + verify(mockExecution).setVariable(Prefix + "source", "VID") + + // Authentications + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "networkRequest", "") + verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) + verify(mockExecution).setVariable(Prefix + "Success", false) + + verify(mockExecution).setVariable(Prefix + "requestId", "") + verify(mockExecution).setVariable(Prefix + "source", "") + verify(mockExecution).setVariable(Prefix + "lcpCloudRegion", "") + verify(mockExecution).setVariable(Prefix + "networkInputs", "") + verify(mockExecution).setVariable(Prefix + "tenantId", "") + + verify(mockExecution).setVariable(Prefix + "queryAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isAAIGood", false) + verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", false) + + // AAI query Cloud Region + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest","") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionReturnCode","") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionResponse","") + verify(mockExecution).setVariable(Prefix + "cloudRegionPo","") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc","") + + verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", "") + verify(mockExecution).setVariable(Prefix + "deleteNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "networkReturnCode", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") + + verify(mockExecution).setVariable(Prefix + "deleteSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "deleteSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "sdncReturnCode", "") + verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + + verify(mockExecution).setVariable(Prefix + "deactivateSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "deactivateSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "deactivateSdncReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") + + verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "isException", false) + + } + + @Test + //@Ignore + public void preProcessRequest_Json_MissingId() { + + println "************ preProcessRequest_MissingId() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("DELETE") + //when(mockExecution.getVariable("networkId")).thenReturn("") // missing Id + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + //when(mockExecution.getVariable("networkId")).thenReturn("") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(incomingJsonRequest) + when(mockExecution.getVariable("disableRollback")).thenReturn(true) + + when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-service-instance-id")).thenReturn("FH/VLXM/003717//SW_INTERNET") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + try { + DoDeleteNetworkInstance.preProcessRequest(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + //verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "DELETE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingId) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + + verify(mockExecution).setVariable(Prefix + "networkInputs", networkInputsMissingId) + verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") + verify(mockExecution).setVariable(Prefix + "source", "VID") + + } + + @Test + //@Ignore + public void preProcessRequest_Json_MissingCloudRegion() { + + def networkModelInfo = """{"modelVersionId": "sn5256d1-5a33-55df-13ab-12abad84e111", + "modelName": "CONTRAIL_EXTERNAL", + "modelType": "CONTRAIL_EXTERNAL", + "modelVersion": "1", + "modelCustomizationId": "sn5256d1-5a33-55df-13ab-12abad84e222", + "modelInvariantId": "sn5256d1-5a33-55df-13ab-12abad84e764" + }""".trim() + + println "************ preProcessRequest_MissingCloudRegion() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("DELETE") + when(mockExecution.getVariable("networkId")).thenReturn("bdc5efe8-404a-409b-85f6-0dcc9eebae30") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + //when(mockExecution.getVariable("networkId")).thenReturn("") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(incomingRequestMissingCloudRegion) + when(mockExecution.getVariable("disableRollback")).thenReturn(true) + + when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso-service-instance-id")).thenReturn("FH/VLXM/003717//SW_INTERNET") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.preProcessRequest(mockExecution) + + //verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "DELETE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingCloudRegion) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + + verify(mockExecution).setVariable(Prefix + "networkInputs", networkInputsMissingCloudRegion) + verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") + verify(mockExecution).setVariable(Prefix + "lcpCloudRegion", null) + + verify(mockExecution).setVariable("BasicAuthHeaderValuePO","Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + + } + + + + @Test + //@Ignore + public void prepareNetworkRequest() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedVperNetworkRequest) + when(mockExecution.getVariable(Prefix + "queryAAIResponse")).thenReturn(queryAAIResponse) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "tenantId")).thenReturn("e81d842d3e8b45c5a59f57cd76af3aaf") + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_value") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.prepareNetworkRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("URN_mso_adapters_network_rest_endpoint", "http://localhost:8090/networks/NetworkAdapter/bdc5efe8-404a-409b-85f6-0dcc9eebae30") + //verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRequest) + verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRESTRequest) + + } + + @Test + //@Ignore + public void prepareNetworkRequest_AlaCarte() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "queryAAIResponse")).thenReturn(queryAAIResponse) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "tenantId")).thenReturn("e81d842d3e8b45c5a59f57cd76af3aaf") + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_value") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.prepareNetworkRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("URN_mso_adapters_network_rest_endpoint", "http://localhost:8090/networks/NetworkAdapter/bdc5efe8-404a-409b-85f6-0dcc9eebae30") + //verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRequest) + verify(mockExecution).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRESTRequestAlaCarte) + + } + + @Test + //@Ignore + public void sendRequestToVnfAdapter() { + + println "************ sendRequestToVnfAdapter ************* " + + WireMock.reset(); + MockNetworkAdapter("bdc5efe8-404a-409b-85f6-0dcc9eebae30", 200, "deleteNetworkResponse_Success.xml"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "deleteNetworkRequest")).thenReturn(deleteNetworkRESTRequest) + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter/bdc5efe8-404a-409b-85f6-0dcc9eebae30") + when(mockExecution.getVariable("BasicAuthHeaderValuePO")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.sendRequestToVnfAdapter(mockExecution) + + verify(mockExecution).setVariable(Prefix + "networkReturnCode", 200) + //verify(mockExecution).setVariable(Prefix + "deleteNetworkResponse", deleteNetworkResponse_noRollback) + + } + + + @Test + //@Ignore + public void prepareSDNCRequest() { + + println "************ prepareSDNCRequest ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "queryAAIResponse")).thenReturn(aaiResponse) + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.prepareSDNCRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "deleteSDNCRequest", deleteSDNCRequest) + + } + + @Test + //@Ignore + public void prepareRpcSDNCRequest() { + + println "************ prepareRpcSDNCRequest ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(inputViprSDC_NetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.prepareRpcSDNCRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "deleteSDNCRequest", deleteRpcSDNCRequest) + + } + + @Test + //@Ignore + public void prepareRpcSDNCActivateRollback() { + + println "************ prepareRpcSDNCActivateRollback ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(inputViprSDC_NetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("8abc633a-810b-4ca5-8b3a-09511d13a2ce") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn(null) + when(mockExecution.getVariable(Prefix + "deactivateSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.prepareRpcSDNCDeactivateRollback(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix) + //verify(mockExecution).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("mso-service-instance-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", sdncAdapaterDeactivateRollback) + + } + + + @Test + //@Ignore + public void callRESTQueryAAI_200() { + + println "************ callRESTQueryAAI ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+"?depth=1") + + verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200") + //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponse) + verify(mockExecution).setVariable(Prefix + "isAAIGood", true) + verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", false) + + } + + @Test + //@Ignore + public void callRESTQueryAAI_withRelationship_200() { + + println "************ callRESTQueryAAI ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+"?depth=1") + + verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200") + //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponseWithRelationship) + verify(mockExecution).setVariable(Prefix + "isAAIGood", true) + verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAI_200_DefaultUri() { + + println "************ callRESTQueryAAI ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+ "?depth=1") + + verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200") + //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponse) + verify(mockExecution).setVariable(Prefix + "isAAIGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion30_200() { + + println "************ callRESTQueryAAICloudRegion30_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion("DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion_NotFound() { + + println "************ callRESTQueryAAICloudRegion_NotFound ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion_404("MDTWNJ21"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestCloudRegionNotFound) + when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn("MDTWNJ21") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion25_200() { + + println "************ callRESTQueryAAICloudRegion25_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion("DeleteNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + + } + + + @Test + //@Ignore + public void validateNetworkResponse() { + + println "************ validateNetworkResponse ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "deleteNetworkResponse")).thenReturn(deleteNetworkResponse) + when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.validateNetworkResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + //verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) + + } + + + @Test + //@Ignore + public void validateSDNCResponse_200() { + + println "************ validateSDNCResponse ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + try { + DoDeleteNetworkInstance.validateSDNCResponse(mockExecution, sdncAdapterWorkflowResponse) + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + + } + + @Test + //@Ignore + public void validateSDNCResponse_404() { + + println "************ validateSDNCResponse ************* " + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from SNDC Adapter: HTTP Status 404.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("404") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + try { + DoDeleteNetworkInstance.validateSDNCResponse(mockExecution) + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + + } + + @Test + //@Ignore + public void validateRpcSDNCDeactivateResponse() { + + println "************ validateRpcSDNCDeactivateResponse ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "deactivateSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mockExecution.getVariable(Prefix + "deactivateSDNCReturnCode")).thenReturn("200") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + try { + DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(mockExecution) + verify(mockExecution).setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true) + + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + //verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + + } + + @Test + @Ignore + public void postProcessResponse() { + + println "************ postProcessResponse ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("PORTAL") + when(mockExecution.getVariable(Prefix + "isException")).thenReturn(false) + + // postProcessResponse(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.postProcessResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", true) + + } + + @Test + //@Ignore + public void prepareRollbackData() { + + println "************ prepareRollbackData() ************* " + + + + WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(deleteRollbackNetworkRequest) + //when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(null) + //when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("") + when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn(sdncAdapaterDeactivateRollback) + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.prepareRollbackData(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoDeleteNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..c97bedbac1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy @@ -0,0 +1,315 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.delegate.BpmnError +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.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.junit.Before +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith + +import static org.junit.Assert.*; + +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.apache.commons.lang3.* + + +@RunWith(MockitoJUnitRunner.class) +class DoUpdateNetworkInstanceRollbackTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + def utils = new MsoUtils() + String Prefix="UPDNETIR_" + + + String rollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String rollbackActivateSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String rollbackSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + generic-resource + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", null) + verify(mockExecution).setVariable(Prefix + "WorkflowException", null) + + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "Success", false) + verify(mockExecution).setVariable(Prefix + "fullRollback", false) + + + } + + @Test + //@Ignore + public void preProcessRequest() { + + println "************ preProcessRequest ************* " + + WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + Map rollbackData = new HashMap(); + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") + + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() + DoUpdateNetworkInstanceRollback.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + //verify variable initialization + initializeVariables(mockExecution) + + } + + + @Test + @Ignore + public void validateRollbackResponses_Good() { + + WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC activate rollback completed. + PO Network rollback completed. + SNDC assign rollback completed.") + + println "************ validateRollbackResponses_Good() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) + + DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() + DoUpdateNetworkInstanceRollback.validateRollbackResponses(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) + verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) + verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) + //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) + } + + @Test + //@Ignore + public void validateRollbackResponses_FullRollback() { + + Map rollbackData = new HashMap(); + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + + println "************ validateRollbackResponses_FullRollback() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") + when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(null) + when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) + when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) + + DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() + DoUpdateNetworkInstanceRollback.validateRollbackResponses(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) + verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) + + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoUpdateNetworkInstanceRollback") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateNetworkInstanceRollback") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoUpdateNetworkInstanceRollback") + when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateNetworkInstanceRollback") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..fb44067b68 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy @@ -0,0 +1,2625 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; +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.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.apache.commons.lang3.* + + +@RunWith(MockitoJUnitRunner.class) +class DoUpdateNetworkInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + def utils = new MsoUtils() + String Prefix="UPDNETI_" + + String jsonIncomingRequest = + """{ "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "someUserParam1", + "value": "someValue1" + } + ] + } + }}""" + + + String jsonIncomingRequest_MissingCloudRegion = + """{ "requestDetails": { + "modelInfo": { + "modelType": "network", + "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [] + } + }}""" + + + + String expectedNetworkRequestMissingNetworkId = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 + + + someValue1 + +""" + + +String expectedNetworkRequestMissingCloudRegion = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + null + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + null + + +""" + +String expectedNetworkInputMissingCloudRegion = +""" + networkId + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + null + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + null +""" + + String networkInputsMissingName = + """ + + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + """ + +String networkInputsMissingCloudRegion = +""" + HSL_direct_net_2 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + e81d842d3e8b45c5a59f57cd76af3aaf +""" + + // expectedNetworkRequest + String expectedNetworkRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 + + + someValue1 + +""" + +String expectedNetworkInputs = +""" + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 +""" + +String expectedVperNetworkRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + + + + + + + + + 1702 + + +""" + +String expectedVperNetworkInputs = +""" + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + MSO-dev-service-type + globalId_45678905678 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + false + + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e111 + sn5256d1-5a33-55df-13ab-12abad84e764 + 1 + sn5256d1-5a33-55df-13ab-12abad84e222 + + + + + + + + + 1702 +""" + +String expectedNetworkInputsMissingNetworkId = +""" + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + f21df226-8093-48c3-be7e-0408fcda0422 + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + false + 1610 +""" + + + String NetworkRequest_noPhysicalName = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 3008 + + + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + +""" + + String vnfRequestFakeRegion = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 7dd5365547234ee8937416c65507d266 + + + 1 + 0 + +""" + + // expectedNetworkRequest + String expectedNetworkRequest_Outputs = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + + + MNS-25180-L-01-dmz_direct_net_1 + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + + + 1 + 0 + +""" + + + String networkInputs = + """ + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf +""" + + String networkOutputs = + """ + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + """ + + String queryAAIResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + +""" + + String queryIdAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + pending-delete + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-update + true + subnetName + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + +""" + + String queryIdAIIResponseTestScenario01 = + """ + + 4da55fe4-7a9e-478c-a434-8a98d62265ab + GN_EVPN_direct_net_0_ST1 + CONTRAIL30_BASIC + GN_EVPN_direct + contrail + false + 9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + 1465398611 + pending-delete + networkName + false + true + false + + + cb1a7b47-5428-44c9-89c2-8b17541c3228 + 108.239.40.1 + 108.239.40.0 + 28 + 4 + pending-delete + true + 108.239.40.0 + 108.239.40.0 + 1465398611 + subnetName + + + + e2cc7c14-90f0-4205-840d-b4e07f04e621 + 2606:ae00:2e01:604::1 + 2606:ae00:2e01:604:: + 64 + 6 + pending-delete + true + 2606:ae00:2e01:604:: + 2606:ae00:2e01:604:: + 1465398611 + subnetName + + + + + + 416 + 4132176 + + + + cloud-region + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ + + + cloud-region.cloud-region-id + AAIAIC25 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.owner-defined-type + + + + + tenant + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ + + tenant.tenant-id + 4ae1d3446a4c48b2bec44b6cfba06d68 + + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + AAIAIC25 + + + tenant.tenant-name + Ruchira Contrail 3.0 test + + + + vpn-binding + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + GN_EVPN_direct_net_0_ST1 + + + + route-table-reference + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + String queryIdAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + + + +""" + + String queryNameAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + + """ + + String queryNameAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + + + +""" + + String queryVpnBindingAAIResponse = + """ + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/ + + l3-network.network-id + 689ec39e-c5fc-4462-8db2-4f760763ad28 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/ + + l3-network.network-id + 1a49396b-19b3-40a4-8792-aa2fbd0f0704 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + +""" + + + String updateNetworkRequest = + """ + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + sn5256d1-5a33-55df-13ab-12abad84e222 + + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + refFQDN1 + refFQDN2 + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_generated + +""" + +String updateNetworkRequest_noPhysicalName = +""" + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + + + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + null + + messageId_generated + +""" + + String updateNetworkResponseREST = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + + messageId_generated +""" + + String updateRollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String updateNetworkResponse = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + true + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + CONTRAIL_EXTERNAL + false + c4f4e878-cde0-4b15-ae9a-bda857759cea + 7dd5365547234ee8937416c65507d266 + +""" + + String updateContrailAAIPayloadRequest = + """ + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + c4f4e878-cde0-4b15-ae9a-bda857759cea + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + Active + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Active + true + subnetName + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + + String updateContrailAAIResponse = + """ + + + + + + + + +""" + + String updateNetworkErrorResponse = + """ + 680bd458-5ec1-4a16-b77c-509022e53450INTERNAL + 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data + true + """ + + + String networkException500 = + """soap:VersionMismatch"http://org.openecomp.mso/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" + + String aaiResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + + + """ + + String changeAssignSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + changeassign + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String assignResponse = +""" 006927ca-f5a3-47fd-880c-dfcbcd81a093 200 OK 200006927ca-f5a3-47fd-880c-dfcbcd81a093Ynotsurewecarea9a77d5a-123e-4ca2-9eb9-0b015d2ee0fbGN_EVPN_direct_net_0_ST_noGW8abc633a-810b-4ca5-8b3a-09511d13a2ce """ + + String sdncRollbackRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String sdncAdapterWorkflowResponse = + """ + + + 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 + 200 + OK + + <output xmlns="com:att:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>MNS-25180-L-01-dmz_direct_net_1</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + +""" + + + String sdncAdapterWorkflowResponse_Error = + """ + + + + 400 + Error writing to l3-netework + Y + c79240d8-34b5-4853-af69-2021928dba00 + + + +""" + + String expected_sdncAdapterWorkflowResponse_Error = + """ + + + + 400 + Error writing to l3-netework + Y + c79240d8-34b5-4853-af69-2021928dba00 + + + +""" + + String sdncAdapterWorkflowFormattedResponse = + """ + + + 00703dc8-71ff-442d-a4a8-3adc5beef6a9 + 200 + Y + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + notsurewecare + + + +""" + +String rollbackSDNCRequest = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + CreateNetworkInstance + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + + invariant-uuid + customization-uuid + uuid + version + CONTRAIL_EXTERNAL + + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String rollbackNetworkRequest = +""" + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "messageId", "") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") + verify(mockExecution).setVariable(Prefix + "networkRequest", "") + verify(mockExecution).setVariable(Prefix + "networkInputs", "") + verify(mockExecution).setVariable(Prefix + "networkOutputs", "") + verify(mockExecution).setVariable(Prefix + "requestId", "") + verify(mockExecution).setVariable(Prefix + "source", "") + verify(mockExecution).setVariable(Prefix + "networkId", "") + + verify(mockExecution).setVariable(Prefix + "isPONR", false) + + // AAI query Cloud Region + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest","") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionReturnCode","") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionResponse","") + verify(mockExecution).setVariable(Prefix + "cloudRegionPo","") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc","") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", false) + + // AAI query Id + verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryIdAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "") + + // AAI query vpn binding + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") + verify(mockExecution).setVariable(Prefix + "vpnBindings", null) + verify(mockExecution).setVariable(Prefix + "vpnCount", 0) + verify(mockExecution).setVariable(Prefix + "routeCollection", "") + + // AAI query network policy + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") + verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", null) + verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 0) + verify(mockExecution).setVariable(Prefix + "networkCollection", "") + + // AAI query route table reference + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIRequest","") + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") + verify(mockExecution).setVariable(Prefix + "networkTableRefUriList", null) + verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 0) + verify(mockExecution).setVariable(Prefix + "tableRefCollection", "") + + + // AAI requery Id + verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest","") + verify(mockExecution).setVariable(Prefix + "requeryIdAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "") + + // AAI update contrail + verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest","") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest","") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", "") + verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "") + + verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", "") + verify(mockExecution).setVariable(Prefix + "updateNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") + //verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") + verify(mockExecution).setVariable(Prefix + "networkReturnCode", "") + //verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", false) + + verify(mockExecution).setVariable(Prefix + "changeAssignSDNCRequest", "") + verify(mockExecution).setVariable(Prefix + "changeAssignSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") + //verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") + verify(mockExecution).setVariable(Prefix + "sdncReturnCode", "") + //verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") + verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", false) + verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + + verify(mockExecution).setVariable(Prefix + "isVnfBindingPresent", false) + verify(mockExecution).setVariable(Prefix + "Success", false) + verify(mockExecution).setVariable(Prefix + "serviceInstanceId", "") + + verify(mockExecution).setVariable(Prefix + "isException", false) + + } + + @Test + //@Ignore + public void preProcessRequest_NetworkRequest() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix + "") + + //verify variable initialization + initializeVariables(mockExecution) + + // Authentications + verify(mockExecution).setVariable("action", "UPDATE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequest) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputs) + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable(Prefix + "networkOutputs", "") + + } + + @Test + //@Ignore + public void preProcessRequest_vPERNetworkRequest() { + + def networkModelInfo = """{"modelUuid": "sn5256d1-5a33-55df-13ab-12abad84e111", + "modelName": "CONTRAIL_EXTERNAL", + "modelType": "CONTRAIL_EXTERNAL", + "modelVersion": "1", + "modelCustomizationUuid": "sn5256d1-5a33-55df-13ab-12abad84e222", + "modelInvariantUuid": "sn5256d1-5a33-55df-13ab-12abad84e764" + }""".trim() + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") // optional + when(mockExecution.getVariable("networkName")).thenReturn("MNS-25180-L-01-dmz_direct_net_1") // optional + when(mockExecution.getVariable("productFamilyId")).thenReturn("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + when(mockExecution.getVariable("networkModelInfo")).thenReturn("CONTRAIL_EXTERNAL") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("tenantId")).thenReturn("7dd5365547234ee8937416c65507d266") + when(mockExecution.getVariable("failIfExists")).thenReturn("false") + when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable("action")).thenReturn("UPDATE") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix + "") + + //verify variable initialization + initializeVariables(mockExecution) + + // Authentications + verify(mockExecution).setVariable("action", "UPDATE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedVperNetworkRequest) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedVperNetworkInputs) + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable(Prefix + "networkOutputs", "") + + } + + @Test + //@Ignore + public void preProcessRequest_MissingNetworkId() { + + println "************ preProcessRequest_MissingName() ************* " + + WorkflowException missingNameWorkflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "Variable 'network-id' value/element is missing.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + //when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + try { + DoUpdateNetworkInstance.preProcessRequest(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "UPDATE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingNetworkId) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputsMissingNetworkId) + verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "VID") + verify(mockExecution).setVariable(Prefix + "networkOutputs", "") + + verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingNameWorkflowException)) + + } + + @Test + //@Ignore + public void preProcessRequest_MissingCloudRegion() { + + println "************ preProcessRequest_MissingCloudRegion() ************* " + + WorkflowException missingCloudRegionWorkflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "requestDetails has missing 'aic-cloud-region' value/element.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + when(mockExecution.getVariable("networkId")).thenReturn("networkId") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest_MissingCloudRegion) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + try { + DoUpdateNetworkInstance.preProcessRequest(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("action", "UPDATE") + verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingCloudRegion) + verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) + verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputMissingCloudRegion) + verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "VID") + + verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingCloudRegionWorkflowException)) + + } + + @Test + //@Ignore + public void prepareUpdateNetworkRequest() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedVperNetworkRequest) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + + verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest) + + } + + + @Test + //@Ignore + public void prepareUpdateNetworkRequest_NoPhysicalname() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(NetworkRequest_noPhysicalName) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + + verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest_noPhysicalName) + + } + + @Test + //@Ignore + public void prepareSDNCRequest() { + + println "************ prepareSDNCRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareSDNCRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "changeAssignSDNCRequest", changeAssignSDNCRequest) + + } + + @Test + //@Ignore + public void prepareSDNCRollbackRequest() { + + println "************ prepareSDNCRollbackRequest ************* " + + + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(assignResponse) + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareSDNCRollbackRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", sdncRollbackRequest) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkId_200() { + + println "************ callRESTQueryAAINetworkId ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkId(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion30_200() { + + println "************ callRESTQueryAAICloudRegion30_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion25_200() { + + println "************ callRESTQueryAAICloudRegion25_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion_NotFound() { + + println "************ callRESTQueryAAICloudRegionFake ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion_404("MDTWNJ21"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestFakeRegion) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") + verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") + verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "vpnCount", 2) + verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "vpnCount", 1) + verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "vpnCount", 2) + verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_NotPresent() { + + println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "vpnCount", 0) + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", aaiVpnResponseStub) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkTableRef_200() { + + println "************ callRESTQueryAAINetworkTableRef_200 ************* " + + WireMock.reset(); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_table_reference_uri")).thenReturn("") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_route_table_reference_uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkTableRef(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 2) + verify(mockExecution).setVariable(Prefix + "networkTableRefUriList", ['/aai/v8/network/route-table-references/route-table-reference/refFQDN1','/aai/v8/network/route-table-references/route-table-reference/refFQDN2']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIRequest", "http://localhost:8090/aai/v8/network/route-table-references/route-table-reference/refFQDN1?depth=all") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkPolicy_200() { + + println "************ callRESTQueryAAINetworkPolicy_200 ************* " + + WireMock.reset(); + MockGetNetworkPolicy("UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 1) + verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest", "http://localhost:8090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg?depth=all") + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + + } + + + @Test + //@Ignore + public void callRESTReQueryAAINetworkId_200() { + + println "************ callRESTReQueryAAINetworkId ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "200") + + } + + + @Test + //@Ignore + public void callRESTUpdateContrailAAINetworkREST_200() { + + println "************ callRESTUpdateContrailAAINetwork ************* " + + WireMock.reset(); + MockPutNetworkIdWithDepth("UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=1") + verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) + verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") + //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) + verify(mockExecution).setVariable(Prefix + "isPONR", true) + + } + + + + @Test + //@Ignore + public void validateUpdateNetworkResponseREST() { + + println "************ validateNetworkResponse ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) + when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "updateNetworkResponse", updateNetworkResponseREST) + verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", true) + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", updateRollbackNetworkRequest) + + } + + @Test + //@Ignore + public void validateUpdateNetworkResponseREST_Error() { + + println "************ validateNetworkResponse ************* " + + WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(networkException500) + when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('500') + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + try { + DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(workflowException, any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateSDNCResponse() { + + println "************ validateSDNCResponse ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + try { + DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) + verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") + + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + //verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + + } + + @Test + //@Ignore + public void validateSDNCResponse_Error() { + + println "************ validateSDNCResponse ************* " + //ExecutionEntity mockExecution = mock(ExecutionEntity.class) + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) + when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + try { + DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) + } catch (Exception ex) { + println " Graceful Exit! - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + // verify set prefix = Prefix + "" + //verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + + } + + @Test + //@Ignore + public void prepareRollbackData() { + + println "************ prepareRollbackData() ************* " + + + + WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackNetworkRequest) + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareRollbackData(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + @Test + //@Ignore + public void postProcessResponse() { + + println "************ postProcessResponse() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(Prefix + "isException")).thenReturn(false) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("mso-request-id")).thenReturn("requestId") + + // preProcessRequest(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.postProcessResponse(mockExecution) + + verify(mockExecution, atLeast(3)).getVariable("isDebugLogEnabled") + verify(mockExecution, atLeast(3)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", true) + + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoUpdateNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoUpdateNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..e987d59805 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy @@ -0,0 +1,368 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +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.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.apache.commons.lang3.* + + +@RunWith(MockitoJUnitRunner.class) +class UpdateNetworkInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + String Prefix="UPDNI_" + def utils = new MsoUtils() + + String createDBRequestError = +""" + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error from SDN-C: No availability zone available + + FAILED + <network-id></network-id><network-name></network-names> + + + """ + + String falloutHandlerRequest = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + UPDATE + VID + + + Received error from SDN-C: No availability zone available. + 5300 + + """ + + String completeMsoProcessRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + VID + + Network has been updated successfully. + BPMN Network action: UPDATE +""" + + +String jsonIncomingRequest = +"""{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "someUserParam1", + "value": "someValue1" + } + ] + } + }}""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables(Execution mockExecution) { + + verify(mockExecution).setVariable(Prefix + "source", "") + verify(mockExecution).setVariable(Prefix + "Success", false) + + verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") + verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") + + } + + @Test + //@Ignore + public void preProcessRequest() { + + println "************ preProcessRequest() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + initializeVariables(mockExecution) + //verify(mockExecution).setVariable(Prefix + "Success", false) + + } + + + @Test + //@Ignore + public void getNetworkModelInfo() { + + println "************ getNetworkModelInfo() ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.getNetworkModelInfo(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + @Test + //@Ignore + public void sendSyncResponse() { + + println "************ sendSyncResponse ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + // preProcessRequest(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.sendSyncResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("UpdateNetworkInstanceResponseCode", "202") + + } + + @Test + //@Ignore + public void sendSyncError() { + + println "************ sendSyncError ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.sendSyncError(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("UpdateNetworkInstanceResponseCode", "500") + + } + + @Test + //@Ignore + public void prepareDBRequestError() { + + println "************ prepareDBRequestError ************* " + + WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstance", 500, "Received error from SDN-C: No availability zone available") + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + //when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("networkId")).thenReturn("") + when(mockExecution.getVariable("networkName")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.prepareDBRequestError(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "createDBRequest", createDBRequestError) + + } + + + @Test + //@Ignore + public void prepareCompletion() { + + println "************ postProcessResponse ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + 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") + + // postProcessResponse(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.prepareCompletion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "Success", true) + verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", completeMsoProcessRequest) + + } + + @Test + //@Ignore + public void buildErrorResponse() { + + println "************ buildErrorResponse ************* " + + + WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstance", 5300, "Received error from SDN-C: No availability zone available.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso-request-id")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") + //when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + + // buildErrorResponse(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.buildErrorResponse(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + } + + @Test + //@Ignore + public void postProcessResponse() { + + println "************ postProcessResponse() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("CMSO_ResponseCode")).thenReturn("200") + + // postProcessResponse(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.postProcessResponse(mockExecution) + + //verify(mockExecution).getVariable("isDebugLogEnabled") + //verify(mockExecution).setVariable("prefix", Prefix) + + verify(mockExecution).setVariable(Prefix + "Success", true) + + } + + @Test + //@Ignore + public void processRollbackData() { + + println "************ callDBCatalog() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.processRollbackData(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("UpdateNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("UpdateNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("UpdateNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java new file mode 100644 index 0000000000..8419e19206 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateGenericALaCarteServiceInstanceTest.java @@ -0,0 +1,109 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for CreateGenericALaCarteServiceInstance.bpmn + */ +public class CreateGenericALaCarteServiceInstanceTest extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public CreateGenericALaCarteServiceInstanceTest() throws IOException { + callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCSITopologyAssignCallback.xml")); + } + + /** + * Sunny day VID scenario. + * + * @throws Exception + */ + //@Ignore // File not found - unable to run the test. Also, Stubs need updating.. + @Test + @Deployment(resources = { + "process/CreateGenericALaCarteServiceInstance.bpmn", + "subprocess/DoCreateServiceInstance.bpmn", + "subprocess/DoCreateServiceInstanceRollback.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericPutService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" }) + public void sunnyDayAlaCarte() throws Exception { + + logStart(); + + //AAI + MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml"); + MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", ""); + MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", "GenericFlows/getServiceInstance.xml"); + MockNodeQueryServiceInstanceByName("RAATest-1", ""); + MockNodeQueryServiceInstanceById("RaaTest-1-id", ""); + //SDNC + mockSDNCAdapter(200); + //DB + mockUpdateRequestDB(200, "DBUpdateResponse.xml"); + + + String businessKey = UUID.randomUUID().toString(); + + //String createVfModuleRequest = FileUtil.readResourceFile("__files/SIRequest.json"); + + Map variables = setupVariables(); + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateGenericALaCarteServiceInstance", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "WorkflowResponse"); + //assertNotNull(workflowResp); + System.out.println("Workflow (Synch) Response:\n" + workflowResp); + String workflowException = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "WorkflowException"); + String completionReq = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "completionRequest"); + System.out.println("completionReq:\n" + completionReq); + System.out.println("workflowException:\n" + workflowException); + assertNotNull(completionReq); + assertEquals(null, workflowException); + + + //injectSDNCCallbacks(callbacks, "assign"); + + logEnd(); + } + + // Success Scenario + private Map setupVariables() { + Map variables = new HashMap(); + variables.put("isDebugLogEnabled", "true"); + variables.put("bpmnRequest", getRequest()); + variables.put("mso-request-id", "RaaCSIRequestId-1"); + variables.put("serviceInstanceId","RaaTest-1-id"); + return variables; + } + + public String getRequest() { + String request = "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\"},\"subscriberInfo\":{\"globalSubscriberId\":\"MCBH-1610\",\"subscriberName\":\"Kaneohe\"},\"requestInfo\":{\"instanceName\":\"RAATest-1\",\"source\":\"VID\",\"suppressRollback\":\"true\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\"},\"requestParameters\":{\"subscriptionServiceType\":\"viprsvc\",\"aLaCarte\":\"false\",\"userParams\":[]}}}"; + return request; + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java new file mode 100644 index 0000000000..30cd4a5631 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateNetworkInstanceTest.java @@ -0,0 +1,645 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.*; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapterPost; +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapterRestRollbackDelete; +// new mock methods +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapterTopology; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter_500; +import org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer; + +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeAsyncWorkflow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.getVariable; +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; + +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.WorkflowTestTransformer; +import org.openecomp.mso.bpmn.common.SDNCAdapterCallbackRule; +import com.github.tomakehurst.wiremock.extension.ResponseTransformer; + +/** + * Unit test cases for CreateNetworkInstance.bpmn + * + */ +public class CreateNetworkInstanceTest extends WorkflowTest { + @WorkflowTestTransformer + public static final ResponseTransformer sdncAdapterMockTransformer = + new SDNCAdapterNetworkTopologyMockTransformer(); + + @Rule + public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = + new SDNCAdapterCallbackRule(processEngineRule); + + /** + * End-to-End flow - Unit test for CreateNetworkInstance.bpmn + * - String input & String response + */ + + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_vIPER_Success1() throws Exception { + + System.out.println("-----------------------------------------------------------------"); + System.out.println(" Success vIPER 1 - CreateNetworkInstance flow Started! "); + System.out.println("-----------------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml", "SvcAction>assign"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>activate"); + MockNetworkAdapterPost("CreateNetworkV2/createNetworkResponse_Success.xml", "createNetworkRequest"); + MockGetNetworkByName("MNS-25180-L-01-dmz_direct_net_1", "CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml"); + + Map variables = setupVariables1(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + System.out.println("----------------------------------------------------------"); + System.out.println("- got workflow response -"); + System.out.println("----------------------------------------------------------"); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("true", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + assertEquals("true", getVariable(processEngineRule, "DoCreateNetworkInstance", "CRENWKI_Success")); + Assert.assertNotNull("CRENI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_CompleteMsoProcessRequest")); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateNetworkInstance", "WorkflowResponse"); + Assert.assertNotNull(workflowResp); + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success vIPER 1 - CreateNetworkInstance flow Completed "); + System.out.println("----------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_vIPER_Success2() throws Exception { + + System.out.println("----------------------------------------------------------------"); + System.out.println(" Success viPER 2 - CreateNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml", "SvcAction>assign"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>activate"); + MockNetworkAdapterPost("CreateNetworkV2/createNetworkResponse_Success.xml", "createNetworkRequest"); + MockGetNetworkByName_404("CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml", "myOwn_Network"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml"); + + Map variables = setupVariables2(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("true", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + assertEquals("true", getVariable(processEngineRule, "DoCreateNetworkInstance", "CRENWKI_Success")); + Assert.assertNotNull("CRENI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_CompleteMsoProcessRequest")); + + String completeMsoProcessRequest = + "" + '\n' + + " " + '\n' + + " testRequestId" + '\n' + + " CREATE" + '\n' + + " VID" + '\n' + + " " + '\n' + + " Network has been created successfully." + '\n' + + " BPMN Network action: CREATE" + '\n' + + ""; + + Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_CompleteMsoProcessRequest")); + + System.out.println("---------------------------------------------------------"); + System.out.println(" Success viPER 2 - CreateNetworkInstance flow Completed "); + System.out.println("---------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_VID_1610_Network_SDNC_Rollback() throws Exception { + + System.out.println("--------------------------------------------------------------------------"); + System.out.println(" Network and SDNC Rollback - CreateNetworkInstance flow Started! "); + System.out.println("--------------------------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>assign"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>rollback"); + MockNetworkAdapterPost("CreateNetworkV2/createNetworkResponse_Success.xml", "createNetworkRequest"); + MockGetNetworkByName("MNS-25180-L-01-dmz_direct_net_1", "CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml"); + MockNetworkAdapterRestRollbackDelete("deleteNetworkResponse_Success.xml","49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + + Map variables = setupVariablesVID1(); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("false", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + assertEquals("false", getVariable(processEngineRule, "DoCreateNetworkInstance", "CRENWKI_Success")); + Assert.assertNotNull("CRENI_FalloutHandlerRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_FalloutHandlerRequest")); + + System.out.println("--------------------------------------------------------------------"); + System.out.println(" Network and SCNC Rollback - CreateNetworkInstance flow Completed "); + System.out.println("--------------------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_vIPER_1702_Network_SDNC_Rollback() throws Exception { + + System.out.println("--------------------------------------------------------------------------"); + System.out.println(" Network and SDNC Rollback - CreateNetworkInstance flow Started! "); + System.out.println("--------------------------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml", "SvcAction>assign"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>unassign"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>activate"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>deactivate"); + MockNetworkAdapterPost("CreateNetworkV2/createNetworkResponse_Success.xml", "createNetworkRequest"); + MockGetNetworkByName("MNS-25180-L-01-dmz_direct_net_1", "CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml"); + MockNetworkAdapterRestRollbackDelete("deleteNetworkResponse_Success.xml","49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + + Map variables = setupVariables1(); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("false", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + assertEquals("false", getVariable(processEngineRule, "DoCreateNetworkInstance", "CRENWKI_Success")); + Assert.assertNotNull("CRENI_FalloutHandlerRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_FalloutHandlerRequest")); + + System.out.println("--------------------------------------------------------------------"); + System.out.println(" Network and SCNC Rollback - CreateNetworkInstance flow Completed "); + System.out.println("--------------------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_sdncFailure() throws Exception { + + System.out.println("----------------------------------------------------------------"); + System.out.println(" SNDC Failure - CreateNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------------"); + + // setup simulators + mockSDNCAdapter_500("SvcAction>query"); + MockGetNetworkByName_404("CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml", "myOwn_Network"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml"); + + Map variables = setupVariables2(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("false", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + assertEquals("false", getVariable(processEngineRule, "DoCreateNetworkInstance", "CRENWKI_Success")); + Assert.assertNotNull("CRENI_FalloutHandlerRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_FalloutHandlerRequest")); + + System.out.println("---------------------------------------------------------"); + System.out.println(" SNDC Failure - CreateNetworkInstance flow Completed "); + System.out.println("---------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_queryServiceInstance404() throws Exception { + + System.out.println("----------------------------------------------------------------------------------"); + System.out.println(" Query ServiceIntance Not found - CreateNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------------------------------"); + + //setup simulators + mockSDNCAdapter_500("SvcAction>query"); + MockGetNetworkByName_404("CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml", "myOwn_Network"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + MockNodeQueryServiceInstanceById_404("f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + + Map variables = setupVariables2(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("false", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + assertEquals("false", getVariable(processEngineRule, "DoCreateNetworkInstance", "CRENWKI_Success")); + Assert.assertNotNull("CRENI_FalloutHandlerRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_FalloutHandlerRequest")); + + System.out.println("---------------------------------------------------------------------------------"); + System.out.println(" Query ServiceIntance Not found - CreateNetworkInstance flow Completed "); + System.out.println("---------------------------------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/CreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstance.bpmn", + "subprocess/DoCreateNetworkInstanceRollback.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceCreateNetworkInstance_VID_Success1() throws Exception { + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success VID1 - CreateNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>assign"); + MockNetworkAdapterPost("CreateNetworkV2/createNetworkResponse_Success.xml", "createNetworkRequest"); + MockGetNetworkByName("MNS-25180-L-01-dmz_direct_net_1", "CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "CreateNetworkV2/createNetwork_queryInstance_Success.xml"); + + Map variables = setupVariablesVID1(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "CreateNetworkInstance", variables); + System.out.println("----------------------------------------------------------"); + System.out.println("- got workflow response -"); + System.out.println("----------------------------------------------------------"); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("true", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_Success")); + Assert.assertNotNull("CRENI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "CreateNetworkInstance", "CRENI_CompleteMsoProcessRequest")); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateNetworkInstance", "WorkflowResponse"); + Assert.assertNotNull(workflowResp); + + System.out.println("-----------------------------------------------------------"); + System.out.println(" Success VID1 - CreateNetworkInstanceInfra flow Completed "); + System.out.println("-----------------------------------------------------------"); + + } + + // ***************** + // Utility Section + // ***************** + + String networkModelInfo = + " {\"modelUuid\": \"mod-inst-uuid-123\", " + '\n' + + " \"modelName\": \"mod_inst_z_123\", " + '\n' + + " \"modelVersion\": \"mod-inst-uuid-123\", " + '\n' + + " \"modelCustomizationUuid\": \"z_network_123\", " + '\n' + + " \"modelInvariantUuid\": \"mod-invar-uuid-123\" " + '\n' + + " }"; + + String serviceModelInfo = + " {\"modelUuid\": \"36a3a8ea-49a6-4ac8-b06c-89a54544b9b6\", " + '\n' + + " \"modelName\": \"HNGW Protected OAM\", " + '\n' + + " \"modelVersion\": \"1.0\", " + '\n' + + " \"modelInvariantUuid\": \"fcc85cb0-ad74-45d7-a5a1-17c8744fdb71\" " + '\n' + + " }"; + + // Success Scenario + private Map setupVariables1() { + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("networkId", "networkId"); + variables.put("networkName", "MNS-25180-L-01-dmz_direct_net_1"); + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("disableRollback", "false"); // macro + variables.put("failIfExists", "false"); + variables.put("sdncVersion", "1702"); + variables.put("subscriptionServiceType", "MSO-dev-service-type"); + variables.put("globalSubscriberId", "globalId_45678905678"); + variables.put("networkModelInfo", networkModelInfo); + variables.put("serviceModelInfo", serviceModelInfo); + + + return variables; + + } + + // Success Scenario 2 + private Map setupVariables2() { + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("networkId", "networkId"); + variables.put("networkName", "myOwn_Network"); // Name Not found in AA&I + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("disableRollback", "false"); // 1702 + variables.put("failIfExists", "false"); + //variables.put("sdncVersion", "1702"); + variables.put("sdncVersion", "1707"); + variables.put("subscriptionServiceType", "MSO-dev-service-type"); + variables.put("globalSubscriberId", "globalId_45678905678"); + variables.put("networkModelInfo", networkModelInfo); + variables.put("serviceModelInfo", serviceModelInfo); + + return variables; + + } + + // Active Scenario + private Map setupVariablesActive() { + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("networkId", "networkId"); + variables.put("networkName", "MNS-25180-L-01-dmz_direct_net_2"); // Unique name for Active + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("suppressRollback", "false"); + variables.put("disableRollback", "false"); + variables.put("failIfExists", "false"); + variables.put("sdncVersion", "1702"); + variables.put("subscriptionServiceType", "MSO-dev-service-type"); + variables.put("globalSubscriberId", "globalId_45678905678"); + variables.put("networkModelInfo", networkModelInfo); + variables.put("serviceModelInfo", serviceModelInfo); + + return variables; + + } + + // Missing Name Scenario + private Map setupVariablesMissingName() { + Map variables = new HashMap(); + //variables.put("bpmnRequest", getCreateNetworkRequestMissingName()); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("networkId", "networkId"); + // variables.put("networkName", "MNS-25180-L-01-dmz_direct_net_2"); // Missing 'name' variable + // variables.put("networkName", ""); // Missing 'value' of name variable + variables.put("modelName", "CONTRAIL_EXTERNAL"); + variables.put("cloudConfiguration", "RDM2WAGPLCP"); + variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("suppressRollback", "true"); + variables.put("failIfExists", "false"); + + return variables; + + } + + // SDNC Rollback Scenario + private Map setupVariablesSDNCRollback() { + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("networkId", "networkId"); + variables.put("networkName", "MNS-25180-L-01-dmz_direct_net_3"); // Unique name for Rollback + variables.put("modelName", "CONTRAIL_EXTERNAL"); + variables.put("cloudConfiguration", "RDM2WAGPLCP"); + variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("suppressRollback", "true"); + variables.put("disableRollback", "false"); + + return variables; + + } + + // old + public String getCreateNetworkRequestActive() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelId\": \"modelId\", " + '\n' + + " \"modelCustomizationUuid\": \"modelCustUuid\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_2\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"false\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + return request; + + } + + public String getCreateNetworkRequestSDNCRollback() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelId\": \"modelId\", " + '\n' + + " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_3\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"true\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + + return request; + } + + + // VID json input + private Map setupVariablesVID1() { + Map variables = new HashMap(); + variables.put("bpmnRequest", getCreateNetworkRequestVID1()); + variables.put("mso-request-id", "testRequestId"); + //variables.put("msoRequestId", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("isBaseVfModule", "true"); + variables.put("recipeTimeout", "0"); + variables.put("requestAction", "CREATE"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", ""); + variables.put("vfModuleId", ""); + variables.put("volumeGroupId", ""); + //variables.put("networkId", "networkId"); + variables.put("serviceType", "vMOG"); + variables.put("vfModuleType", ""); + variables.put("networkType", "modelName"); + + return variables; + + } + + public String getCreateNetworkRequestVID1() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelCustomizationId\": \"f21df226-8093-48c3-be7e-0408fcda0422\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1.0\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_1\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"false\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"backoutOnFailure\": false, " + '\n' + + " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + return request; + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java index e70f48d758..d361d1e511 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleVolumeInfraV1Test.java @@ -20,6 +20,10 @@ package org.openecomp.mso.bpmn.infrastructure; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteVolumeGroupById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupByName; @@ -27,6 +31,7 @@ import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceIn import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVolumeGroupById; import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPostVNFVolumeGroup; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroupRollback; import java.io.IOException; import java.util.HashMap; @@ -34,10 +39,12 @@ import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; import org.openecomp.mso.bpmn.mock.FileUtil; +import org.openecomp.mso.bpmn.mock.StubResponseAAI; public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { @@ -48,6 +55,8 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { public CreateVfModuleVolumeInfraV1Test() throws IOException { callbacks.put("volumeGroupCreate", FileUtil.readResourceFile( "__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeCallbackResponse.xml")); + callbacks.put("volumeGroupDelete", FileUtil.readResourceFile( + "__files/DeleteVfModuleVolumeInfraV1/DeleteVfModuleVolumeCallbackResponse.xml")); callbacks.put("volumeGroupException", FileUtil.readResourceFile( "__files/CreateVfModuleVolumeInfraV1/CreateVfModuleCallbackException.xml")); callbacks.put("volumeGroupRollback", FileUtil.readResourceFile( @@ -58,9 +67,10 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { * Happy path scenario for VID *****************************/ @Test + //@Ignore @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", "subprocess/GenericGetService.bpmn", - "subprocess/DoCreateVfModuleVolumeV1.bpmn", + "subprocess/DoCreateVfModuleVolumeV2.bpmn", "subprocess/FalloutHandler.bpmn", "subprocess/CompleteMsoProcess.bpmn", "subprocess/VnfAdapterRestV1.bpmn"}) @@ -99,10 +109,62 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { logEnd(); } + /** + * Fail - trigger rollback + *****************************/ + @Test + //@Ignore + @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/DoCreateVfModuleVolumeV2.bpmn", + "subprocess/DoCreateVfModuleVolumeRollback.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/VnfAdapterRestV1.bpmn"}) + public void TestRollback() throws Exception { + + logStart(); + + MockNodeQueryServiceInstanceById("test-service-instance-id", "CreateVfModuleVolumeInfraV1/getSIUrlById.xml"); + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockPutVolumeGroupById("AAIAIC25", "TEST-VOLUME-GROUP-ID-0123", "CreateVfModuleVolumeInfraV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml", 201); + mockPostVNFVolumeGroup(202); + mockPutVNFVolumeGroupRollback("TEST-VOLUME-GROUP-ID-0123", 202); + MockDeleteVolumeGroupById("AAIAIC25", "8424bb3c-c3e7-4553-9662-469649ed9379", "1460134360", 202); + StubResponseAAI.MockGetVolumeGroupByName_404("AAIAIC25", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); + StubResponseAAI.MockGetVolumeGroupByName("AAIAIC25", "MSOTESTVOL101a-vSAMP12_base_vol_module-0", "CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml", 200); + StubResponseAAI.MockDeleteVolumeGroup("AAIAIC25", "8424bb3c-c3e7-4553-9662-469649ed9379", "1460134360"); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleVolRequest = FileUtil.readResourceFile("__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); + testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + + TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleVolumeInfraV1", "v1", businessKey, createVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 1000000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); + injectVNFRestCallbacks(callbacks, "volumeGroupDelete"); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "CVMVINFRAV1_SuccessIndicator", false); + + logEnd(); + } + /** * Happy path scenario for VID *****************************/ @Test + @Ignore @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/DoCreateVfModuleVolumeV1.bpmn", @@ -145,7 +207,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { *Vnf Create fail *****************************/ @Test - //@Ignore + @Ignore @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/DoCreateVfModuleVolumeV1.bpmn", @@ -193,7 +255,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { * Error scenario - vnf not found ********************************/ @Test - //@Ignore + @Ignore @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/DoCreateVfModuleVolumeV1.bpmn", @@ -233,7 +295,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { * Error scenario - error in validation **************************************/ @Test - //@Ignore + @Ignore @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/DoCreateVfModuleVolumeV1.bpmn", @@ -270,7 +332,7 @@ public class CreateVfModuleVolumeInfraV1Test extends WorkflowTest { * Error scenario - service instance not found *********************************************/ @Test - //@Ignore + @Ignore @Deployment(resources = {"process/CreateVfModuleVolumeInfraV1.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/DoCreateVfModuleVolumeV1.bpmn", diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java index 80c1e8c215..48705220c4 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVnfInfraTest.java @@ -44,6 +44,7 @@ import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; import org.openecomp.mso.bpmn.common.WorkflowTest; @@ -134,6 +135,7 @@ public class CreateVnfInfraTest extends WorkflowTest { } @Test + @Ignore @Deployment(resources = {"subprocess/DoCreateVnf.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/GenericGetVnf.bpmn", "subprocess/GenericPutVnf.bpmn", "process/CreateVnfInfra.bpmn", "subprocess/FalloutHandler.bpmn", "subprocess/CompleteMsoProcess.bpmn"}) public void testCreateVnfInfra_error_siNotFound() throws Exception{ @@ -151,6 +153,7 @@ public class CreateVnfInfraTest extends WorkflowTest { } @Test + @Ignore @Deployment(resources = {"subprocess/DoCreateVnf.bpmn", "subprocess/GenericGetService.bpmn", "subprocess/GenericGetVnf.bpmn", diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java new file mode 100644 index 0000000000..d9e882b612 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteGenericALaCarteServiceInstanceTest.java @@ -0,0 +1,91 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + +/** + * Unit test cases for DelServiceInstance.bpmn + */ +public class DeleteGenericALaCarteServiceInstanceTest extends WorkflowTest { + + public DeleteGenericALaCarteServiceInstanceTest() throws IOException { + } + + /** + * Sunny day VID scenario. + * + * @throws Exception + */ + @Ignore // IGNORED FOR 1710 MERGE TO ONAP + @Test + @Deployment(resources = { + "process/DeleteGenericALaCarteServiceInstance.bpmn", + "subprocess/DoDeleteServiceInstance.bpmn", + "subprocess/GenericDeleteService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" }) + public void sunnyDayAlaCarte() throws Exception { + + logStart(); + + //AAI + MockDeleteServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", ""); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml"); + MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); + //DB + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + + Map variables = setupVariables(); + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "DeleteGenericALaCarteServiceInstance", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "DeleteGenericALaCarteServiceInstance", "WorkflowResponse"); + //assertNotNull(workflowResp); + System.out.println("Workflow (Synch) Response:\n" + workflowResp); + String workflowException = BPMNUtil.getVariable(processEngineRule, "DeleteGenericALaCarteServiceInstance", "WorkflowException"); + String completionReq = BPMNUtil.getVariable(processEngineRule, "DeleteGenericALaCarteServiceInstance", "completionRequest"); + System.out.println("completionReq:\n" + completionReq); + System.out.println("workflowException:\n" + workflowException); + assertNotNull(completionReq); + assertEquals(null, workflowException); + + logEnd(); + } + + // Success Scenario + private Map setupVariables() { + Map variables = new HashMap(); + variables.put("isDebugLogEnabled", "true"); + variables.put("bpmnRequest", getRequest()); + variables.put("mso-request-id", "RaaTestRequestId-1"); + variables.put("serviceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); + return variables; + } + + public String getRequest() { + String request = "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SDN-ETHERNET-INTERNET\",\"subscriberName\":\"\"},\"requestInfo\":{\"instanceName\":\"1604-MVM-26\",\"source\":\"VID\",\"suppressRollback\":\"true\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\"},\"requestParameters\":{\"subscriptionServiceType\":\"123456789\",\"aLaCarte\":\"false\",\"userParams\":\"somep\"}}}"; + return request; + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java new file mode 100644 index 0000000000..0da2526fc1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DeleteNetworkInstanceTest.java @@ -0,0 +1,321 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeAsyncWorkflow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.getVariable; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapterContainingRequest; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapterTopology; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.SDNCAdapterCallbackRule; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.WorkflowTestTransformer; +import org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer; + +import com.github.tomakehurst.wiremock.extension.ResponseTransformer; + + +/** + * Unit test cases for DeleteNetworkInstance.bpmn + * + */ +//@Ignore +public class DeleteNetworkInstanceTest extends WorkflowTest { + @WorkflowTestTransformer + public static final ResponseTransformer sdncAdapterMockTransformer = + new SDNCAdapterNetworkTopologyMockTransformer(); + + @Rule + public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = + new SDNCAdapterCallbackRule(processEngineRule); + + /** + * End-to-End flow - Unit test for DeleteNetworkInstance.bpmn + * - String input & String response + */ + + @Test + //@Ignore + @Deployment(resources = {"process/DeleteNetworkInstance.bpmn", + "subprocess/DoDeleteNetworkInstance.bpmn", + "subprocess/DoDeleteNetworkInstanceRollback.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceDeleteNetworkInstance_VID_Success() throws Exception { + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success VID - DeleteNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml", "SvcAction>delete"); + MockNetworkAdapter("bdc5efe8-404a-409b-85f6-0dcc9eebae30", 200, "deleteNetworkResponse_Success.xml"); + MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "1"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockGetCloudRegion("RDM2WAGPLCP", 200, "DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + + Map variables = new HashMap(); + variables.put("mso-request-id", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("isBaseVfModule", "true"); + variables.put("recipeTimeout", "0"); + variables.put("requestAction", "DELETE"); + variables.put("serviceInstanceId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("vnfId", ""); + variables.put("vfModuleId", ""); + variables.put("volumeGroupId", ""); + variables.put("networkId", "bdc5efe8-404a-409b-85f6-0dcc9eebae30"); + variables.put("serviceType", "MOG"); + variables.put("vfModuleType", ""); + variables.put("networkType", "modelName"); + variables.put("bpmnRequest", getDeleteNetworkInstanceInfraRequest()); + + executeAsyncWorkflow(processEngineRule, "DeleteNetworkInstance", variables); + + Assert.assertNotNull("DELNI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_CompleteMsoProcessRequest")); + Assert.assertEquals("true", getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_Success")); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "DeleteNetworkInstance", "WorkflowResponse"); + Assert.assertNotNull(workflowResp); + System.out.println("DeleteNetworkInstanceTest.shouldInvokeServiceDeleteNetworkInstance_Success() WorkflowResponse:\n" + workflowResp); + + String completeMsoProcessRequest = + "" + '\n' + + " " + '\n' + + " testRequestId" + '\n' + + " DELETE" + '\n' + + " VID" + '\n' + + " " + '\n' + + " Network has been deleted successfully." + '\n' + + " BPMN Network action: DELETE" + '\n' + + ""; + + Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_CompleteMsoProcessRequest")); + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success VID - DeleteNetworkInstance flow Completed "); + System.out.println("----------------------------------------------------------"); + + + } + + @Test + //@Ignore + @Deployment(resources = {"process/DeleteNetworkInstance.bpmn", + "subprocess/DoDeleteNetworkInstance.bpmn", + //"subprocess/DoDeleteNetworkInstanceRollback.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceDeleteNetworkInstance_vIPER_Success() throws Exception { + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success vIPER - DeleteNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml", "SvcAction>unassign"); + mockSDNCAdapterTopology("DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml", "SvcAction>deactivate"); + MockNetworkAdapter("bdc5efe8-404a-409b-85f6-0dcc9eebae30", 200, "deleteNetworkResponse_Success.xml"); + MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "1"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockGetCloudRegion("RDM2WAGPLCP", 200, "DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + + String networkModelInfo = " {\"modelName\": \"modelName\", " + '\n' + + " \"networkType\": \"modelName\" }"; + + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("serviceInstanceId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("networkId", "bdc5efe8-404a-409b-85f6-0dcc9eebae30"); + variables.put("networkName", "HSL_direct_net_2"); + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "88a6ca3ee0394ade9403f075db23167e"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("disableRollback", "false"); // 1702 + variables.put("failIfExists", "false"); + //variables.put("sdncVersion", "1702"); + variables.put("sdncVersion", "1707"); + variables.put("subscriptionServiceType", "MSO-dev-service-type"); + variables.put("networkModelInfo", networkModelInfo); + + executeAsyncWorkflow(processEngineRule, "DeleteNetworkInstance", variables); + + Assert.assertNotNull("DELNI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_CompleteMsoProcessRequest")); + Assert.assertEquals("true", getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_Success")); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "DeleteNetworkInstance", "WorkflowResponse"); + Assert.assertNotNull(workflowResp); + System.out.println("DeleteNetworkInstanceTest.shouldInvokeServiceDeleteNetworkInstance_vIPER_Success() WorkflowResponse:\n" + workflowResp); + + String completeMsoProcessRequest = + "" + '\n' + + " " + '\n' + + " testRequestId" + '\n' + + " DELETE" + '\n' + + " VID" + '\n' + + " " + '\n' + + " Network has been deleted successfully." + '\n' + + " BPMN Network action: DELETE" + '\n' + + ""; + + Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_CompleteMsoProcessRequest")); + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success VID - DeleteNetworkInstance flow Completed "); + System.out.println("----------------------------------------------------------"); + + + } + + @Test + //@Ignore + @Deployment(resources = {"process/DeleteNetworkInstance.bpmn", + "subprocess/DoDeleteNetworkInstance.bpmn", + "subprocess/DoDeleteNetworkInstanceRollback.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceDeleteNetworkInstanceInfra_vIPER_Rollback() throws Exception { + // Rollback is not Applicable for DeleteNetwork (no requirements). Rollback should not be invoked. + System.out.println("----------------------------------------------------------"); + System.out.println(" Rollback - DeleteNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------"); + + // setup simulatores + mockSDNCAdapter("/SDNCAdapter", "SvcAction>unassign", 500, ""); + mockSDNCAdapterTopology("DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml", "SvcAction>deactivate"); + mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml", "SvcAction>activate"); + MockNetworkAdapter("bdc5efe8-404a-409b-85f6-0dcc9eebae30", 200, "deleteNetworkResponse_Success.xml"); + MockNetworkAdapterContainingRequest("createNetworkRequest", 200, "CreateNetworkV2/createNetworkResponse_Success.xml"); + MockGetNetworkByIdWithDepth ("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "1"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockGetCloudRegion("RDM2WAGPLCP", 200, "DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + + String networkModelInfo = " {\"modelCustomizationId\": \"uuid-nrc-001-1234\", " + '\n' + + " \"modelInvariantId\": \"was-ist-das-001-1234\" }"; + + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("serviceInstanceId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("networkId", "bdc5efe8-404a-409b-85f6-0dcc9eebae30"); + variables.put("networkName", "HSL_direct_net_2"); + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "88a6ca3ee0394ade9403f075db23167e"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("disableRollback", "false"); // 1702 + variables.put("failIfExists", "false"); + variables.put("sdncVersion", "1702"); + variables.put("subscriptionServiceType", "MSO-dev-service-type"); + variables.put("networkModelInfo", networkModelInfo); + + executeAsyncWorkflow(processEngineRule, "DeleteNetworkInstance", variables); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "DeleteNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "DeleteNetworkInstance", "WorkflowResponse"); + Assert.assertNotNull(workflowResp); + + Assert.assertNotNull("DELNI_FalloutHandlerRequest - ", getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_FalloutHandlerRequest")); + Assert.assertEquals("false", getVariable(processEngineRule, "DeleteNetworkInstance", "DELNI_Success")); + Assert.assertEquals("false", BPMNUtil.getVariable(processEngineRule, "DoDeleteNetworkInstance", "DELNWKI_Success")); + + System.out.println("----------------------------------------------------------"); + System.out.println(" Rollback - DeleteNetworkInstanceModular flow Completed "); + System.out.println("----------------------------------------------------------"); + + + } + + + // ***************** + // Utility Section + // ***************** + + public String getDeleteNetworkInstanceInfraRequest() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelCustomizationId\": \"f21df226-8093-48c3-be7e-0408fcda0422\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1.0\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"HSL_direct_net_2\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"suppressRollback\": \"false\", " + '\n' + + " \"callbackUrl\": \"\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"backoutOnFailure\": true, " + '\n' + + " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + + " \"userParams\": {} " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + return request; + + } + + + public String getDeleteNetworkInstanceInfraRequest_MissingId() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelId\": \"modelId\", " + '\n' + + " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"HSL_direct_net_2\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"backoutOnFailure\": true, " + '\n' + + " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + return request; + + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java new file mode 100644 index 0000000000..f2c9680075 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateSIRollbackTest.java @@ -0,0 +1,179 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.RollbackData; + +/** + * Unit test cases for DoCreateServiceInstanceRollback.bpmn + */ +public class DoCreateSIRollbackTest extends WorkflowTest { + private static final String EOL = "\n"; + private final CallbackSet callbacks = new CallbackSet(); + private final String sdncAdapterCallback = + "" + EOL + + " ((REQUEST-ID))" + EOL + + " Y" + EOL + + "" + EOL; + + public DoCreateSIRollbackTest() throws IOException { + callbacks.put("deactivate", sdncAdapterCallback); + callbacks.put("delete", sdncAdapterCallback); + } + + /** + * Sunny day VID scenario. + * + * @throws Exception + */ + //@Ignore // File not found - unable to run the test. Also, Stubs need updating.. + @Test + @Deployment(resources = { + "subprocess/DoCreateServiceInstanceRollback.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericDeleteService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" }) + public void sunnyDay() throws Exception { + + logStart(); + + //AAI + MockDeleteServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", ""); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml"); + MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); + //SDNC + mockSDNCAdapter(200); + //DB + mockUpdateRequestDB(200, "DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map variables = new HashMap(); + setupVariables(variables); + invokeSubProcess("DoCreateServiceInstanceRollback", businessKey, variables); + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + waitForProcessEnd(businessKey, 10000); + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateServiceInstanceRollback", "WorkflowException"); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + + logEnd(); + } + + // Success Scenario + private void setupVariables(Map variables) { + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "RaaTestRequestId-1"); + variables.put("mso-request-id", "RaaTestRequestId-1"); + variables.put("serviceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); + + RollbackData rollbackData = new RollbackData(); + + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); + rollbackData.put("SERVICEINSTANCE", "globalCustomerId", "SDN-ETHERNET-INTERNET"); + rollbackData.put("SERVICEINSTANCE", "serviceSubscriptionType", "123456789"); + rollbackData.put("SERVICEINSTANCE", "disablerollback", "false"); + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true"); + rollbackData.put("SERVICEINSTANCE", "rollbackSDNC", "true"); + + String req = "" + EOL + + "" + EOL + + "b043d290-140d-4a38-a9b6-95d3b8bd27d4" + EOL + + "MIS%252F1604%252F0026%252FSW_INTERNET" + EOL + + "deactivate" + EOL + + "service-topology-operation" + EOL + + "http://localhost:8080/mso/SDNCAdapterCallbackService" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "RaaTestRequestId-1" + EOL + + "MSO" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "DeleteServiceInstance" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "123456789" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "MIS%252F1604%252F0026%252FSW_INTERNET" + EOL + + "" + EOL + + "SDN-ETHERNET-INTERNET" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + ""; + + String req1 = "" + EOL + + "" + EOL + + "bca4fede-0804-4c13-af69-9e80b378150f" + EOL + + "MIS%252F1604%252F0026%252FSW_INTERNET" + EOL + + "delete" + EOL + + "service-topology-operation" + EOL + + "http://localhost:8080/mso/SDNCAdapterCallbackService" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "RaaTestRequestId-1" + EOL + + "MSO" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "DeleteServiceInstance" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "123456789" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "MIS%252F1604%252F0026%252FSW_INTERNET" + EOL + + "" + EOL + + "SDN-ETHERNET-INTERNET" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + "" + EOL + + ""; + + rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", req); + + rollbackData.put("SERVICEINSTANCE", "sdncDelete",req1); + variables.put("rollbackData",rollbackData); + + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java new file mode 100644 index 0000000000..359a372098 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateServiceInstanceTest.java @@ -0,0 +1,98 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; + +/** + * Unit test cases for DoCreateServiceInstance.bpmn + */ +public class DoCreateServiceInstanceTest extends WorkflowTest { + private static final String EOL = "\n"; + private final CallbackSet callbacks = new CallbackSet(); + private final String sdncAdapterCallback = + "" + EOL + + " ((REQUEST-ID))" + EOL + + " Y" + EOL + + "" + EOL; + + public DoCreateServiceInstanceTest() throws IOException { + callbacks.put("assign", sdncAdapterCallback); + } + + /** + * Sunny day VID scenario. + * + * @throws Exception + */ + //@Ignore // File not found - unable to run the test. Also, Stubs need updating.. + @Test + @Deployment(resources = { + "subprocess/DoCreateServiceInstance.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericPutService.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/DoCreateServiceInstanceRollback.bpmn", + "subprocess/FalloutHandler.bpmn" }) + public void sunnyDay() throws Exception { + + logStart(); + + //AAI + MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml"); + MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-si-id", ""); + MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-si-id", "GenericFlows/getServiceInstance.xml"); + MockNodeQueryServiceInstanceByName("RAATest-si", ""); + + MockNodeQueryServiceInstanceById("RaaTest-si-id", ""); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml"); + MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); + //SDNC + mockSDNCAdapter(200); + //DB + mockUpdateRequestDB(200, "DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map variables = new HashMap(); + setupVariables(variables); + invokeSubProcess("DoCreateServiceInstance", businessKey, variables); + injectSDNCCallbacks(callbacks, "assign"); + waitForProcessEnd(businessKey, 10000); + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateServiceInstance", "WorkflowException"); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + + logEnd(); + } + + // Success Scenario + private void setupVariables(Map variables) { + variables.put("mso-request-id", "RaaDSITest1"); + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "RaaDSITestRequestId-1"); + variables.put("serviceInstanceId","RaaTest-si-id"); + variables.put("serviceModelInfo", "{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\"}"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("globalSubscriberId", "MCBH-1610"); + variables.put("subscriptionServiceType", "viprsvc"); + variables.put("instanceName", "RAATest-1"); + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java index 5b0d4c73bd..ea46bfe8a2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleRollbackTest.java @@ -136,7 +136,8 @@ public class DoCreateVfModuleRollbackTest extends WorkflowTest { variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); rollbackData.put("VFMODULE", "msorequestid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); rollbackData.put("VFMODULE", "serviceinstanceid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); - variables.put("RollbackData", rollbackData); + variables.put("rollbackData", rollbackData); + variables.put("sdncVersion", "1702"); invokeSubProcess("DoCreateVfModuleRollback", businessKey, variables); // "changedelete" operation not required for deleting a Vf Module diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java index fc4816cef3..565ef0285a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleTest.java @@ -22,8 +22,11 @@ package org.openecomp.mso.bpmn.infrastructure; import static org.openecomp.mso.bpmn.common.BPMNUtil.getRawVariable; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; @@ -38,10 +41,8 @@ import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet; import org.openecomp.mso.bpmn.mock.FileUtil; /** @@ -56,6 +57,12 @@ public class DoCreateVfModuleTest extends WorkflowTest { "__files/VfModularity/SDNCTopologyAssignCallback.xml")); callbacks.put("query", FileUtil.readResourceFile( "__files/VfModularity/SDNCTopologyQueryCallback.xml")); + callbacks.put("queryVnf", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml")); + callbacks.put("queryModuleNoVnf", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml")); + callbacks.put("queryModule", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml")); callbacks.put("activate", FileUtil.readResourceFile( "__files/VfModularity/SDNCTopologyActivateCallback.xml")); callbacks.put("vnfCreate", FileUtil.readResourceFile( @@ -66,10 +73,11 @@ public class DoCreateVfModuleTest extends WorkflowTest { * Test the sunny day scenario. */ @Test - @Ignore + @Deployment(resources = { "subprocess/DoCreateVfModule.bpmn", "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", @@ -82,6 +90,54 @@ public class DoCreateVfModuleTest extends WorkflowTest { logStart(); + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + mockVNFPost("", 202, "skask"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + //RuntimeService runtimeService = processEngineRule.getRuntimeService(); + + Map variables = setupVariablesSunnyDayBuildingBlocks(); + //runtimeService.startProcessInstanceByKey("DoCreateVfModule", variables); + invokeSubProcess("DoCreateVfModule", businessKey, variables); + + injectSDNCCallbacks(callbacks, "queryVnf"); + injectSDNCCallbacks(callbacks, "assign, queryModuleNoVnf"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + Assert.assertTrue((boolean) getRawVariable(processEngineRule, "DoCreateVfModule", "DCVFM_SuccessIndicator")); + + logEnd(); + } + + /** + * Test the sunny day scenario with 1702 SDNC interaction. + */ + @Test + + @Deployment(resources = { + "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn" + }) + public void sunnyDay_1702() throws IOException { + + logStart(); + MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); @@ -91,11 +147,72 @@ public class DoCreateVfModuleTest extends WorkflowTest { mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); mockVNFPost("", 202, "skask"); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); String businessKey = UUID.randomUUID().toString(); //RuntimeService runtimeService = processEngineRule.getRuntimeService(); Map variables = setupVariablesSunnyDayBuildingBlocks(); + variables.put("sdncVersion", "1702"); + //runtimeService.startProcessInstanceByKey("DoCreateVfModule", variables); + invokeSubProcess("DoCreateVfModule", businessKey, variables); + + + injectSDNCCallbacks(callbacks, "assign, queryModule"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + Assert.assertTrue((boolean) getRawVariable(processEngineRule, "DoCreateVfModule", "DCVFM_SuccessIndicator")); + + logEnd(); + } + + /** + * Test the sunny day scenario. + */ + @Test + + @Deployment(resources = { + "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenerateVfModuleName.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn" + }) + public void sunnyDay_withVfModuleNameGeneration() throws IOException { + + logStart(); + + MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); + MockPutNetwork(".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200); + MockPutGenericVnf("skask"); + MockAAIVfModule(); + mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); + mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); + mockVNFPost("", 202, "skask"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + + String businessKey = UUID.randomUUID().toString(); + //RuntimeService runtimeService = processEngineRule.getRuntimeService(); + + Map variables = setupVariablesSunnyDayBuildingBlocks(); + variables.put("vfModuleName", null); + variables.put("vfModuleLabel", "MODULELABEL"); + variables.put("sdncVersion", "1702"); //runtimeService.startProcessInstanceByKey("DoCreateVfModule", variables); invokeSubProcess("DoCreateVfModule", businessKey, variables); @@ -111,11 +228,19 @@ public class DoCreateVfModuleTest extends WorkflowTest { logEnd(); } + private Map setupVariablesSunnyDayBuildingBlocks() { Map variables = new HashMap(); + //try { + // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); + //} + //catch (Exception e) { + + //} variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); + + variables.put("msoRequestId", "testRequestId"); variables.put("isBaseVfModule", false); variables.put("isDebugLogEnabled", "true"); variables.put("disableRollback", "true"); @@ -123,6 +248,7 @@ public class DoCreateVfModuleTest extends WorkflowTest { //variables.put("requestAction", "CREATE_VF_MODULE"); variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); variables.put("vnfId", "skask"); + variables.put("vnfName", "vnfname"); variables.put("vfModuleName", "PCRF::module-0-2"); variables.put("vnfType", "vSAMP12"); variables.put("vfModuleId", ""); @@ -131,20 +257,40 @@ public class DoCreateVfModuleTest extends WorkflowTest { variables.put("vfModuleType", ""); variables.put("isVidRequest", "true"); variables.put("asdcServiceModelVersion", "1.0"); + variables.put("usePreload", true); - String vfModuleModelInfo = "{" + "\"modelInfo\": { "+ "\"modelType\": \"vfModule\"," + - "\"modelInvariantId\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + - "\"modelNameVersionId\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + String vfModuleModelInfo = "{ "+ "\"modelType\": \"vfModule\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + "\"modelName\": \"STMTN5MMSC21-MMSC::model-1-0\"," + "\"modelVersion\": \"1\"," + - "\"modelCustomizationId\": \"MODEL-123\"" + "}}"; + "\"modelCustomizationUuid\": \"MODEL-123\"" + "}"; variables.put("vfModuleModelInfo", vfModuleModelInfo); - String cloudConfiguration = "{" + "\"cloudConfiguration\": { " + - "\"lcpCloudRegionId\": \"MDTWNJ21\"," + - "\"tenantId\": \"fba1bd1e195a404cacb9ce17a9b2b421\"" + "}}"; - variables.put("cloudConfiguration", cloudConfiguration); + variables.put("sdncVersion", "1707"); + + variables.put("lcpCloudRegionId", "MDTWNJ21"); + variables.put("tenantId", "fba1bd1e195a404cacb9ce17a9b2b421"); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"aa5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"bb6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"SVC-STMTN5MMSC21-MMSC::model-1-0\"," + + "\"modelVersion\": \"1\"," + + "}"; + variables.put("serviceModelInfo", serviceModelInfo); + + String vnfModelInfo = "{ "+ "\"modelType\": \"vnf\"," + + "\"modelInvariantUuid\": \"445256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"f26478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"VNF-STMTN5MMSC21-MMSC::model-1-0\"," + + "\"modelVersion\": \"1\"," + + "\"modelCustomizationUuid\": \"VNF-MODEL-123\"" + "}"; + variables.put("vnfModelInfo", vnfModelInfo); + + variables.put("vnfQueryPath", "/restconf/vnfQueryPath"); + return variables; } -} +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV1Test.java deleted file mode 100644 index c7a112d5aa..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV1Test.java +++ /dev/null @@ -1,351 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.infrastructure; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet; -import org.openecomp.mso.bpmn.mock.FileUtil; - -public class DoCreateVfModuleVolumeV1Test extends WorkflowTest { - - public static final String _prefix = "CVFMODVOL2_"; - - private final CallbackSet callbacks = new CallbackSet(); - - public DoCreateVfModuleVolumeV1Test() throws IOException { - callbacks.put("volumeGroupCreate", FileUtil.readResourceFile( - "__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeCallbackResponse.xml")); - callbacks.put("volumeGroupRollback", FileUtil.readResourceFile( - "__files/DoCreateVfModuleVolumeV1/RollbackVfModuleVolumeCallbackResponse.xml")); - } - - /** - * Happy Path - * @throws Exception - */ - @Test - @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn"}) - public void TestHappyPath() throws Exception { - - logStart(); - - DoCreateVfModuleVolume_Success(); - - String businessKey = UUID.randomUUID().toString(); - String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); - - Map testVariables = new HashMap(); - testVariables.put("DCVFMODVOLV1_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); - testVariables.put("vnf-id", "TEST-VNF-ID-0123"); - testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); - //testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); - invokeAsyncProcess("DoCreateVfModuleVolumeV1", "v1", businessKey, createVfModuleVolRequest, testVariables); - - injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); - - waitForProcessEnd(businessKey, 100000); - checkVariable(businessKey, "DCVFMODVOLV1_SuccessIndicator", true); - - logEnd(); - } - - @Test - @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn"}) - public void TestVolumeGroupExistError() throws Exception { - - logStart(); - - DoCreateVfModuleVolume_VolumeGroupExistsFail(); - - String businessKey = UUID.randomUUID().toString(); - String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); - - Map testVariables = new HashMap(); - testVariables.put("DCVFMODVOLV1_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); - testVariables.put("vnf-id", "TEST-VNF-ID-0123"); - testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); - testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); - invokeAsyncProcess("DoCreateVfModuleVolumeV1", "v1", businessKey, createVfModuleVolRequest, testVariables); - - //injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); - - waitForProcessEnd(businessKey, 100000); - checkVariable(businessKey, "DCVFMODVOLV1_SuccessIndicator", false); - - logEnd(); - } - - /** - * Will trigger AAI create rollback - * @throws Exception - */ - @Test - @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn"}) - public void TestVnfVolumeGroupCreateError() throws Exception { - - logStart(); - - DoCreateVfModuleVolume_VnfCreateVolumeGroupFail(); - - String businessKey = UUID.randomUUID().toString(); - String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); - - Map testVariables = new HashMap(); - testVariables.put("DCVFMODVOLV1_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); - testVariables.put("vnf-id", "TEST-VNF-ID-0123"); - testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); - testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); - invokeAsyncProcess("DoCreateVfModuleVolumeV1", "v1", businessKey, createVfModuleVolRequest, testVariables); - - //injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); - - waitForProcessEnd(businessKey, 100000); - checkVariable(businessKey, "DCVFMODVOLV1_SuccessIndicator", false); - - logEnd(); - } - - /** - * Will trigger AAI create rollback - * @throws Exception - */ - @Test - @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn"}) - public void TestUpdateAaiVolumeGroupError() throws Exception { - - logStart(); - - DoCreateVfModuleVolume_AaiVolumeGroupUpdateFail(); - - String businessKey = UUID.randomUUID().toString(); - String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); - - Map testVariables = new HashMap(); - testVariables.put("DCVFMODVOLV1_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); - testVariables.put("vnf-id", "TEST-VNF-ID-0123"); - testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); - testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); - invokeAsyncProcess("DoCreateVfModuleVolumeV1", "v1", businessKey, createVfModuleVolRequest, testVariables); - - injectVNFRestCallbacks(callbacks, "volumeGroupCreate,volumeGroupRollback"); - - waitForProcessEnd(businessKey, 100000); - checkVariable(businessKey, "DCVFMODVOLV1_SuccessIndicator", false); - - logEnd(); - } - - /** - * Will trigger not trigger rollback - * @throws Exception - */ - @Test - @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn"}) - public void TestUpdateAaiVolumeGroupErrorNoRollback() throws Exception { - - logStart(); - - DoCreateVfModuleVolume_AaiVolumeGroupUpdateFail(); - - String businessKey = UUID.randomUUID().toString(); - String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml"); - - Map testVariables = new HashMap(); - testVariables.put("DCVFMODVOLV1_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); - testVariables.put("vnf-id", "TEST-VNF-ID-0123"); - testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); - testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); - testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); - invokeAsyncProcess("DoCreateVfModuleVolumeV1", "v1", businessKey, createVfModuleVolRequest, testVariables); - - injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); - - waitForProcessEnd(businessKey, 100000); - checkVariable(businessKey, "DCVFMODVOLV1_SuccessIndicator", false); - - logEnd(); - } - - public static void DoCreateVfModuleVolume_Success() { - // Notes: - // 1. initial aai volume group by name - /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group?volume-group-name=TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0 - // 2. Create volume group - /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group - // 3. Requery Volume Group - /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group?volume-group-name=MSOTESTVOL101a-vSAMP12_base_vol_module-0 - // 4. Update volume group (id from requery response - /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/8424bb3c-c3e7-4553-9662-469649ed9379 - - //generic vnf - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/TEST-VNF-ID-0123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/GenericVnf.xml"))); - //create volume group - stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/TEST-VOLUME-GROUP-ID-0123")) - .willReturn(aResponse() - .withStatus(201) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml"))); - //requery volume group - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups[?]volume-group-name=MSOTESTVOL101a-vSAMP12_base_vol_module-0")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml"))); - //update volume group - stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/8424bb3c-c3e7-4553-9662-469649ed9379")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml"))); - // VNF rest Adapter - stubFor(post(urlEqualTo("/vnfs/v1/volume-groups")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - } - - public static void DoCreateVfModuleVolume_VolumeGroupExistsFail() { - //generic vnf - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/TEST-VNF-ID-0123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/GenericVnf.xml"))); - //initial volume group query - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group[?]volume-group-name=TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml"))); - } - - public static void DoCreateVfModuleVolume_VnfCreateVolumeGroupFail() { - //generic vnf - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/TEST-VNF-ID-0123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/GenericVnf.xml"))); - //create volume group - stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/TEST-VOLUME-GROUP-ID-0123")) - .willReturn(aResponse() - .withStatus(201) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml"))); - //Query AAI volume group by name -- needed before delete - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups[?]volume-group-name=MSOTESTVOL101a-vSAMP12_base_vol_module-0")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml"))); - //delete volume group in aai - stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/8424bb3c-c3e7-4553-9662-469649ed9379[?]resource-version=1460134360")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml"))); - stubFor(post(urlEqualTo("/vnfs/v1/volume-groups")) - .willReturn(aResponse() - .withStatus(404) - .withHeader("Content-Type", "application/xml"))); - } - - public static void DoCreateVfModuleVolume_AaiVolumeGroupUpdateFail() { - //generic vnf - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/TEST-VNF-ID-0123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/GenericVnf.xml"))); - //create volume group - stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/TEST-VOLUME-GROUP-ID-0123")) - .willReturn(aResponse() - .withStatus(201) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml"))); - //requery volume group - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups[?]volume-group-name=MSOTESTVOL101a-vSAMP12_base_vol_module-0")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml"))); - //delete volume group in aai - stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/8424bb3c-c3e7-4553-9662-469649ed9379[?]resource-version=1460134360")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml"))); - // VNF rest Adapter - stubFor(post(urlEqualTo("/vnfs/v1/volume-groups")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - // VNF Rest Adapter rollback - vnfs/v1/volume-groups/STUB-TEST-8424bb3c-c3e7-4553-9662-469649ed9379/rollback - stubFor(delete(urlEqualTo("/vnfs/v1/volume-groups/TEST-VOLUME-GROUP-ID-0123/rollback")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java new file mode 100644 index 0000000000..3b1f4b8faf --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVfModuleVolumeV2Test.java @@ -0,0 +1,220 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.mock.FileUtil; + +@Ignore +public class DoCreateVfModuleVolumeV2Test extends WorkflowTest { + + public static final String _prefix = "CVFMODVOL2_"; + + private final CallbackSet callbacks = new CallbackSet(); + + public DoCreateVfModuleVolumeV2Test() throws IOException { + callbacks.put("volumeGroupCreate", FileUtil.readResourceFile( + "__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeCallbackResponse.xml")); + callbacks.put("volumeGroupRollback", FileUtil.readResourceFile( + "__files/DoCreateVfModuleVolumeV1/RollbackVfModuleVolumeCallbackResponse.xml")); + } + + /** + * Happy Path + * @throws Exception + */ + @Test + //@Ignore + @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV2.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/vnfAdapterRestV1.bpmn", + "subprocess/DoCreateVfModuleVolumeRollback.bpmn"}) + public void TestHappyPath() throws Exception { + + logStart(); + +// DoCreateVfModuleVolume_Success(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); + + Map testVariables = new HashMap(); + testVariables.put("volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + testVariables.put("lcpCloudRegionId", "AAIAIC25"); + testVariables.put("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-01"); + testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + //testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); + TestAsyncResponse asyncResponse = invokeAsyncProcess("DoCreateVfModuleVolumeV2", "v1", businessKey, createVfModuleVolRequest, testVariables); + + injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "DCVFMODVOLV2_SuccessIndicator", true); + + logEnd(); + } + + @Test +// @Ignore + @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV2.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/vnfAdapterRestV1.bpmn", + "subprocess/DoCreateVfModuleVolumeRollback.bpmn"}) + public void TestVolumeGroupExistError() throws Exception { + + logStart(); + +// DoCreateVfModuleVolume_VolumeGroupExistsFail(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); + + Map testVariables = new HashMap(); + testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); + testVariables.put("vnf-id", "TEST-VNF-ID-0123"); + testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); + testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); + TestAsyncResponse asyncResponse = invokeAsyncProcess("DoCreateVfModuleVolumeV2", "v1", businessKey, createVfModuleVolRequest, testVariables); + + //injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); + + waitForProcessEnd(businessKey, 100000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "SavedWorkflowException1"); + Assert.assertTrue(wfe.getErrorCode() == 2500); + Assert.assertTrue(wfe.getErrorMessage().startsWith("Generic vnf null was not found in AAI. Return code: 404.")); + checkVariable(businessKey, "DCVFMODVOLV2_SuccessIndicator", false); + + logEnd(); + } + + /** + * Will trigger AAI create rollback + * @throws Exception + */ + @Test +// @Ignore + @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV2.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/vnfAdapterRestV1.bpmn", + "subprocess/DoCreateVfModuleVolumeRollback.bpmn"}) + public void TestVnfVolumeGroupCreateError() throws Exception { + + logStart(); + +// DoCreateVfModuleVolume_VnfCreateVolumeGroupFail(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); + + Map testVariables = new HashMap(); + testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); + testVariables.put("vnf-id", "TEST-VNF-ID-0123"); + testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); + testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); + TestAsyncResponse asyncResponse = invokeAsyncProcess("DoCreateVfModuleVolumeV2", "v1", businessKey, createVfModuleVolRequest, testVariables); + + //injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "DCVFMODVOLV2_SuccessIndicator", false); + + logEnd(); + } + + /** + * Will trigger AAI create rollback + * @throws Exception + */ + @Test +// @Ignore + @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV2.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/vnfAdapterRestV1.bpmn", + "subprocess/DoCreateVfModuleVolumeRollback.bpmn"}) + public void TestUpdateAaiVolumeGroupError() throws Exception { + + logStart(); + +// DoCreateVfModuleVolume_AaiVolumeGroupUpdateFail(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml"); + + Map testVariables = new HashMap(); + testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); + testVariables.put("vnf-id", "TEST-VNF-ID-0123"); + testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); + testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); + TestAsyncResponse asyncResponse = invokeAsyncProcess("DoCreateVfModuleVolumeV2", "v1", businessKey, createVfModuleVolRequest, testVariables); + + // VNF callback not needed fort this failure scenario +// injectVNFRestCallbacks(callbacks, "volumeGroupCreate,volumeGroupRollback"); + + waitForProcessEnd(businessKey, 100000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "SavedWorkflowException1"); + Assert.assertTrue(wfe.getErrorCode() == 2500); + Assert.assertTrue(wfe.getErrorMessage().startsWith("Generic vnf null was not found in AAI. Return code: 404.")); + checkVariable(businessKey, "DCVFMODVOLV2_SuccessIndicator", false); + + logEnd(); + } + + /** + * Will trigger not trigger rollback + * @throws Exception + */ + @Test +// @Ignore + @Deployment(resources = {"subprocess/DoCreateVfModuleVolumeV2.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/vnfAdapterRestV1.bpmn", + "subprocess/DoCreateVfModuleVolumeRollback.bpmn"}) + public void TestUpdateAaiVolumeGroupErrorNoRollback() throws Exception { + + logStart(); + +// DoCreateVfModuleVolume_AaiVolumeGroupUpdateFail(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleVolRequest = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml"); + + Map testVariables = new HashMap(); + testVariables.put("DCVFMODVOLV2_volumeGroupId", "TEST-VOLUME-VOLUME-GROUP-ID-0123"); + testVariables.put("vnf-id", "TEST-VNF-ID-0123"); + testVariables.put("volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("test-volume-group-name", "TEST-MSOTESTVOL101a-vSAMP12_base_vol_module-0"); + testVariables.put("test-volume-group-id", "TEST-VOLUME-GROUP-ID-0123"); + testVariables.put("DoCreateVfModuleVolumeV1Request", createVfModuleVolRequest); + TestAsyncResponse asyncResponse = invokeAsyncProcess("DoCreateVfModuleVolumeV2", "v1", businessKey, createVfModuleVolRequest, testVariables); + + // VNF callback not needed fort this failure scenario +// injectVNFRestCallbacks(callbacks, "volumeGroupCreate"); + + waitForProcessEnd(businessKey, 100000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "SavedWorkflowException1"); + Assert.assertTrue(wfe.getErrorCode() == 2500); + Assert.assertTrue(wfe.getErrorMessage().startsWith("Generic vnf null was not found in AAI. Return code: 404.")); + checkVariable(businessKey, "DCVFMODVOLV2_SuccessIndicator", false); + + logEnd(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java new file mode 100644 index 0000000000..fb065ab633 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesRollbackTest.java @@ -0,0 +1,405 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFDelete; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVfModuleDelete; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.RollbackData; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test for DoCreateVnfAndModulesRollback.bpmn. + */ +public class DoCreateVnfAndModulesRollbackTest extends WorkflowTest { + private final CallbackSet callbacks = new CallbackSet(); + + private static final String EOL = "\n"; + + + + private final String vnfAdapterDeleteCallback = + "" + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " true" + EOL + + " {{MESSAGE-ID}}" + EOL + + "" + EOL; + + private final String vnfAdapterDeleteCallbackFail = + "" + EOL + + " Error processing request to VNF-Async. Not Found." + EOL + + " INTERNAL" + EOL + + " false" + EOL + + " {{MESSAGE-ID}}" + EOL + + "" + EOL; + + private final String sdncAdapterDeleteCallback = + "" + EOL + + " {{REQUEST-ID}}" + EOL + + " Y" + EOL + + "" + EOL; + + public DoCreateVnfAndModulesRollbackTest() throws IOException { + callbacks.put("sdncChangeDelete", sdncAdapterDeleteCallback); + callbacks.put("sdncDelete", sdncAdapterDeleteCallback); + callbacks.put("vnfDelete", vnfAdapterDeleteCallback); + callbacks.put("vnfDeleteFail", vnfAdapterDeleteCallbackFail); + callbacks.put("deactivate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + } + + @Test + @Ignore + @Deployment(resources = { + "subprocess/DoCreateVnfAndModulesRollback.bpmn", + "subprocess/DoCreateVfModuleRollback.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/DeleteAAIVfModule.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/GenericDeleteVnf.bpmn", + "subprocess/DoDeleteVnf.bpmn" + }) + public void TestDoCreateVnfAndModulesRollbackSuccess_BaseOnly() { + // delete the Base Module and Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73 + String request = + "" + EOL + + " " + EOL + + " DELETE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + logStart(); + mockSDNCAdapter("/SDNCAdapter", "SvcAction>changedelete", 200, "DeleteGenericVNFV1/sdncAdapterResponse.xml"); + mockSDNCAdapter("/SDNCAdapter", "SvcAction>delete", 200, "DeleteGenericVNFV1/sdncAdapterResponse.xml"); + mockVNFDelete(".*", "/.*", 202); + mockVfModuleDelete("78987"); + MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + MockPatchGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721"); + MockGetGenericVnfByName("STMTN5MMSC21", "DoCreateVfModule_getVnfResponse.xml"); + MockGetGenericVnfById("/a27ce5a9-29c4-4c22-a017-6615ac73c721.*", "DoCreateVfModule_getVnfResponse.xml", 200); + MockPutVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + MockDeleteGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721", "0000021"); + MockDeleteVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73", "0000073", 200); + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + RollbackData rollbackData = new RollbackData(); + + rollbackData.put("VFMODULE_BASE", "source", "PORTAL"); + rollbackData.put("VFMODULE_BASE", "vnfid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_BASE", "vnfname", "STMTN5MMSC21"); + rollbackData.put("VFMODULE_BASE", "vnftype", "asc_heat-int"); + rollbackData.put("VFMODULE_BASE", "vfmoduleid", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + rollbackData.put("VFMODULE_BASE", "vfmodulename", "STMTN5MMSC21-MMSC::module-0-0"); + rollbackData.put("VFMODULE_BASE", "tenantid", "fba1bd1e195a404cacb9ce17a9b2b421"); + rollbackData.put("VFMODULE_BASE", "aiccloudregion", "RDM2WAGPLCP"); + rollbackData.put("VFMODULE_BASE", "heatstackid", "thisisaheatstack"); + rollbackData.put("VFMODULE_BASE", "contrailNetworkPolicyFqdn0", "MSOTest:DefaultPolicyFQDN1"); + rollbackData.put("VFMODULE_BASE", "contrailNetworkPolicyFqdn1", "MSOTest:DefaultPolicyFQDN2"); + rollbackData.put("VFMODULE_BASE", "oamManagementV6Address", "2000:abc:bce:1111"); + rollbackData.put("VFMODULE_BASE", "oamManagementV4Address", "127.0.0.1"); + + rollbackData.put("VFMODULE_BASE", "rollbackPrepareUpdateVfModule", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackVnfAdapterCreate", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackUpdateAAIVfModule", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackSDNCRequestActivate", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackCreateAAIVfModule", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackCreateNetworkPoliciesAAI", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackUpdateVnfAAI", "true"); + + rollbackData.put("VNF", "vnfId", "testVnfId123"); + + rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0"); + + variables.put("isDebugLogEnabled","true"); + variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_BASE", "msorequestid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_BASE", "serviceinstanceid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + + variables.put("rollbackData", rollbackData); + invokeSubProcess("DoCreateVnfAndModulesRollback", businessKey, variables); + + // "changedelete" operation not required for deleting a Vf Module +// injectSDNCCallbacks(callbacks, "sdncChangeDelete"); + injectVNFRestCallbacks(callbacks, "vnfDelete"); + //waitForRunningProcessCount("DoCreateVnfAndModulesRollback", 0, 120000); + injectSDNCCallbacks(callbacks, "sdncDelete"); + + waitForProcessEnd(businessKey, 10000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + checkVariable(businessKey, "WorkflowException", null); + if (wfe != null) { + System.out.println("TestCreateVfModuleSuccess: ErrorCode=" + wfe.getErrorCode() + + ", ErrorMessage=" + wfe.getErrorMessage()); + } + logEnd(); + } + + @Test + @Deployment(resources = { + "subprocess/DoCreateVnfAndModulesRollback.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/DeleteAAIVfModule.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/GenericDeleteVnf.bpmn", + "subprocess/DoDeleteVnf.bpmn" + }) + public void TestDoCreateVnfAndModulesRollbackSuccess_vnfOnly() { + // delete the Base Module and Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73 + String request = + "" + EOL + + " " + EOL + + " DELETE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + logStart(); + MockGetGenericVnfById("testVnfId123.*", "GenericFlows/getGenericVnfByNameResponse.xml"); + MockDeleteGenericVnf("testVnfId123", "testReVer123"); + MockDoDeleteVfModule_SDNCSuccess(); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + RollbackData rollbackData = new RollbackData(); + + rollbackData.put("VNF", "vnfId", "testVnfId123"); + rollbackData.put("VNF", "rollbackVnfCreate", "true"); + rollbackData.put("VNF", "rollbackSDNCAssign", "true"); + rollbackData.put("VNF", "rollbackSDNCActivate", "true"); + rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0"); + + + variables.put("isDebugLogEnabled","true"); + variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + + + variables.put("rollbackData", rollbackData); + variables.put("sdncVersion", "1707"); + invokeSubProcess("DoCreateVnfAndModulesRollback", businessKey, variables); + + // "changedelete" operation not required for deleting a Vf Module +// injectSDNCCallbacks(callbacks, "sdncChangeDelete"); + + //waitForRunningProcessCount("DoCreateVnfAndModulesRollback", 0, 120000); + // injectSDNCCallbacks(callbacks, "sdncDelete"); + + waitForProcessEnd(businessKey, 10000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + checkVariable(businessKey, "WorkflowException", null); + if (wfe != null) { + System.out.println("TestCreateVfModuleSuccess: ErrorCode=" + wfe.getErrorCode() + + ", ErrorMessage=" + wfe.getErrorMessage()); + } + logEnd(); + } + + @Test + @Ignore + @Deployment(resources = { + "subprocess/DoCreateVnfAndModulesRollback.bpmn", + "subprocess/DoCreateVfModuleRollback.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/DeleteAAIVfModule.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/GenericDeleteVnf.bpmn", + "subprocess/DoDeleteVnf.bpmn" + }) + public void TestDoCreateVnfAndModulesRollbackSuccess_AddOn() { + // delete the Base Module and Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73 + String request = + "" + EOL + + " " + EOL + + " DELETE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + logStart(); + mockSDNCAdapter("/SDNCAdapter", "SvcAction>changedelete", 200, "DeleteGenericVNFV1/sdncAdapterResponse.xml"); + mockSDNCAdapter("/SDNCAdapter", "SvcAction>delete", 200, "DeleteGenericVNFV1/sdncAdapterResponse.xml"); + mockVNFDelete(".*", "/.*", 202); + mockVfModuleDelete("78987"); + MockGetGenericVnfByName("STMTN5MMSC21", "DoCreateVfModule_getVnfResponse.xml"); + MockGetGenericVnfById("/a27ce5a9-29c4-4c22-a017-6615ac73c721", "DoCreateVfModule_getVnfResponse.xml", 200); + MockGetGenericVnfByIdWithDepth("a27ce5a9-29c4-4c22-a017-6615ac73c721", 1, "DoCreateVfModuleRollback/GenericVnf.xml"); + MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + MockPatchGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721"); + MockPutVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + MockDeleteGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721", "0000021"); + MockDeleteVfModuleId("", "", "", 200); + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + RollbackData rollbackData = new RollbackData(); + + rollbackData.put("VFMODULE_BASE", "source", "PORTAL"); + rollbackData.put("VFMODULE_BASE", "vnfid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_BASE", "vnfname", "STMTN5MMSC21"); + rollbackData.put("VFMODULE_BASE", "vnftype", "asc_heat-int"); + rollbackData.put("VFMODULE_BASE", "vfmoduleid", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + rollbackData.put("VFMODULE_BASE", "vfmodulename", "STMTN5MMSC21-MMSC::module-0-0"); + rollbackData.put("VFMODULE_BASE", "tenantid", "fba1bd1e195a404cacb9ce17a9b2b421"); + rollbackData.put("VFMODULE_BASE", "aiccloudregion", "RDM2WAGPLCP"); + rollbackData.put("VFMODULE_BASE", "heatstackid", "thisisaheatstack"); + rollbackData.put("VFMODULE_BASE", "contrailNetworkPolicyFqdn0", "MSOTest:DefaultPolicyFQDN1"); + rollbackData.put("VFMODULE_BASE", "contrailNetworkPolicyFqdn1", "MSOTest:DefaultPolicyFQDN2"); + rollbackData.put("VFMODULE_BASE", "oamManagementV6Address", "2000:abc:bce:1111"); + rollbackData.put("VFMODULE_BASE", "oamManagementV4Address", "127.0.0.1"); + rollbackData.put("VFMODULE_BASE", "rollbackPrepareUpdateVfModule", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackVnfAdapterCreate", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackUpdateAAIVfModule", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackSDNCRequestActivate", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackCreateAAIVfModule", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackCreateNetworkPoliciesAAI", "true"); + rollbackData.put("VFMODULE_BASE", "rollbackUpdateVnfAAI", "true"); + rollbackData.put("VFMODULE_BASE", "msorequestid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_BASE", "serviceinstanceid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + + + rollbackData.put("VFMODULE_ADDON_1", "source", "PORTAL"); + rollbackData.put("VFMODULE_ADDON_1", "vnfid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_ADDON_1", "vnfname", "STMTN5MMSC21"); + rollbackData.put("VFMODULE_ADDON_1", "vnftype", "asc_heat-int"); + rollbackData.put("VFMODULE_ADDON_1", "vfmoduleid", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + rollbackData.put("VFMODULE_ADDON_1", "vfmodulename", "STMTN5MMSC21-MMSC::module-0-0"); + rollbackData.put("VFMODULE_ADDON_1", "tenantid", "fba1bd1e195a404cacb9ce17a9b2b421"); + rollbackData.put("VFMODULE_ADDON_1", "aiccloudregion", "RDM2WAGPLCP"); + rollbackData.put("VFMODULE_ADDON_1", "heatstackid", "thisisaheatstack"); + rollbackData.put("VFMODULE_ADDON_1", "contrailNetworkPolicyFqdn0", "MSOTest:DefaultPolicyFQDN1"); + rollbackData.put("VFMODULE_ADDON_1", "contrailNetworkPolicyFqdn1", "MSOTest:DefaultPolicyFQDN2"); + rollbackData.put("VFMODULE_ADDON_1", "oamManagementV6Address", "2000:abc:bce:1111"); + rollbackData.put("VFMODULE_ADDON_1", "oamManagementV4Address", "127.0.0.1"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackPrepareUpdateVfModule", "true"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackVnfAdapterCreate", "true"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackUpdateAAIVfModule", "true"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackSDNCRequestActivate", "true"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackCreateAAIVfModule", "true"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackCreateNetworkPoliciesAAI", "true"); + rollbackData.put("VFMODULE_ADDON_1", "rollbackUpdateVnfAAI", "true"); + rollbackData.put("VFMODULE_ADDON_1", "msorequestid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + rollbackData.put("VFMODULE_ADDON_1", "serviceinstanceid", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + + rollbackData.put("VNF", "vnfId", "testVnfId123"); + + rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "1"); + + variables.put("isDebugLogEnabled","true"); + variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + + + variables.put("rollbackData", rollbackData); + invokeSubProcess("DoCreateVnfAndModulesRollback", businessKey, variables); + + // "changedelete" operation not required for deleting a Vf Module + // injectSDNCCallbacks(callbacks, "sdncChangeDelete"); + injectVNFRestCallbacks(callbacks, "vnfDelete"); + injectVNFRestCallbacks(callbacks, "vnfDelete"); + //waitForRunningProcessCount("DoCreateVnfAndModulesRollback", 0, 120000); + injectSDNCCallbacks(callbacks, "sdncDelete"); + + waitForProcessEnd(businessKey, 10000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + checkVariable(businessKey, "WorkflowException", null); + if (wfe != null) { + System.out.println("TestCreateVfModuleSuccess: ErrorCode=" + wfe.getErrorCode() + + ", ErrorMessage=" + wfe.getErrorMessage()); + } + logEnd(); + } + + public static void MockDoDeleteVfModule_SDNCSuccess() { + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>deactivate")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>unassign")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + } + + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java new file mode 100644 index 0000000000..3c10872dc8 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfAndModulesTest.java @@ -0,0 +1,354 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSDNCAdapterVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.domain.ModelInfo; +import org.openecomp.mso.bpmn.core.domain.ModuleResource; +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.bpmn.core.domain.VnfResource; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit Test for the DoCreateVnfAndModules Flow + * + */ +public class DoCreateVnfAndModulesTest extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public DoCreateVnfAndModulesTest() throws IOException { + + callbacks.put("assign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyAssignCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("query", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallback.xml")); + callbacks.put("queryVnf", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml")); + callbacks.put("queryModuleNoVnf", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml")); + callbacks.put("queryModule", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml")); + callbacks.put("vnfCreate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestCreateCallback.xml")); + } + + @Test + @Ignore // IGNORED FOR 1710 MERGE TO ONAP + @Deployment(resources = {"subprocess/GenericGetService.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/GenericPutVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/DoCreateVnf.bpmn", + "subprocess/GenerateVfModuleName.bpmn", + "subprocess/DoCreateVfModule.bpmn", + "subprocess/DoCreateVnfAndModules.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/DoCreateVnfAndModulesRollback.bpmn"}) + public void testDoCreateVnfAndModulesBaseOnly_success() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + MockGetGenericVnfById_404("testVnfId"); + MockPutGenericVnf(".*"); + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesSuccess(variables, "", "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); + invokeSubProcess("DoCreateVnfAndModules", businessKey, variables); + + injectSDNCCallbacks(callbacks, "assign"); + injectSDNCCallbacks(callbacks, "query"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "queryVnf"); + injectSDNCCallbacks(callbacks, "assign, queryModuleNoVnf"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + assertVariables("true", "true", "false", "true", "Success", null); + + } + + @Test + @Ignore // IGNORED FOR 1710 MERGE TO ONAP + @Deployment(resources = {"subprocess/GenericGetService.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/GenericPutVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/DoCreateVnf.bpmn", + "subprocess/GenerateVfModuleName.bpmn", + "subprocess/DoCreateVfModule.bpmn", + "subprocess/DoCreateVnfAndModules.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/DoCreateVnfAndModulesRollback.bpmn"}) + public void testDoCreateVnfAndModulesWithAddon_success() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + MockGetGenericVnfById_404("testVnfId"); + MockPutGenericVnf(".*"); + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesAddonSuccess(variables, "", "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); + invokeSubProcess("DoCreateVnfAndModules", businessKey, variables); + + injectSDNCCallbacks(callbacks, "assign"); + injectSDNCCallbacks(callbacks, "query"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "queryVnf"); + injectSDNCCallbacks(callbacks, "assign, queryModuleNoVnf"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "queryVnf"); + injectSDNCCallbacks(callbacks, "assign, queryModuleNoVnf"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + assertVariables("true", "true", "false", "true", "Success", null); + + } + + private void assertVariables(String exSIFound, String exSISucc, String exVnfFound, String exVnfSucc, String exResponse, String exWorkflowException) { + + String siFound = BPMNUtil.getVariable(processEngineRule, "DoCreateVnf", "GENGS_FoundIndicator"); + String siSucc = BPMNUtil.getVariable(processEngineRule, "DoCreateVnf", "GENGS_SuccessIndicator"); + String vnfFound = BPMNUtil.getVariable(processEngineRule, "DoCreateVnf", "GENGV_FoundIndicator"); + String vnfSucc = BPMNUtil.getVariable(processEngineRule, "DoCreateVnf", "GENGV_SuccessIndicator"); + String response = BPMNUtil.getVariable(processEngineRule, "DoCreateVnf", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateVnf", "SavedWorkflowException1"); + + //assertEquals(exSIFound, siFound); + //assertEquals(exSISucc, siSucc); + //assertEquals(exVnfFound, vnfFound); + //assertEquals(exVnfSucc, vnfSucc); + //assertEquals(exResponse, response); + assertEquals(exWorkflowException, workflowException); + } + + private void setVariables(Map variables, String request, String requestId, String siId) { + variables.put("isDebugLogEnabled", "true"); + variables.put("bpmnRequest", request); + variables.put("mso-request-id", requestId); + variables.put("serviceInstanceId",siId); + variables.put("testVnfId","testVnfId123"); + variables.put("vnfType", "STMTN"); + } + + private void setVariablesSuccess(Map variables, String request, String requestId, String siId) { + variables.put("isDebugLogEnabled", "true"); + variables.put("mso-request-id", requestId); + variables.put("requestId", requestId); + variables.put("msoRequestId", requestId); + variables.put("serviceInstanceId",siId); + variables.put("disableRollback", "true"); + //variables.put("testVnfId","testVnfId123"); + variables.put("vnfType", "STMTN"); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"995256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"ServicevSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "}"; + variables.put("serviceModelInfo", serviceModelInfo); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + String vnfModelInfo = "{" + "\"modelType\": \"vnf\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"vSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"" + "}"; + variables.put("vnfModelInfo", vnfModelInfo); + + String cloudConfiguration = "{" + "\"cloudConfiguration\": { " + + "\"lcpCloudRegionId\": \"mdt1\"," + + "\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}}"; + variables.put("cloudConfiguration", cloudConfiguration); + variables.put("sdncVersion", "1707"); + variables.put("globalSubscriberId", "subscriber123"); + + try { + String serviceDecomposition = FileUtil.readResourceFile("__files/VIPR/serviceDecompositionATMFW.json"); + ServiceDecomposition sd = new ServiceDecomposition(); + ModelInfo serviceModel = new ModelInfo(); + serviceModel.setModelName("servicewithVNFs"); + sd.setModelInfo(serviceModel); + VnfResource vr = new VnfResource(); + ModelInfo mvr = new ModelInfo(); + mvr.setModelName("vSAMP12"); + mvr.setModelInstanceName("v123"); + mvr.setModelInvariantUuid(""); + mvr.setModelVersion("1.0"); + mvr.setModelCustomizationUuid("MODEL-ID-1234"); + vr.setModelInfo(mvr); + vr.constructVnfType("vnf1"); + vr.setNfType("somenftype"); + vr.setNfRole("somenfrole"); + vr.setNfFunction("somenffunction"); + vr.setNfNamingCode("somenamingcode"); + ModuleResource mr = new ModuleResource(); + ModelInfo mvmr = new ModelInfo(); + mvmr.setModelInvariantUuid("ff5256d2-5a33-55df-13ab-12abad84e7ff"); + mvmr.setModelName("STMTN5MMSC21-MMSC::model-1-0"); + mvmr.setModelVersion("1"); + mvmr.setModelCustomizationUuid("MODEL-123"); + mr.setModelInfo(mvmr); + mr.setIsBase(true); + mr.setVfModuleLabel("MODULELABEL"); + vr.addVfModule(mr); + sd.addVnfResource(vr); + + variables.put("serviceDecomposition", sd); + variables.put("isTest", true); + } catch(Exception e) { + + } + + } + + private void setVariablesAddonSuccess(Map variables, String request, String requestId, String siId) { + variables.put("isDebugLogEnabled", "true"); + variables.put("mso-request-id", requestId); + variables.put("requestId", requestId); + variables.put("msoRequestId", requestId); + variables.put("serviceInstanceId",siId); + variables.put("disableRollback", "true"); + //variables.put("testVnfId","testVnfId123"); + variables.put("vnfType", "STMTN"); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"995256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"ServicevSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "}"; + variables.put("serviceModelInfo", serviceModelInfo); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + String vnfModelInfo = "{" + "\"modelType\": \"vnf\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"vSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"" + "}"; + variables.put("vnfModelInfo", vnfModelInfo); + + String cloudConfiguration = "{" + "\"cloudConfiguration\": { " + + "\"lcpCloudRegionId\": \"mdt1\"," + + "\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}}"; + variables.put("cloudConfiguration", cloudConfiguration); + variables.put("sdncVersion", "1707"); + variables.put("globalSubscriberId", "subscriber123"); + + try { + String serviceDecomposition = FileUtil.readResourceFile("__files/VIPR/serviceDecompositionATMFW.json"); + ServiceDecomposition sd = new ServiceDecomposition(); + ModelInfo serviceModel = new ModelInfo(); + serviceModel.setModelName("servicewithVNFs"); + sd.setModelInfo(serviceModel); + VnfResource vr = new VnfResource(); + ModelInfo mvr = new ModelInfo(); + mvr.setModelName("vSAMP12"); + mvr.setModelInstanceName("v123"); + mvr.setModelInvariantUuid(""); + mvr.setModelVersion("1.0"); + mvr.setModelCustomizationUuid("MODEL-ID-1234"); + vr.setModelInfo(mvr); + vr.setNfType("somenftype"); + vr.setNfRole("somenfrole"); + vr.setNfFunction("somenffunction"); + vr.setNfNamingCode("somenamingcode"); + ModuleResource mr = new ModuleResource(); + ModelInfo mvmr = new ModelInfo(); + mvmr.setModelInvariantUuid("ff5256d2-5a33-55df-13ab-12abad84e7ff"); + mvmr.setModelName("STMTN5MMSC21-MMSC::model-1-0"); + mvmr.setModelVersion("1"); + mvmr.setModelCustomizationUuid("MODEL-123"); + mr.setModelInfo(mvmr); + mr.setIsBase(true); + mr.setVfModuleLabel("MODULELABEL"); + vr.addVfModule(mr); + ModuleResource mr1 = new ModuleResource(); + ModelInfo mvmr1 = new ModelInfo(); + mvmr1.setModelInvariantUuid("ff5256d2-5a33-55df-13ab-12abad84e7ff"); + mvmr1.setModelName("STMTN5MMSC21-MMSC::model-1-0"); + mvmr1.setModelVersion("1"); + mvmr1.setModelCustomizationUuid("MODEL-123"); + mr1.setModelInfo(mvmr1); + mr1.setIsBase(false); + mr1.setVfModuleLabel("MODULELABEL"); + mr1.setInitialCount(1); + vr.addVfModule(mr1); + + sd.addVnfResource(vr); + + variables.put("serviceDecomposition", sd); + variables.put("isTest", true); + } catch(Exception e) { + + + + } + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java index b161d05bfe..4d2b512a2f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoCreateVnfTest.java @@ -102,11 +102,11 @@ public class DoCreateVnfTest extends WorkflowTest { variables.put("vnfType", "STMTN"); variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); String vnfModelInfo = "{ "+ "\"modelType\": \"vnf\"," + - "\"modelInvariantId\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + - "\"modelNameVersionId\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + "\"modelName\": \"vSAMP12\"," + "\"modelVersion\": \"1.0\"," + - "\"modelCustomizationId\": \"MODEL-ID-1234\"," + + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + "}"; variables.put("vnfModelInfo", vnfModelInfo); @@ -114,6 +114,15 @@ public class DoCreateVnfTest extends WorkflowTest { "\"lcpCloudRegionId\": \"mdt1\"," + "\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}"; variables.put("cloudConfiguration", cloudConfiguration); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"995256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"ServicevSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "}"; + variables.put("serviceModelInfo", serviceModelInfo); + variables.put("globalSubscriberId", "MSO-1610"); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java new file mode 100644 index 0000000000..3aefb6afaa --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteServiceInstanceTest.java @@ -0,0 +1,88 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; + +/** + * Unit test cases for DoDeleteServiceInstance.bpmn + */ +public class DoDeleteServiceInstanceTest extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + private static final String EOL = "\n"; + private final String sdncAdapterCallback = + "" + EOL + + " ((REQUEST-ID))" + EOL + + " Y" + EOL + + "" + EOL; + + public DoDeleteServiceInstanceTest() throws IOException { + callbacks.put("deactivate", sdncAdapterCallback); + callbacks.put("delete", sdncAdapterCallback); + } + + /** + * Sunny day VID scenario. + * + * @throws Exception + */ + //@Ignore // File not found - unable to run the test. Also, Stubs need updating.. + @Test + @Deployment(resources = { + "subprocess/DoDeleteServiceInstance.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericDeleteService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" }) + public void sunnyDay() throws Exception { + + logStart(); + + //AAI + MockDeleteServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "", 204); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml"); + MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); + //SDNC + mockSDNCAdapter(200); + //DB + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map variables = new HashMap(); + setupVariables(variables); + invokeSubProcess("DoDeleteServiceInstance", businessKey, variables); + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + waitForProcessEnd(businessKey, 10000); + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteServiceInstance", "WorkflowException"); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + + logEnd(); + } + + // Success Scenario + private void setupVariables(Map variables) { + variables.put("isDebugLogEnabled", "true"); + variables.put("msoRequestId", "RaaDDSIRequestId-1"); + variables.put("mso-request-id", "RaaDDSIRequestId-1"); + variables.put("serviceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java new file mode 100644 index 0000000000..a1f66553f4 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleFromVnfTest.java @@ -0,0 +1,157 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIDeleteVfModule; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIGenericVnfSearch; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.WorkflowException; + +public class DoDeleteVfModuleFromVnfTest extends WorkflowTest { + private final CallbackSet callbacks = new CallbackSet(); + + private static final String EOL = "\n"; + + private final String vnfAdapterDeleteCallback = + "" + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " true" + EOL + + " {{MESSAGE-ID}}" + EOL + + "" + EOL; + + private final String vnfAdapterDeleteCallbackFail = + "" + EOL + + " Error processing request to VNF-Async. Not Found." + EOL + + " INTERNAL" + EOL + + " false" + EOL + + " {{MESSAGE-ID}}" + EOL + + "" + EOL; + + private final String sdncAdapterDeleteCallback = + "" + EOL + + " {{REQUEST-ID}}" + EOL + + " Y" + EOL + + "" + EOL; + + public DoDeleteVfModuleFromVnfTest() throws IOException { + callbacks.put("deactivate", sdncAdapterDeleteCallback); + callbacks.put("unassign", sdncAdapterDeleteCallback); + callbacks.put("vnfDelete", vnfAdapterDeleteCallback); + callbacks.put("vnfDeleteFail", vnfAdapterDeleteCallbackFail); + } + + private final String wfeString = "WorkflowException"; + + @Test + @Deployment(resources = { + "subprocess/DoDeleteVfModuleFromVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/DeleteAAIVfModule.bpmn" + }) + public void TestDoDeleteVfModuleFromVnfSuccess() { + // delete the Base Module and Generic Vnf + // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73 + String request = + "" + EOL + + " " + EOL + + " DELETE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " STMTN5MMSC21" + EOL + + " asc_heat-int" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " STMTN5MMSC21-MMSC::module-0-0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " SDN-ETHERNET-INTERNET" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " pending-delete" + EOL + + " RDM2WAGPLCP" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + logStart(); + MockDoDeleteVfModule_SDNCSuccess(); + MockDoDeleteVfModule_DeleteVNFSuccess(); + MockAAIGenericVnfSearch(); + MockAAIDeleteVfModule(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("isDebugLogEnabled","true"); + variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("msoRequestId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("serviceInstanceId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("vfModuleId", "973ed047-d251-4fb9-bf1a-65b8949e0a73"); + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "fba1bd1e195a404cacb9ce17a9b2b421"); + variables.put("sdncVersion", "1707"); + + invokeSubProcess("DoDeleteVfModuleFromVnf", businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivate"); + injectVNFRestCallbacks(callbacks, "vnfDelete"); + //waitForRunningProcessCount("vnfAdapterDeleteV1", 0, 120000); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, wfeString); + checkVariable(businessKey, wfeString, null); + if (wfe != null) { + System.out.println("TestDoDeleteVfModuleSuccess: ErrorCode=" + wfe.getErrorCode() + + ", ErrorMessage=" + wfe.getErrorMessage()); + } + logEnd(); + } + + + // start of mocks used locally and by other VF Module unit tests + + + + public static void MockDoDeleteVfModule_SDNCSuccess() { + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>deactivate")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>unassign")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + } + + + public static void MockDoDeleteVfModule_DeleteVNFSuccess() { + stubFor(delete(urlMatching("/vnfs/v1/vnfs/.*/vf-modules/.*")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + } + + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java index a3165f7ff3..3e1c498c58 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleTest.java @@ -43,6 +43,7 @@ import org.junit.Assert; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.mock.FileUtil; /** * Unit test for DoDeleteVfModule.bpmn. @@ -77,7 +78,8 @@ public class DoDeleteVfModuleTest extends WorkflowTest { public DoDeleteVfModuleTest() throws IOException { callbacks.put("sdncChangeDelete", sdncAdapterDeleteCallback); callbacks.put("sdncDelete", sdncAdapterDeleteCallback); - callbacks.put("vnfDelete", vnfAdapterDeleteCallback); + callbacks.put("vnfDelete", FileUtil.readResourceFile( + "__files/DeleteVfModuleCallbackResponse.xml")); callbacks.put("vnfDeleteFail", vnfAdapterDeleteCallbackFail); } @@ -182,12 +184,13 @@ public class DoDeleteVfModuleTest extends WorkflowTest { variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-0-0"); variables.put("sdncVersion", "1610"); variables.put("isVidRequest", "true"); + variables.put("retainResources", false); String vfModuleModelInfo = "{" + "\"modelType\": \"vnf\"," + - "\"modelInvariantId\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + - "\"modelNameVersionId\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + "\"modelName\": \"vSAMP12\"," + "\"modelVersion\": \"1.0\"," + - "\"modelCustomizationId\": \"MODEL-ID-1234\"," + + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + "}"; variables.put("vfModuleModelInfo", vfModuleModelInfo); diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java new file mode 100644 index 0000000000..01043100c1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVfModuleVolumeV2Test.java @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteVolumeGroupById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVfModuleDelete; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.WorkflowException; +import org.openecomp.mso.bpmn.mock.FileUtil; + +public class DoDeleteVfModuleVolumeV2Test extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public DoDeleteVfModuleVolumeV2Test() throws IOException { + callbacks.put("volumeGroupDelete", FileUtil.readResourceFile( + "__files/DeleteVfModuleVolumeInfraV1/DeleteVfModuleVolumeCallbackResponse.xml")); + } + + @Test + //@Ignore + @Deployment(resources = {"subprocess/DoDeleteVfModuleVolumeV2.bpmn", "subprocess/VnfAdapterRestV1.bpmn"}) + public void happyPath() throws Exception { + + logStart(); + + MockGetNetworkCloudRegion("MDTWNJ21", "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockDeleteVolumeGroupById("RDM2WAGPLCP", "78987", "0000020", 200); + mockPutVNFVolumeGroup("78987", 202); + mockVfModuleDelete("78987"); + MockDeleteVolumeGroupById("AAIAIC25", "78987", "0000020", 200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockGetVolumeGroupById("AAIAIC25", "78987", "VfModularity/VolumeGroup.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map testVariables = new HashMap(); + testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123"); + testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123"); + testVariables.put("isDebugLogEnabled", "true"); + //testVariables.put("lcpCloudRegionId", "MDTWNJ21"); + //testVariables.put("tenantId", "fba1bd1e195a404cacb9ce17a9b2b421"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("serviceInstanceId", "test-service-instance-id-0123"); + + String cloudConfiguration = "{" + + "\"lcpCloudRegionId\": \"MDTWNJ21\"," + + "\"tenantId\": \"fba1bd1e195a404cacb9ce17a9b2b421\"" + "}"; + testVariables.put("cloudConfiguration", cloudConfiguration); + + invokeSubProcess("DoDeleteVfModuleVolumeV2", businessKey, testVariables); + + injectVNFRestCallbacks(callbacks, "volumeGroupDelete"); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "wasDeleted", "true"); + + logEnd(); + } + + + @Test + //@Ignore + @Deployment(resources = {"subprocess/DoDeleteVfModuleVolumeV2.bpmn", "subprocess/VnfAdapterRestV1.bpmn"}) + public void testVolumeGroupInUse() throws Exception { + + logStart(); + MockGetNetworkCloudRegion("MDTWNJ21", "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml"); + MockDeleteVolumeGroupById("RDM2WAGPLCP", "78987", "0000020", 200); + mockVfModuleDelete("78987"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map testVariables = new HashMap(); + testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123"); + testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123"); + testVariables.put("isDebugLogEnabled", "true"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("serviceInstanceId", "test-service-instance-id-0123"); + + String cloudConfiguration = "{" + + "\"lcpCloudRegionId\": \"MDTWNJ21\"," + + "\"tenantId\": \"fba1bd1e195a404cacb9ce17a9b2b421\"" + "}"; + testVariables.put("cloudConfiguration", cloudConfiguration); + + invokeSubProcess("DoDeleteVfModuleVolumeV2", businessKey, testVariables); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "wasDeleted", "false"); + WorkflowException msoException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + System.out.println("WorkflowException - Code: " + msoException.getErrorCode() + " Message: " + msoException.getErrorMessage()); + + + logEnd(); + } + + @Test + //@Ignore + @Deployment(resources = {"subprocess/DoDeleteVfModuleVolumeV2.bpmn", "subprocess/VnfAdapterRestV1.bpmn"}) + public void testTenantIdMismatch() throws Exception { + + logStart(); + MockGetNetworkCloudRegion("MDTWNJ21", "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockDeleteVolumeGroupById("RDM2WAGPLCP", "78987", "0000020", 200); + mockVfModuleDelete("78987", 404); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map testVariables = new HashMap(); + testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123"); + testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123"); + testVariables.put("isDebugLogEnabled", "true"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("serviceInstanceId", "test-service-instance-id-0123"); + + String cloudConfiguration = "{" + + "\"lcpCloudRegionId\": \"MDTWNJ21\"," + + "\"tenantId\": \"fba1bd1e195a404cacb9ce17a9b2b421xxx\"" + "}"; + testVariables.put("cloudConfiguration", cloudConfiguration); + + invokeSubProcess("DoDeleteVfModuleVolumeV2", businessKey, testVariables); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "wasDeleted", "false"); + WorkflowException msoException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + System.out.println("WorkflowException - Code: " + msoException.getErrorCode() + " Message: " + msoException.getErrorMessage()); + + + logEnd(); + } + + @Test + //@Ignore + @Deployment(resources = {"subprocess/DoDeleteVfModuleVolumeV2.bpmn", "subprocess/VnfAdapterRestV1.bpmn"}) + public void testVnfAdapterCallfail() throws Exception { + + logStart(); + MockGetNetworkCloudRegion("MDTWNJ21", "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); + MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockDeleteVolumeGroupById("RDM2WAGPLCP", "78987", "0000020", 200); + mockVfModuleDelete("78987", 404); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + String businessKey = UUID.randomUUID().toString(); + + Map testVariables = new HashMap(); + testVariables.put("mso-request-id", "TEST-REQUEST-ID-0123"); + testVariables.put("msoRequestId", "TEST-REQUEST-ID-0123"); + testVariables.put("isDebugLogEnabled", "true"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("serviceInstanceId", "test-service-instance-id-0123"); + + String cloudConfiguration = "{" + + "\"lcpCloudRegionId\": \"MDTWNJ21\"," + + "\"tenantId\": \"fba1bd1e195a404cacb9ce17a9b2b421\"" + "}"; + testVariables.put("cloudConfiguration", cloudConfiguration); + + invokeSubProcess("DoDeleteVfModuleVolumeV2", businessKey, testVariables); + + waitForProcessEnd(businessKey, 100000); + checkVariable(businessKey, "wasDeleted", "false"); + WorkflowException msoException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); + System.out.println("WorkflowException - Code: " + msoException.getErrorCode() + " Message: " + msoException.getErrorMessage()); + + logEnd(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java new file mode 100644 index 0000000000..585c26d801 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoDeleteVnfAndModulesTest.java @@ -0,0 +1,190 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIDeleteVfModule; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIGenericVnfSearch; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.mock.FileUtil; + +public class DoDeleteVnfAndModulesTest extends WorkflowTest { + private final CallbackSet callbacks = new CallbackSet(); + private static final String EOL = "\n"; + private final String vnfAdapterDeleteCallback = + "" + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " true" + EOL + + " {{MESSAGE-ID}}" + EOL + + "" + EOL; + + public DoDeleteVnfAndModulesTest () throws IOException { + callbacks.put("deactivate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("vnfDelete", vnfAdapterDeleteCallback); + + } + + @Test + @Deployment(resources = {"subprocess/DoDeleteVnfAndModules.bpmn", "subprocess/SDNCAdapterV1.bpmn", "subprocess/GenericGetVnf.bpmn", "subprocess/GenericDeleteVnf.bpmn", "subprocess/DoDeleteVnf.bpmn", "subprocess/DoDeleteVfModule.bpmn"}) + public void testDoDeleteVnfAndModules_successVnfOnly() throws Exception{ + MockGetGenericVnfById("testVnfId123.*", "GenericFlows/getGenericVnfByNameResponse.xml"); + MockDeleteGenericVnf("testVnfId123", "testReVer123"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + mockSDNCAdapter(200); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesVnfOnly(variables); + invokeSubProcess("DoDeleteVnfAndModules", businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnfAndModules", "WorkflowException"); + + assertEquals(null, workflowException); + } + + + private void setVariablesVnfOnly(Map variables) { + variables.put("mso-request-id", "testRequestId123"); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfId","testVnfId123"); + variables.put("serviceInstanceId", "MIS%2F1604%2F0026%2FSW_INTERNET"); + //variables.put("vnfName", "testVnfName123"); + variables.put("disableRollback", "true"); + variables.put("msoRequestId", "testVnfId123"); + variables.put("testVnfId","testVnfId123"); + //variables.put("vnfType", "STMTN"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + String vnfModelInfo = "{ "+ "\"modelType\": \"vnf\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"vSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + + "}"; + //variables.put("vnfModelInfo", vnfModelInfo); + + variables.put("lcpCloudRegionId", "mdt1"); + variables.put("tenantId", "88a6ca3ee0394ade9403f075db23167e"); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"995256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"ServicevSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "}"; + //variables.put("serviceModelInfo", serviceModelInfo); + variables.put("globalSubscriberId", "MSO-1610"); + variables.put("sdncVersion", "1707"); + + } + + @Test + @Deployment(resources = {"subprocess/DoDeleteVnfAndModules.bpmn", "subprocess/SDNCAdapterV1.bpmn", "subprocess/GenericGetVnf.bpmn", "subprocess/GenericDeleteVnf.bpmn", "subprocess/DoDeleteVnf.bpmn", "subprocess/DoDeleteVfModuleFromVnf.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/DeleteAAIVfModule.bpmn"}) + public void testDoDeleteVnfAndModules_successVnfAndModules() throws Exception{ + MockAAIGenericVnfSearch(); + MockGetGenericVnfById("testVnfId123.*", "GenericFlows/getGenericVnfByNameResponse.xml"); + MockDeleteGenericVnf("testVnfId123", "testReVer123"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + mockSDNCAdapter(200); + MockDoDeleteVfModule_SDNCSuccess(); + MockDoDeleteVfModule_DeleteVNFSuccess(); + MockAAIDeleteVfModule(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesVnfAndModules(variables); + invokeSubProcess("DoDeleteVnfAndModules", businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "deactivate"); + injectVNFRestCallbacks(callbacks, "vnfDelete"); + injectSDNCCallbacks(callbacks, "unassign"); + MockGetGenericVnfById("a27ce5a9-29c4-4c22-a017-6615ac73c721", "GenericFlows/getGenericVnfByNameResponse.xml"); + injectSDNCCallbacks(callbacks, "unassign"); + //MockGetGenericVnfById("a27ce5a9-29c4-4c22-a017-6615ac73c721", "GenericFlows/getGenericVnfByNameResponse.xml"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnfAndModules", "WorkflowException"); + + assertEquals(null, workflowException); + } + + + private void setVariablesVnfAndModules(Map variables) { + variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("isDebugLogEnabled", "true"); + variables.put("vnfId","a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("serviceInstanceId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + + variables.put("msoRequestId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + //variables.put("testVnfId","testVnfId123"); + + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "fba1bd1e195a404cacb9ce17a9b2b421"); + + variables.put("sdncVersion", "1707"); + + } + + + public static void MockDoDeleteVfModule_SDNCSuccess() { + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>deactivate")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>unassign")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + } + + + public static void MockDoDeleteVfModule_DeleteVNFSuccess() { + stubFor(delete(urlMatching("/vnfs/v1/vnfs/.*/vf-modules/.*")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java index bba6f62adc..fa0bc4985c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVfModuleTest.java @@ -22,10 +22,19 @@ package org.openecomp.mso.bpmn.infrastructure; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleIdNoResponse; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; @@ -41,7 +50,6 @@ import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet; import org.openecomp.mso.bpmn.mock.FileUtil; /** @@ -112,5 +120,125 @@ public class DoUpdateVfModuleTest extends WorkflowTest { logEnd(); } + + /** + * Test the happy path through the flow with Building Blocks interface. + */ + @Test + + @Deployment(resources = { + "subprocess/DoUpdateVfModule.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/UpdateAAIVfModule.bpmn" + }) + public void happyPathBB() throws IOException { + + logStart(); + + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "DEV-VF-0011"); + variables.put("isDebugLogEnabled","true"); + variables.put("msoRequestId", "DEV-VF-0011"); + variables.put("isBaseVfModule", "false"); + variables.put("isDebugLogEnabled", "true"); + variables.put("disableRollback", "true"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", "skask"); + variables.put("vfModuleId", "supercool"); + variables.put("vnfType", "pcrf-capacity"); + variables.put("isVidRequest", "true"); + variables.put("volumeGroupId", "78987"); + variables.put("usePreload", true); + + variables.put("sdncVersion", "1702"); + + variables.put("lcpCloudRegionId", "MDTWNJ21"); + variables.put("tenantId", "fba1bd1e195a404cacb9ce17a9b2b421"); + + String vfModuleModelInfo = "{ "+ "\"modelType\": \"vfModule\"," + + "\"modelInvariantUuid\": \"introvert\"," + + "\"modelUuid\": \"3.14\"," + + "\"modelName\": \"STMTN5MMSC21-MMSC::model-1-0\"," + + "\"modelVersion\": \"1\"," + + "\"modelCustomizationUuid\": \"MODEL-123\"" + "}"; + variables.put("vfModuleModelInfo", vfModuleModelInfo); + + String vnfModelInfo = "{ "+ "\"modelType\": \"vnf\"," + + "\"modelInvariantUuid\": \"introvert\"," + + "\"modelUuid\": \"3.14\"," + + "\"modelName\": \"VNF-STMTN5MMSC21-MMSC::model-1-0\"," + + "\"modelVersion\": \"1\"," + + "\"modelCustomizationUuid\": \"VNF-MODEL-123\"" + "}"; + variables.put("vnfModelInfo", vnfModelInfo); + + invokeSubProcess("DoUpdateVfModule", businessKey, variables); + + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + checkVariable(businessKey, "DoUpdateVfModuleSuccessIndicator", true); + + String heatStackId = (String) getVariableFromHistory(businessKey, "DOUPVfMod_heatStackId"); + System.out.println("Heat stack Id from AAI: " + heatStackId); + + logEnd(); + } + + // start of mocks used locally and by other VF Module unit tests + public static void MockSDNCAdapterVfModule() { + // simplified the implementation to return "success" for all requests + stubFor(post(urlEqualTo("/SDNCAdapter")) +// .withRequestBody(containing("SvcInstanceId><")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); +// stubFor(post(urlEqualTo("/SDNCAdapter")) +// .withRequestBody(containing("vnf-type>STMTN")) +// .willReturn(aResponse() +// .withStatus(200) +// .withHeader("Content-Type", "text/xml") +// .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); +// stubFor(post(urlEqualTo("/SDNCAdapter")) +// .withRequestBody(containing("SvcAction>query")) +// .willReturn(aResponse() +// .withStatus(200) +// .withHeader("Content-Type", "text/xml") +// .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); + } + + public static void MockVNFAdapterRestVfModule() { + stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java new file mode 100644 index 0000000000..b7650af4b8 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/DoUpdateVnfAndModulesTest.java @@ -0,0 +1,206 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.junit.Assert.assertEquals; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSDNCAdapterVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.core.domain.ModelInfo; +import org.openecomp.mso.bpmn.core.domain.ModuleResource; +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.bpmn.core.domain.VnfResource; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit Test for the DoUpdateVnfAndModules Flow + * + */ +public class DoUpdateVnfAndModulesTest extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public DoUpdateVnfAndModulesTest() throws IOException { + + callbacks.put("changeassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("query", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallback.xml")); + callbacks.put("vnfUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestUpdateCallback.xml")); + } + + @Test + + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/DoUpdateVfModule.bpmn", + "subprocess/DoUpdateVnfAndModules.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn"}) + public void testDoUpdateVnfAndModules_success() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + //MockGetGenericVnfById_404("testVnfId"); + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutGenericVnf(".*"); + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + mockVNFPut("skask", "/supercool", 202); + mockVNFPut("skask", "/lukewarm", 202); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + setVariablesSuccess(variables, "", "testRequestId123", "MIS%2F1604%2F0026%2FSW_INTERNET"); + invokeSubProcess("DoUpdateVnfAndModules", businessKey, variables); + + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + assertVariables("2", "200", null); + + } + + + + private void assertVariables(String exModuleCount, String exVnfFound, String exWorkflowException) { + + String moduleCount = BPMNUtil.getVariable(processEngineRule, "DoUpdateVnfAndModules", "DUVAM_moduleCount"); + String vnfFound = BPMNUtil.getVariable(processEngineRule, "DoUpdateVnfAndModules", "DUVAM_queryAAIVfModuleResponseCode"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "DoUpdateVnfAndModules", "SavedWorkflowException1"); + + assertEquals(exModuleCount, moduleCount); + assertEquals(exVnfFound, vnfFound); + assertEquals(exWorkflowException, workflowException); + } + + private void setVariables(Map variables, String request, String requestId, String siId) { + variables.put("isDebugLogEnabled", "true"); + variables.put("bpmnRequest", request); + variables.put("msoRequestUdid", requestId); + variables.put("serviceInstanceId",siId); + variables.put("testVnfId","testVnfId123"); + variables.put("vnfType", "STMTN"); + + } + + private void setVariablesSuccess(Map variables, String request, String requestId, String siId) { + variables.put("isDebugLogEnabled", "true"); + variables.put("requestId", requestId); + variables.put("msoRequestId", requestId); + variables.put("serviceInstanceId",siId); + variables.put("disableRollback", "true"); + //variables.put("testVnfId","testVnfId123"); + variables.put("vnfType", "STMTN"); + variables.put("vnfId", "skask"); + variables.put("tenantId", "88a6ca3ee0394ade9403f075db23167e"); + variables.put("lcpCloudRegionId", "mdt1"); + + String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + + "\"modelInvariantUuid\": \"995256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"ServicevSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "}"; + variables.put("serviceModelInfo", serviceModelInfo); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + String vnfModelInfo = "{" + "\"modelType\": \"vnf\"," + + "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + + "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + + "\"modelName\": \"vSAMP12\"," + + "\"modelVersion\": \"1.0\"," + + "\"modelCustomizationUuid\": \"MODEL-ID-1234\"" + "}"; + variables.put("vnfModelInfo", vnfModelInfo); + + String cloudConfiguration = "{" + "\"cloudConfiguration\": { " + + "\"lcpCloudRegionId\": \"mdt1\"," + + "\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}}"; + variables.put("cloudConfiguration", cloudConfiguration); + variables.put("sdncVersion", "1702"); + variables.put("globalSubscriberId", "subscriber123"); + variables.put("asdcServiceModelVersion", "serviceVersion01"); + + try { + VnfResource vr = new VnfResource(); + ModelInfo mvr = new ModelInfo(); + mvr.setModelName("vSAMP12"); + mvr.setModelInstanceName("v123"); + mvr.setModelInvariantUuid("extrovert"); + mvr.setModelVersion("1.0"); + mvr.setModelCustomizationUuid("MODEL-ID-1234"); + vr.setModelInfo(mvr); + vr.constructVnfType("vnf1"); + vr.setNfType("somenftype"); + vr.setNfRole("somenfrole"); + vr.setNfFunction("somenffunction"); + vr.setNfNamingCode("somenamingcode"); + ModuleResource mr = new ModuleResource(); + ModelInfo mvmr = new ModelInfo(); + mvmr.setModelInvariantUuid("introvert"); + mvmr.setModelName("STMTN5MMSC21-MMSC::model-1-0"); + mvmr.setModelVersion("1"); + mvmr.setModelCustomizationUuid("MODEL-123"); + mr.setModelInfo(mvmr); + mr.setIsBase(true); + mr.setVfModuleLabel("MODULELABEL"); + vr.addVfModule(mr); + ModuleResource mr1 = new ModuleResource(); + ModelInfo mvmr1 = new ModelInfo(); + mvmr1.setModelInvariantUuid("extrovert"); + mvmr1.setModelName("SECONDMODELNAME"); + mvmr1.setModelVersion("1"); + mvmr1.setModelCustomizationUuid("MODEL-123"); + mr1.setModelInfo(mvmr1); + mr1.setIsBase(false); + mr1.setVfModuleLabel("MODULELABEL1"); + vr.addVfModule(mr1); + variables.put("vnfResourceDecomposition", vr); + variables.put("isTest", true); + } catch(Exception e) { + + } + + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java new file mode 100644 index 0000000000..acccbf5788 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/ReplaceVnfInfraTest.java @@ -0,0 +1,259 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIDeleteVfModule; +import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIGenericVnfSearch; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetPserverByVnfId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSetInMaintFlagByVnfId; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicyAbort; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; +import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for UpdateVnfInfra.bpmn + */ +public class ReplaceVnfInfraTest extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + private static final String EOL = "\n"; + private final String vnfAdapterDeleteCallback = + "" + EOL + + " a27ce5a9-29c4-4c22-a017-6615ac73c721" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " true" + EOL + + " {{MESSAGE-ID}}" + EOL + + "" + EOL; + + public ReplaceVnfInfraTest() throws IOException { + callbacks.put("deactivate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("vnfDelete", vnfAdapterDeleteCallback); + callbacks.put("changeassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("query", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallback.xml")); + callbacks.put("vnfUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestUpdateCallback.xml")); + } + + /** + * Sunny day scenario. + * + * @throws Exception + */ + @Test + @Ignore + @Deployment(resources = { + "process/ReplaceVnfInfra.bpmn", + "subprocess/DoDeleteVfModule.bpmn", + "subprocess/DoDeleteVnfAndModules.bpmn", + "subprocess/DeleteAAIVfModule.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/DoDeleteVnfAndModules.bpmn", + "subprocess/GenericDeleteVnf.bpmn", + "subprocess/DoDeleteVnf.bpmn", + "subprocess/DoDeleteVfModule.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/GenericPutVnf.bpmn", + "subprocess/DoCreateVnf.bpmn", + "subprocess/GenerateVfModuleName.bpmn", + "subprocess/DoCreateVfModule.bpmn", + "subprocess/DoCreateVnfAndModules.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateVnfAndModulesRollback.bpmn", + "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/BuildingBlock/RainyDayHandler.bpmn", + "subprocess/BuildingBlock/ManualHandling.bpmn" + + }) + public void sunnyDay() throws Exception { + + logStart(); + MockAAIGenericVnfSearch(); + MockGetGenericVnfById("testVnfId123.*", "GenericFlows/getGenericVnfByNameResponse.xml"); + MockDeleteGenericVnf("testVnfId123", "testReVer123"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + mockSDNCAdapter(200); + MockDoDeleteVfModule_SDNCSuccess(); + MockDoDeleteVfModule_DeleteVNFSuccess(); + MockAAIDeleteVfModule(); + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + //MockGetGenericVnfById_404("testVnfId"); + MockGetServiceResourcesCatalogData("995256d2-5a33-55df-13ab-12abad84e7ff", "1.0", "VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json"); + //MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + //MockPutGenericVnf(".*"); + MockAAIVfModule(); + MockPatchGenericVnf("a27ce5a9-29c4-4c22-a017-6615ac73c721"); + MockPatchVfModuleId("a27ce5a9-29c4-4c22-a017-6615ac73c721", ".*"); + //mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + //mockVNFPut("skask", "/supercool", 202); + //mockVNFPut("skask", "/lukewarm", 202); + //MockVNFAdapterRestVfModule(); + //MockDBUpdateVfModule(); + //MockGetPserverByVnfId("skask", "AAI/AAI_pserverByVnfId.json", 200); + //MockGetGenericVnfsByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200); + MockSetInMaintFlagByVnfId("skask", 200); + MockPolicySkip(); + + //mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + //mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVnfRequest = + FileUtil.readResourceFile("__files/InfrastructureFlows/ReplaceVnf_VID_request.json"); + + Map variables = setupVariablesSunnyDayVID(); + + + TestAsyncResponse asyncResponse = invokeAsyncProcess("ReplaceVnfInfra", + "v1", businessKey, updaetVnfRequest, variables); + + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + //injectSDNCCallbacks(callbacks, "deactivate"); + //injectSDNCCallbacks(callbacks, "deactivate"); + injectVNFRestCallbacks(callbacks, "vnfDelete"); + //injectSDNCCallbacks(callbacks, "unassign"); + MockGetGenericVnfById("a27ce5a9-29c4-4c22-a017-6615ac73c721", "GenericFlows/getGenericVnfByNameResponse.xml"); + injectSDNCCallbacks(callbacks, "unassign"); + + + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + + // TODO add appropriate assertions + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "ReplaceVfModuleInfraSuccessIndicator", true); + + logEnd(); + } + + // Active Scenario + private Map setupVariablesSunnyDayVID() { + Map variables = new HashMap(); + //try { + // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); + //} + //catch (Exception e) { + + //} + //variables.put("mso-request-id", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("isDebugLogEnabled", "true"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721"); + variables.put("vnfType", "vSAMP12"); + variables.put("serviceType", "MOG"); + + return variables; + + } + + public static void MockDoDeleteVfModule_SDNCSuccess() { + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>deactivate")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + stubFor(post(urlEqualTo("/SDNCAdapter")) + .withRequestBody(containing("SvcAction>unassign")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml"))); + } + + + public static void MockDoDeleteVfModule_DeleteVNFSuccess() { + stubFor(delete(urlMatching("/vnfs/v1/vnfs/.*/vf-modules/.*")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java new file mode 100644 index 0000000000..39cdd72375 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceTest.java @@ -0,0 +1,468 @@ +package org.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.*; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapterRestPut; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapterTopology; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeAsyncWorkflow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.getVariable; +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; + +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.WorkflowTestTransformer; +import org.openecomp.mso.bpmn.common.SDNCAdapterCallbackRule; +import org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer; + +import com.github.tomakehurst.wiremock.extension.ResponseTransformer; + +/** + * Unit test cases for DoUpdateNetworkInstance.bpmn + * + */ +public class UpdateNetworkInstanceTest extends WorkflowTest { + @WorkflowTestTransformer + public static final ResponseTransformer sdncAdapterMockTransformer = + new SDNCAdapterNetworkTopologyMockTransformer(); + + @Rule + public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = + new SDNCAdapterCallbackRule(processEngineRule); + + /** + * End-to-End flow - Unit test for DoUpdateNetworkInstance.bpmn + * - String input & String response + */ + + @Test + //@Ignore + @Deployment(resources = {"process/UpdateNetworkInstance.bpmn", + "subprocess/DoUpdateNetworkInstance.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceUpdateNetworkInstance_SuccessVID1() throws Exception { + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success1 - UpdateNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); + MockNetworkAdapterRestPut("UpdateNetworkV2/updateNetworkResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockPutNetworkIdWithDepth("UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); + + Map variables = setupVariablesVID1(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + System.out.println("----------------------------------------------------------"); + System.out.println("- got workflow response -"); + System.out.println("----------------------------------------------------------"); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_Success")); + Assert.assertNotNull("UPDNI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_CompleteMsoProcessRequest")); + + String workflowResp = BPMNUtil.getVariable(processEngineRule, "UpdateNetworkInstance", "WorkflowResponse"); + Assert.assertNotNull(workflowResp); + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success1 - UpdateNetworkInstance flow Completed "); + System.out.println("----------------------------------------------------------"); + + } + + @Test + //@Ignore + @Deployment(resources = {"process/UpdateNetworkInstance.bpmn", + "subprocess/DoUpdateNetworkInstance.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceUpdateNetworkInstance_SuccessVIPER1() throws Exception { + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success2 - UpdateNetworkInstance flow Started! "); + System.out.println("----------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); + MockNetworkAdapterRestPut("UpdateNetworkV2/updateNetworkResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockPutNetworkIdWithDepth("UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); + + Map variables = setupVariablesVIPER1(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_Success")); + Assert.assertNotNull("UPDNI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_CompleteMsoProcessRequest")); + + String completeMsoProcessRequest = + "" + '\n' + + " " + '\n' + + " testRequestId" + '\n' + + " UPDATE" + '\n' + + " VID" + '\n' + + " " + '\n' + + " Network has been updated successfully." + '\n' + + " BPMN Network action: UPDATE" + '\n' + + ""; + + Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_CompleteMsoProcessRequest")); + + System.out.println("----------------------------------------------------------"); + System.out.println(" Success2 - UpdateNetworkInstance flow Completed "); + System.out.println("----------------------------------------------------------"); + + } + + + @Test + //@Ignore + @Deployment(resources = {"process/UpdateNetworkInstance.bpmn", + "subprocess/DoUpdateNetworkInstance.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceUpdateNetworkInstance_MissingNetworkId() throws Exception { + + System.out.println("--------------------------------------------------------------------"); + System.out.println(" Missing networkId - UpdateNetworkInstance flow Started! "); + System.out.println("--------------------------------------------------------------------"); + + // setup simulators + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); + + Map variables = setupVariablesMissingNetworkId(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_Success")); + Assert.assertNotNull("UPDNI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_FalloutHandlerRequest")); + + String falloutHandlerActual = getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_FalloutHandlerRequest"); + String falloutHandlerExpected = +"" + "\n" + +" " + "\n" + +" 88f65519-9a38-4c4b-8445-9eb4a5a5af56" + "\n" + +" UPDATE" + "\n" + +" VID" + "\n" + +" " + "\n" + +" " + "\n" + +" Variable 'network-id' value/element is missing." + "\n" + +" 7000" + "\n" + +" " + "\n" + +" "; + + assertEquals("Response", falloutHandlerExpected, falloutHandlerActual); + + System.out.println("------------------------------------------------------------------"); + System.out.println(" Missing networkId - UpdateNetworkInstance flow Completed "); + System.out.println("------------------------------------------------------------------"); + + } + + + @Test + //@Ignore + @Deployment(resources = {"process/UpdateNetworkInstance.bpmn", + "subprocess/DoUpdateNetworkInstance.bpmn", + "subprocess/DoUpdateNetworkInstanceRollback.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn"}) + + public void shouldInvokeServiceUpdateNetworkInstance_Network_SDNC_Rollback() throws Exception { + + System.out.println("---------------------------------------------------------------"); + System.out.println(" Network and SDNC Rollback - UpdateNetworkInstance flow Started! "); + System.out.println("---------------------------------------------------------------"); + + // setup simulators + mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); + mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); + MockNetworkAdapterRestPut("UpdateNetworkV2/updateNetworkResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + MockGetNetworkPolicy("UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); + MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); + MockUpdateRequestDB("DBUpdateResponse.xml"); + //MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml", "v8"); + MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); + + Map variables = setupVariablesVID1(); + //WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstance", variables); + //waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_Success")); + Assert.assertNotNull("UPDNI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstance", "UPDNI_FalloutHandlerRequest")); + + System.out.println("---------------------------------------------------------------------"); + System.out.println(" Network and SCNC Rollback - UpdateNetworkInstance flow Completed "); + System.out.println("---------------------------------------------------------------------"); + + } + + // ***************** + // Utility Section + // ***************** + + String networkModelInfo = + " {\"modelUuid\": \"mod-inst-uuid-123\", " + '\n' + + " \"modelName\": \"mod_inst_z_123\", " + '\n' + + " \"modelVersion\": \"1.0\", " + '\n' + + " \"modelCustomizationUuid\": \"mod-inst-uuid-123\", " + '\n' + + " \"modelInvariantUuid\": \"mod-invar-uuid-123\" " + '\n' + + " }"; + + String serviceModelInfo = + " {\"modelUuid\": \"36a3a8ea-49a6-4ac8-b06c-89a54544b9b6\", " + '\n' + + " \"modelName\": \"HNGW Protected OAM\", " + '\n' + + " \"modelVersion\": \"1.0\", " + '\n' + + " \"modelInvariantUuid\": \"fcc85cb0-ad74-45d7-a5a1-17c8744fdb71\" " + '\n' + + " }"; + + // Success Scenario + private Map setupVariablesVID1() { + Map variables = new HashMap(); + variables.put("bpmnRequest", getCreateNetworkRequest1()); + variables.put("mso-request-id", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("isBaseVfModule", "true"); + variables.put("recipeTimeout", "0"); + variables.put("requestAction", "UPDATE"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", ""); + variables.put("vfModuleId", ""); + variables.put("volumeGroupId", ""); + variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + variables.put("serviceType", "vMOG"); + variables.put("vfModuleType", ""); + variables.put("networkType", "modelName"); + return variables; + + } + + public String getCreateNetworkRequest1() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelCustomizationId\": \"f21df226-8093-48c3-be7e-0408fcda0422\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1.0\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_1\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"false\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"backoutOnFailure\": true, " + '\n' + + " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + return request; + } + + public String getCreateNetworkRequest2() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelId\": \"modelId\", " + '\n' + + " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"myOwn_Network\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"true\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"backoutOnFailure\": true, " + '\n' + + " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + return request; + + } + + // Success Scenario + private Map setupVariablesVIPER1() { + Map variables = new HashMap(); + variables.put("testMessageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("msoRequestId", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); + variables.put("networkName", "MNS-25180-L-01-dmz_direct_net_1"); + variables.put("lcpCloudRegionId", "RDM2WAGPLCP"); + variables.put("tenantId", "88a6ca3ee0394ade9403f075db23167e"); + variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); + variables.put("disableRollback", "false"); // macro + variables.put("failIfExists", "false"); + //variables.put("sdncVersion", "1702"); + variables.put("sdncVersion", "1707"); + variables.put("subscriptionServiceType", "MSO-dev-service-type"); + variables.put("globalSubscriberId", "globalId_45678905678"); + variables.put("networkModelInfo", networkModelInfo); + variables.put("serviceModelInfo", serviceModelInfo); + return variables; + + } + + // Missing Name Scenario + private Map setupVariablesMissingNetworkId() { + Map variables = new HashMap(); + variables.put("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); + variables.put("bpmnRequest", getCreateNetworkRequestNetworkId()); + variables.put("requestId", "testRequestId"); + variables.put("isBaseVfModule", "true"); + variables.put("recipeTimeout", "0"); + variables.put("requestAction", "UPDATE"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", ""); + variables.put("vfModuleId", ""); + variables.put("volumeGroupId", ""); + //variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); // missing, ok + variables.put("serviceType", "vMOG"); + variables.put("vfModuleType", ""); + variables.put("networkType", "modelName"); + + return variables; + + } + + public String getCreateNetworkRequestNetworkId() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelId\": \"modelId\", " + '\n' + + " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"true\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + return request; + + } + + public String getCreateNetworkRequestSDNCRollback() { + + String request = + "{ \"requestDetails\": { " + '\n' + + " \"modelInfo\": { " + '\n' + + " \"modelType\": \"modelType\", " + '\n' + + " \"modelId\": \"modelId\", " + '\n' + + " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + + " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + + " \"modelVersion\": \"1\" " + '\n' + + " }, " + '\n' + + " \"cloudConfiguration\": { " + '\n' + + " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + + " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + + " }, " + '\n' + + " \"requestInfo\": { " + '\n' + + " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_3\", " + '\n' + + " \"source\": \"VID\", " + '\n' + + " \"callbackUrl\": \"\", " + '\n' + + " \"suppressRollback\": \"true\" ," + '\n' + + " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + + " }, " + '\n' + + " \"requestParameters\": { " + '\n' + + " \"userParams\": [] " + '\n' + + " } " + '\n' + + " } " + '\n' + + "}"; + + + return request; + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java new file mode 100644 index 0000000000..3997d0aaa0 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleInfraV2Test.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet; +import org.openecomp.mso.bpmn.common.WorkflowTest.TestAsyncResponse; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for UpdateVfModuleV2.bpmn + */ +public class UpdateVfModuleInfraV2Test extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public UpdateVfModuleInfraV2Test() throws IOException { + /*callbacks.put("changeassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml")); + callbacks.put("query", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("vnfUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestUpdateCallback.xml"));*/ + } + + @Test + @Ignore // IGNORED FOR 1710 MERGE TO ONAP + @Deployment(resources = { + "process/UpdateVfModuleInfraV2.bpmn", + "subprocess/DoUpdateVfModule.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + }) + + public void sunnyDay() throws Exception { + //logStart(); + + + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutVfModuleIdNoResponse("skask", "PCRF", "supercool"); + MockGetGenericVnfByIdWithPriority("skask", "supercool", 200, "VfModularity/VfModule-supercool.xml", 1); + mockSDNCAdapter("/SDNCAdapter", "SvcInstanceId><", 200, "VfModularity/StandardSDNCSynchResponse.xml"); + mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); + mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); + mockVNFPut("skask", "/supercool", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = setupVariablesSunnyDayVID(); + + String updateVfModuleRequest = + FileUtil.readResourceFile("__files/InfrastructureFlows/UpdateVfModule_VID_request.json"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleInfraV2", + "v1", businessKey, updateVfModuleRequest, variables); + + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + //String responseBody = response.getResponse(); + //System.out.println("Workflow (Synch) Response:\n" + responseBody); + + //logEnd(); + } + + // Active Scenario + private Map setupVariablesSunnyDayVID() { + Map variables = new HashMap(); + variables.put("requestId", "testRequestId"); + variables.put("isBaseVfModule", false); + variables.put("isDebugLogEnabled", "true"); + variables.put("recipeTimeout", "0"); + variables.put("requestAction", "UPDATE_VF_MODULE"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", "skask"); + variables.put("vnfType", "vSAMP12"); + variables.put("vfModuleId", "supercool"); + variables.put("volumeGroupId", ""); + variables.put("serviceType", "MOG"); + variables.put("vfModuleType", ""); + variables.put("moduleUuid", "fe6985cd-ea33-3346-ac12-ab121484a3fe"); + return variables; + + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java new file mode 100644 index 0000000000..496dab4f83 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVnfInfraTest.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetPserverByVnfId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSetInMaintFlagByVnfId; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; +import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for UpdateVnfInfra.bpmn + */ +public class UpdateVnfInfraTest extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public UpdateVnfInfraTest() throws IOException { + callbacks.put("changeassign", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyChangeAssignCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("query", FileUtil.readResourceFile( + "__files/VfModularity/SDNCTopologyQueryCallback.xml")); + callbacks.put("vnfUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestUpdateCallback.xml")); + } + + /** + * Sunny day scenario. + * + * @throws Exception + */ + @Test + @Ignore // IGNORED FOR 1710 MERGE TO ONAP + @Deployment(resources = { + "process/UpdateVnfInfra.bpmn", + "subprocess/DoUpdateVfModule.bpmn", + "subprocess/DoUpdateVnfAndModules.bpmn", + "subprocess/PrepareUpdateAAIVfModule.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/BuildingBlock/RainyDayHandler.bpmn", + "subprocess/BuildingBlock/ManualHandling.bpmn" + + }) + public void sunnyDay() throws Exception { + + logStart(); + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + //MockGetGenericVnfById_404("testVnfId"); + MockGetServiceResourcesCatalogData("995256d2-5a33-55df-13ab-12abad84e7ff", "1.0", "VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json"); + MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); + MockPutGenericVnf(".*"); + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + mockVNFPut("skask", "/supercool", 202); + mockVNFPut("skask", "/lukewarm", 202); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + MockGetPserverByVnfId("skask", "AAI/AAI_pserverByVnfId.json", 200); + MockGetGenericVnfsByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200); + MockSetInMaintFlagByVnfId("skask", 200); + MockPolicySkip(); + + mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVnfRequest = + FileUtil.readResourceFile("__files/InfrastructureFlows/UpdateVnf_VID_request.json"); + + Map variables = setupVariablesSunnyDayVID(); + + + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVnfInfra", + "v1", businessKey, updaetVnfRequest, variables); + + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "changeassign, query"); + injectVNFRestCallbacks(callbacks, "vnfUpdate"); + injectSDNCCallbacks(callbacks, "activate"); + + // TODO add appropriate assertions + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleInfraSuccessIndicator", true); + + logEnd(); + } + + // Active Scenario + private Map setupVariablesSunnyDayVID() { + Map variables = new HashMap(); + //try { + // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); + //} + //catch (Exception e) { + + //} + //variables.put("mso-request-id", "testRequestId"); + variables.put("requestId", "testRequestId"); + variables.put("isDebugLogEnabled", "true"); + variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); + variables.put("vnfId", "skask"); + variables.put("vnfType", "vSAMP12"); + variables.put("serviceType", "MOG"); + + return variables; + + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json new file mode 100644 index 0000000000..c7361f88ef --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json @@ -0,0 +1,329 @@ +{ + "vnf-id": "example-vnf-id-val-90603", + "vnf-name": "example-vnf-name-val-56838", + "vnf-name2": "example-vnf-name2-val-56319", + "vnf-type": "example-vnf-type-val-30533", + "service-id": "example-service-id-val-28290", + "regional-resource-zone": "example-regional-resource-zone-val-11059", + "prov-status": "example-prov-status-val-59777", + "operational-status": "example-operational-status-val-22513", + "in-maint": true, + + "equipment-role": "example-equipment-role-val-23396", + "orchestration-status": "example-orchestration-status-val-59435", + "heat-stack-id": "example-heat-stack-id-val-96869", + "mso-catalog-key": "example-mso-catalog-key-val-30721", + "management-option": "example-management-option-val-61927", + "ipv4-oam-address": "example-ipv4-oam-address-val-23494", + "ipv4-loopback0-address": "example-ipv4-loopback0-address-val-87072", + "nm-lan-v6-address": "example-nm-lan-v6-address-val-91063", + "management-v6-address": "example-management-v6-address-val-80466", + "vcpu": 45837298, + "vcpu-units": "example-vcpu-units-val-86249", + "vmemory": 57288956, + "vmemory-units": "example-vmemory-units-val-13291", + "vdisk": 16937143, + "vdisk-units": "example-vdisk-units-val-73197", + + "is-closed-loop-disabled": true, + "summary-status": "example-summary-status-val-86438", + "encrypted-access-flag": true, + + + + + "model-invariant-id": "example-model-invariant-id-val-14704", + "model-version-id": "example-model-version-id-val-47847", + "model-customization-id": "example-model-customization-id-val-52688", + "widget-model-id": "example-widget-model-id-val-20939", + "widget-model-version": "example-widget-model-version-val-72210", + "as-number": "example-as-number-val-68358", + "regional-resource-subzone": "example-regional-resource-subzone-val-34391", + "nf-type": "example-nf-type-val-54866", + "nf-function": "example-nf-function-val-24790", + "nf-role": "example-nf-role-val-4780", + "nf-naming-code": "example-nf-naming-code-val-25118", + "selflink": "example-selflink-val-68404", + + + + + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-50593", + "interface-role": "example-interface-role-val-23375", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-5921", + "selflink": "example-selflink-val-75663", + "interface-id": "example-interface-id-val-37465", + "macaddr": "example-macaddr-val-62657", + "network-name": "example-network-name-val-7252", + "management-option": "example-management-option-val-32963", + "interface-description": "example-interface-description-val-89453", + "is-port-mirrored": true, + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-16684", + "vlan-id-inner": 8602916, + "vlan-id-outer": 97348542, + "speed-value": "example-speed-value-val-90330", + "speed-units": "example-speed-units-val-15849", + "vlan-description": "example-vlan-description-val-46942", + "backdoor-connection": "example-backdoor-connection-val-78445", + + "orchestration-status": "example-orchestration-status-val-44994", + + + + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-90277", + "l3-interface-ipv4-prefix-length": 3364150, + "vlan-id-inner": 44021171, + "vlan-id-outer": 55708677, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-43267", + "neutron-subnet-id": "example-neutron-subnet-id-val-62870" + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-45323", + "l3-interface-ipv6-prefix-length": 56688923, + "vlan-id-inner": 5703071, + "vlan-id-outer": 86682265, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-28366", + "neutron-subnet-id": "example-neutron-subnet-id-val-53034" + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-4720", + "vf-vlan-filter": "example-vf-vlan-filter-val-42594", + "vf-mac-filter": "example-vf-mac-filter-val-13375", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-6057", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "vf-insert-stag": true, + "vf-link-status": "example-vf-link-status-val-81448", + "neutron-network-id": "example-neutron-network-id-val-9504" + } + ] + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-16738", + "interface-role": "example-interface-role-val-13943", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-63173", + "selflink": "example-selflink-val-43085", + "interface-id": "example-interface-id-val-51379", + "macaddr": "example-macaddr-val-16195", + "network-name": "example-network-name-val-45683", + "management-option": "example-management-option-val-78983", + "interface-description": "example-interface-description-val-34414", + "is-port-mirrored": true + } + ] + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-99078", + "l3-interface-ipv4-prefix-length": 55755841, + "vlan-id-inner": 81525473, + "vlan-id-outer": 90908072, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-47919", + "neutron-subnet-id": "example-neutron-subnet-id-val-84236" + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-21939", + "l3-interface-ipv6-prefix-length": 50057584, + "vlan-id-inner": 75774660, + "vlan-id-outer": 4421090, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-46377", + "neutron-subnet-id": "example-neutron-subnet-id-val-16585" + } + ] + } + ] + }, + "lag-interfaces": { + "lag-interface": [ + { + "interface-name": "example-interface-name-val-39234", + "interface-description": "example-interface-description-val-1037", + "speed-value": "example-speed-value-val-1929", + "speed-units": "example-speed-units-val-74937", + "interface-id": "example-interface-id-val-91265", + "interface-role": "example-interface-role-val-19613", + + + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-10722", + "interface-role": "example-interface-role-val-95194", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-24328", + "selflink": "example-selflink-val-24987", + "interface-id": "example-interface-id-val-75726", + "macaddr": "example-macaddr-val-36940", + "network-name": "example-network-name-val-65359", + "management-option": "example-management-option-val-49521", + "interface-description": "example-interface-description-val-70528", + "is-port-mirrored": true, + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-70827", + "vlan-id-inner": 55659612, + "vlan-id-outer": 90335612, + "speed-value": "example-speed-value-val-54761", + "speed-units": "example-speed-units-val-91398", + "vlan-description": "example-vlan-description-val-17018", + "backdoor-connection": "example-backdoor-connection-val-4021", + + "orchestration-status": "example-orchestration-status-val-18315", + + + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-59336", + "l3-interface-ipv4-prefix-length": 57636053, + "vlan-id-inner": 34068397, + "vlan-id-outer": 48570286, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-69862", + "neutron-subnet-id": "example-neutron-subnet-id-val-75795" + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-15038", + "l3-interface-ipv6-prefix-length": 42694503, + "vlan-id-inner": 15929806, + "vlan-id-outer": 87413856, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-52519", + "neutron-subnet-id": "example-neutron-subnet-id-val-24471" + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-44669", + "vf-vlan-filter": "example-vf-vlan-filter-val-53436", + "vf-mac-filter": "example-vf-mac-filter-val-71902", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-54963", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "vf-insert-stag": true, + "vf-link-status": "example-vf-link-status-val-1546", + "neutron-network-id": "example-neutron-network-id-val-92159" + } + ] + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-9327", + "interface-role": "example-interface-role-val-21859", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-21445", + "selflink": "example-selflink-val-6085", + "interface-id": "example-interface-id-val-39854", + "macaddr": "example-macaddr-val-14433", + "network-name": "example-network-name-val-3722", + "management-option": "example-management-option-val-64739", + "interface-description": "example-interface-description-val-5814", + "is-port-mirrored": true + + + + } + ] + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-64531", + "l3-interface-ipv4-prefix-length": 66545882, + "vlan-id-inner": 12194134, + "vlan-id-outer": 29589286, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-91108", + "neutron-subnet-id": "example-neutron-subnet-id-val-56984" + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-37408", + "l3-interface-ipv6-prefix-length": 5116459, + "vlan-id-inner": 39229896, + "vlan-id-outer": 15091934, + "is-floating": true, + "neutron-network-id": "example-neutron-network-id-val-87700", + "neutron-subnet-id": "example-neutron-subnet-id-val-37352" + } + ] + } + ] + } + } + ] + }, + "vf-modules": { + "vf-module": [ + { + "vf-module-id": "example-vf-module-id-val-56249", + "vf-module-name": "example-vf-module-name-val-18987", + "heat-stack-id": "example-heat-stack-id-val-80110", + "orchestration-status": "example-orchestration-status-val-8226", + "is-base-vf-module": true, + "model-invariant-id": "example-model-invariant-id-val-5071", + "model-version-id": "example-model-version-id-val-80793", + "model-customization-id": "example-model-customization-id-val-83277", + "widget-model-id": "example-widget-model-id-val-99814", + "widget-model-version": "example-widget-model-version-val-22799", + "contrail-service-instance-fqdn": "example-contrail-service-instance-fqdn-val-52133", + "module-index": 1933, + "selflink": "example-selflink-val-69992" + } + ] + }, + "licenses": { + "license": [ + { + "group-uuid": "example-group-uuid-val-73012", + "resource-uuid": "example-resource-uuid-val-80045" + } + ] + }, + "entitlements": { + "entitlement": [ + { + "group-uuid": "example-group-uuid-val-14874", + "resource-uuid": "example-resource-uuid-val-49146" + } + ] + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_pserverByVnfId.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_pserverByVnfId.json new file mode 100644 index 0000000000..1059d8c9a9 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/AAI/AAI_pserverByVnfId.json @@ -0,0 +1,72 @@ + { + + "result": [{ + + "hostname": "8862-PserverHOSTNAME-LB1113", + "equipType": "JUNIPER UCPE", + "equipVendor": "JUNIPER", + "equipModel": "QFX51010-PNF", + "ipv4OamAddress": "190.8.5.199", + "serialNumber": "VX986001PNF", + "pserverId": "5715CE4F-8600-58E103FE60C79", + "internetTopology": "WAN", + "inMaint": false, + "resourceVersion": "1500495668780", + "pserverName2": "test81600", + "relationshipList": { + "relationship": [ + { + "relatedTo": "vserver", + "relatedLink": "/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/8862-tenantl-LB1113/vservers/vserver/8862-Lvserver-LB1113", + "relationshipData": [ + { + "relationshipKey": "cloud-region.cloud-owner", + "relationshipValue": "att-aic" + }, + { + "relationshipKey": "cloud-region.cloud-region-id", + "relationshipValue": "AAIAIC25" + }, + { + "relationshipKey": "tenant.tenant-id", + "relationshipValue": "8862-tenantl-LB1113" + }, + { + "relationshipKey": "vserver.vserver-id", + "relationshipValue": "8862-Lvserver-LB1113" + } + ], + "relatedToProperty": [ + { + "propertyKey": "vserver.vserver-name", + "propertyValue": "hjZAYKyl5LO" + } + ] + } + ] + }, + "pinterfaces": { + "pinterface": [ + { + "interfaceName": "ge-0/5/8", + "speedValue": "1", + "speedUnits": "GBPS", + "resourceVersion": "1500495668784", + "inMaint": false + }, + { + "interfaceName": "ge-1/5/8", + "speedValue": "1", + "speedUnits": "GBPS", + "resourceVersion": "1500495668788", + "inMaint": false + } + ] + } + } + + + + ] +} + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml new file mode 100644 index 0000000000..e6af14123e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml @@ -0,0 +1,17 @@ + + + + + + + + 79ec9006-3695-4fcc-93a8-be6f9e248beb + 200 + OK + + <output xmlns="com:att:sdnctl:generic-resource"><response-message></response-message><svc-request-id>79ec9006-3695-4fcc-93a8-be6f9e248beb</svc-request-id><service-response-information><instance-id>f805ec2b-b4d8-473e-8325-67f110139e5d</instance-id></service-response-information><response-code>200</response-code><network-response-information><instance-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</instance-id><object-path>restconf/config/GENERIC-RESOURCE-API:services/service/f805ec2b-b4d8-473e-8325-67f110139e5d/service-data/networks/network/f7e4db56-aab5-4065-8e65-cec1cd1de24f</object-path></network-response-information><ack-final-indicator>Y</ack-final-indicator></output> + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..40bb93bda0 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml @@ -0,0 +1,19 @@ + + + + + + + + testRequestId + 200 + OK + + <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json index 91048eca9b..5a7ef5e2c7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json @@ -2,11 +2,11 @@ "requestDetails": { "modelInfo": { "modelType": "volumeGroup", - "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12::base::module-0", "modelVersion": "1", - "modelCustomizationId": "ee6478e5-ea33-3346-ac12-ab121484a3fe" + "modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe" }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", @@ -23,8 +23,8 @@ "instanceId": "{service-instance-id}", "modelInfo": { "modelType": "service", - "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "Test", "modelVersion": "2.0" } @@ -34,11 +34,11 @@ "instanceId": "{vnf-instance-id}", "modelInfo": { "modelType": "vnf", - "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1", - "modelCustomizationName": "vSAMP12" + "modelInstanceName": "vSAMP12" } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json index 72e41839fb..de99a6da56 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json @@ -3,7 +3,7 @@ "modelInfo": { "modelType": "volumeGroup", "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12::base::module-0", "modelVersion": "1" }, @@ -23,7 +23,7 @@ "modelInfo": { "modelType": "service", "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "{parent service model name}", "modelVersion": "1" } @@ -34,7 +34,7 @@ "modelInfo": { "modelType": "vnf", "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "Test/vSAMP12", "modelVersion": "1" } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml index cb20a41ca0..8d9efb3b39 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml @@ -29,6 +29,7 @@ simple_cinder_master Pending + ee6478e5-ea33-3346-ac12-ab121484a3fe 1460134360 diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml new file mode 100644 index 0000000000..8d9c5c0a43 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml @@ -0,0 +1,62 @@ + + 78987 + MSOTESTVOL102a-vSAMP12_base_vol_module-0 + + Test/vSAMP12 + Pending + 0000020 + + + generic-vnf + https://aai-ext1.test.att.com:8443/aai/v8/network/generic-vnfs/generic-vnf/9e48f6ea-f786-46de-800a-d480e5ccc846/ + + generic-vnf.vnf-id + 9e48f6ea-f786-46de-800a-d480e5ccc846 + + + generic-vnf.vnf-name + MSOSTSAMP12-10601 + + + + tenant + https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mdt1/tenants/tenant/fba1bd1e195a404cacb9ce17a9b2b421/ + + tenant.tenant-id + fba1bd1e195a404cacb9ce17a9b2b421 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mdt1 + + + tenant.tenant-name + ECOMP_MDT1 + + + + vf-module + https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mdt1/tenants/tenant/fba1bd1e195a404cacb9ce17a9b2b421/ + + vf-module.vf-module-id + fba1bd1e195a404cacb9ce17a9b2b421 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mdt1 + + + vf-module.vf-module-name + ECOMP_MDT1 + + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json index 1b56dbddbc..d1e5ee1bc6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json @@ -2,8 +2,8 @@ "requestDetails": { "modelInfo": { "modelType": "vfModule", -"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "STMTN5MMSC21-MMSC::model-1-0", "modelVersion": "1", "modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe" @@ -28,8 +28,8 @@ "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", "modelInfo": { "modelType": "volumeGroup", -"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12..base..module-0", "modelVersion": "1" } @@ -40,8 +40,8 @@ "instanceId": "123456", "modelInfo": { "modelType": "service", -"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "SERVICE_MODEL_NAME", "modelVersion": "1.0" } @@ -53,11 +53,11 @@ "instanceName": "skask-test", "modelInfo": { "modelType": "vnf", -"modelInvariantId": "skask", -"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "skask", +"modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1.0", -"modelCustomizationName": "vSAMP12 1" +"modelInstanceName": "vSAMP12 1" } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json index f8cac48f1f..55dc31309b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json @@ -2,8 +2,8 @@ "requestDetails": { "modelInfo": { "modelType": "vfModule", -"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "STMTN5MMSC21-MMSC::model-1-0", "modelVersion": "1", "modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe" @@ -28,8 +28,8 @@ "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", "modelInfo": { "modelType": "volumeGroup", -"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12..base..module-0", "modelVersion": "1" } @@ -40,8 +40,8 @@ "instanceId": "123456", "modelInfo": { "modelType": "service", -"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "SERVICE_MODEL_NAME", "modelVersion": "1.0" } @@ -53,11 +53,11 @@ "instanceName": "skask-test", "modelInfo": { "modelType": "vnf", -"modelInvariantId": "skask", -"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "skask", +"modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1.0", -"modelCustomizationName": "vSAMP12 1" +"modelInstanceName": "vSAMP12 1" } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DBUpdateResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DBUpdateResponse.xml new file mode 100644 index 0000000000..40e2344f36 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..8ec4f520c1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml @@ -0,0 +1,19 @@ + + + + + + + + 19174929-3809-49ca-89eb-17f84a035389 + 200 + OK + + <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml new file mode 100644 index 0000000000..f180e61366 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml @@ -0,0 +1,17 @@ + + + + + + + 19174929-3809-49ca-89eb-17f84a035389 + 200 + OK + + <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml new file mode 100644 index 0000000000..74a3beb221 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml @@ -0,0 +1,21 @@ + + + 86651f79-057e-4245-8f5f-174db3cef553-1502888133261 + true + 20928949-5230-495d-86a6-f3690b9b5d60 + + + shared_private_network_id + bcd04543-b3d7-4c64-a910-1735b875ebb2 + + + server1_port + d1605e82-50ba-4544-9f8d-a8a37b678046 + + + vnf_id + 7da56895-6be1-4bec-856b-525e0e573199 + + + 7da56895-6be1-4bec-856b-525e0e573199 + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json index 35ba121086..c6cc1ca428 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json @@ -2,7 +2,7 @@ "requestDetails": { "modelInfo": { "modelType": "volumeGroup", - "modelInvariantId": "0b01b8c2-8416-11e6-ae22-56b6b6499611", + "modelInvariantUuid": "0b01b8c2-8416-11e6-ae22-56b6b6499611", "modelName": "vSAMP12::base::module-0", "modelVersion": "1.0" }, diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json index 5ff965f7e2..5a05061098 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json @@ -3,7 +3,7 @@ "modelInfo": { "modelType": "volumeGroup", "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12::base::module-0", "modelVersion": "1" }, @@ -23,7 +23,7 @@ "modelInfo": { "modelType": "service", "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "{parent service model name}", "modelVersion": "1" } @@ -34,7 +34,7 @@ "modelInfo": { "modelType": "vnf", "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "Test/vSAMP12", "modelVersion": "1" } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml new file mode 100644 index 0000000000..021a8a73d1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml @@ -0,0 +1,26 @@ + + a27ce5a9-29c4-4c22-a017-6615ac73c721 + STMTN5MMSC21 + mmsc-capacity + SDN-MOBILITY + vMMSC + pending-create + false + false + 1508691 + + + 973ed047-d251-4fb9-bf1a-65b8949e0a73 + STMTN5MMSC21-MMSC::module-0-0 + 973ed047-d251-4fb9-bf1a-65b8949e0a73 + 1.0 + true + FILLED-IN-BY-MSO + pending-create + 1508692 + + + + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSINoRelations.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSINoRelations.xml new file mode 100644 index 0000000000..adb7aab35f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSINoRelations.xml @@ -0,0 +1,6 @@ + + MIS/1604/0026/SW_INTERNET + 123456789 + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml new file mode 100644 index 0000000000..80b035979a --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml @@ -0,0 +1,7 @@ + + + + service-instance + https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/aa8428ac-7dd2-441f-aa3e-e175802574fb + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json index 2b9c2879a7..3595c25584 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json @@ -2,11 +2,12 @@ "requestDetails": { "modelInfo": { "modelType": "vnf", - "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1.0", - "modelCustomizationName": "vSAMP12 1" + "modelInstanceName": "vSAMP12 1", + "modelCustomizationUuid": "customizationId123" }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", @@ -24,8 +25,8 @@ "instanceId": "{serviceInstanceId}", "modelInfo": { "modelType": "service", - "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "{parent service model name}", "modelVersion": "1.0" } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json index f90b9678f0..e8d9fc29b1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json @@ -2,11 +2,11 @@ "requestDetails": { "modelInfo": { "modelType": "vnf", - "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1.0", - "modelCustomizationName": "vSAMP12 1" + "modelInstanceName": "vSAMP12 1" }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", @@ -24,8 +24,8 @@ "instanceId": "{serviceInstanceId}", "modelInfo": { "modelType": "service", - "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "{parent service model name}", "modelVersion": "1.0" } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json new file mode 100644 index 0000000000..7c9717244b --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json @@ -0,0 +1,49 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vnf", +"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationUuid": "MODEL-ID-1234" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "mdt1", +"tenantId": "88a6ca3ee0394ade9403f075db23167e" +}, +"requestInfo": { +"instanceName": "STMTN", +"instanceId": "a27ce5a9-29c4-4c22-a017-6615ac73c721", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "MIS%2F1604%2F0026%2FSW_INTERNET", +"modelInfo": { +"modelType": "service", +"modelInvariantUuid": "995256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "ab6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "ServicevSAMP12", +"modelVersion": "1.0" +} +} +} +], +"requestParameters": { +"usePreload": false, +"userParams" : [ + { + "name" : "someUserParam", + "value" : "someValue" + }, + { + "name": "sgi_protected_subnet_id", + "value": "thisissomefakevalue" + } +] +} +} +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json index e3556e7b4a..c40a99ef34 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json @@ -2,11 +2,11 @@ "requestDetails": { "modelInfo": { "modelType": "vfModule", -"modelInvariantId": "introvert", -"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "introvert", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "STMTN5MMSC21-MMSC::model-1-0", "modelVersion": "1", -"modelCustomizationId": "MODEL12345" +"modelCustomizationUuid": "MODEL12345" }, "cloudConfiguration": { "lcpCloudRegionId": "MDTWNJ21", @@ -24,8 +24,8 @@ "instanceId": "123456", "modelInfo": { "modelType": "service", -"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", -"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "SERVICE_MODEL_NAME", "modelVersion": "1.0" } @@ -36,16 +36,26 @@ "instanceId": "skask", "modelInfo": { "modelType": "vnf", -"modelInvariantId": "skask", -"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelInvariantUuid": "skask", +"modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1.0", -"modelCustomizationName": "vSAMP12 1" +"modelInstanceName": "vSAMP12 1" } } } ], "requestParameters": { -"userParams": {} +"usePreload": false, +"userParams" : [ + { + "name" : "someUserParam", + "value" : "someValue" + }, + { + "name": "sgi_protected_subnet_id", + "value": "thisissomefakevalue" + } +] } } \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json new file mode 100644 index 0000000000..cdeaf92bb9 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json @@ -0,0 +1,49 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vnf", +"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationUuid": "MODEL-ID-1234" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "mdt1", +"tenantId": "88a6ca3ee0394ade9403f075db23167e" +}, +"requestInfo": { +"instanceName": "STMTN", +"instanceId": "skask", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "MIS%2F1604%2F0026%2FSW_INTERNET", +"modelInfo": { +"modelType": "service", +"modelInvariantUuid": "995256d2-5a33-55df-13ab-12abad84e7ff", +"modelUuid": "ab6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "ServicevSAMP12", +"modelVersion": "1.0" +} +} +} +], +"requestParameters": { +"usePreload": false, +"userParams" : [ + { + "name" : "someUserParam", + "value" : "someValue" + }, + { + "name": "sgi_protected_subnet_id", + "value": "thisissomefakevalue" + } +] +} +} +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policyAbortResponse.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policyAbortResponse.json new file mode 100644 index 0000000000..c315b1ed1d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policyAbortResponse.json @@ -0,0 +1 @@ +{"decision":"PERMIT","details":"Abort"} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policySkipResponse.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policySkipResponse.json new file mode 100644 index 0000000000..7cbdebb6b3 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/Policy/policySkipResponse.json @@ -0,0 +1 @@ +{"decision":"PERMIT","details":"Skip"} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml index 244a51e160..c48c6a661f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml @@ -9,7 +9,7 @@ tenant - https://aai-ext1.test.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mdt1/tenants/tenant/fba1bd1e195a404cacb9ce17a9b2b421/ + /aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mdt1/tenants/tenant/fba1bd1e195a404cacb9ce17a9b2b421/ tenant.tenant-id fba1bd1e195a404cacb9ce17a9b2b421 @@ -29,7 +29,7 @@ vf-module - http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf/9e48f6ea-f786-46de-800a-d480e5ccc846/vf-modules/vf-module/6a1dc898-b590-47b9-bbf0-34424a7a2ec3/ + /aai/v8/network/generic-vnfs/generic-vnf/9e48f6ea-f786-46de-800a-d480e5ccc846/vf-modules/vf-module/6a1dc898-b590-47b9-bbf0-34424a7a2ec3/ generic-vnf.vnf-id 9e48f6ea-f786-46de-800a-d480e5ccc846 diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json index 8ab460e24d..603c1f452f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json @@ -2,8 +2,8 @@ "requestDetails": { "modelInfo": { "modelType": "volumeGroup", - "modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12::base::module-0", "modelVersion": "1" }, @@ -22,8 +22,8 @@ "instanceId": "{service-instance-id}", "modelInfo": { "modelType": "service", - "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "Test", "modelVersion": "2.0" } @@ -33,11 +33,11 @@ "instanceId": "{vnf-instance-id}", "modelInfo": { "modelType": "vnf", - "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "Test/vSAMP12", "modelVersion": "1", - "modelCustomizationName": "vSAMP12" + "modelInstanceName": "vSAMP12" } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json index 963e2dd7d7..f32ba2994b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json @@ -2,8 +2,8 @@ "requestDetails": { "modelInfo": { "modelType": "volumeGroup", - "modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12::base::module-0", "modelVersion": "1" }, @@ -22,8 +22,8 @@ "instanceId": "{service-instance-id}", "modelInfo": { "modelType": "service", - "modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff-x", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff-x", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", "modelName": "Test", "modelVersion": "2.0" } @@ -33,11 +33,11 @@ "instanceId": "{vnf-instance-id}", "modelInfo": { "modelType": "vnf", - "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "Test/vSAMP12", "modelVersion": "1", - "modelCustomizationName": "vSAMP12" + "modelInstanceName": "vSAMP12" } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml index 58b8708809..85773cdb07 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml @@ -5,8 +5,8 @@ active true 1475077639 - ff5256d2-5a33-55df-13ab-12abad84e7ff - 1.0 + ff5256d2-5a33-55df-13ab-12abad84e7ff + 1.0 volume-group diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json new file mode 100644 index 0000000000..9126442ddb --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json @@ -0,0 +1,93 @@ +{ "serviceResources" : { + "modelInfo" : { + "modelName" : "MSO Test Network", + "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", + "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", + "modelVersion" : null + }, + "serviceVnfs": [ + { "modelInfo" : { + "modelName" : "vHNF for DHV Test", + "modelUuid" : "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "MODEL-ID-1234", + "modelInstanceName" : "vHNF for DHV Test 17" + }, + "toscaNodeType" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : "vSCP", + "nfNamingCode" : null, + "vfModules": [ + { + "modelInfo" : { + "modelName" : "VhnfForDhvTest..base_TEST..module-0", + "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0a", + "modelInvariantUuid" : "introvert", + "modelVersion" : "1", + "modelCustomizationUuid" : "1740536a-742e-40f5-b9c8-83918849a787" + }, "isBase" : true, + "vfModuleLabel" : "base_TEST", + "initialCount" : 1, + "hasVolumeGroup" : true + } + ] + } + ], + "serviceNetworks": [ + { + "modelInfo" : { + "modelName" : "CONTRAIL_BASIC", + "modelUuid" : "fe5be3a6-dbe0-46d6-bcac-44dc841a7edc", + "modelInvariantUuid" : "ab07fbd8-185a-45ac-be45-db3eb02e98d5", + "modelVersion" : null, + "modelCustomizationUuid" : "0cb9b26a-9820-48a7-86e5-16c510e993d9", + "modelInstanceName" : "CONTRAIL_BASIC 5" + }, + "toscaNodeType" : null, + "networkType" : null, + "networkTechnology" : null, + "networkRole" : null, + "networkScope" : null + } + ], + "serviceAllottedResources": [ + { + "modelInfo" : { + "modelName" : "IP_MUX_Demux", + "modelUuid" : "64a1a718-556b-48ce-b3b7-ed3237ccc94f", + "modelInvariantUuid" : "f110ef53-a0a6-4d72-ab91-fd88a835e8c4", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "4bab0880-2f06-4aeb-87cb-3734c8e8bf93", + "modelInstanceName" : "Pri_IP_MUX_Demux 1" + }, + "toscaNodeType" : null, + "allottedResourceType" : "ContrailRoute", + "allottedResourceRole" : null, + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null + }, + { + "modelInfo" : { + "modelName" : "Service_Admin", + "modelUuid" : "73501e03-ee76-4509-a8ce-96d2a9f33ee9", + "modelInvariantUuid" : "462edf71-1a3c-487b-bf55-497460ab7de3", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "a896ffad-c8f9-404e-a527-7a8d0cc99ce6", + "modelInstanceName" : "Pri_Service_Admin 5" + }, + "toscaNodeType" : null, + "allottedResourceType" : "SecurityZone", + "allottedResourceRole" : null, + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null + } + ] + }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json new file mode 100644 index 0000000000..eac0957fd3 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json @@ -0,0 +1,105 @@ +{ "serviceResources" : { + "modelInfo" : { + "modelName" : "MSO Test Network", + "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", + "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", + "modelVersion" : null + }, + "serviceVnfs": [ + { "modelInfo" : { + "modelName" : "vHNF for DHV Test", + "modelUuid" : "7097d8bb-f6ad-4cf7-866e-6a04c8f1b332", + "modelInvariantUuid" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "da86dd87-43c5-458c-b226-5315b7be9ad5", + "modelInstanceName" : "vHNF for DHV Test 17" + }, + "toscaNodeType" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : "vSCP", + "nfNamingCode" : null, + "vfModules": [ + { + "modelInfo" : { + "modelName" : "VhnfForDhvTest..base_TEST..module-0", + "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0a", + "modelInvariantUuid" : "introvert", + "modelVersion" : "1", + "modelCustomizationUuid" : "1740536a-742e-40f5-b9c8-83918849a787" + }, "isBase" : true, + "vfModuleLabel" : "base_TEST", + "initialCount" : 1, + "hasVolumeGroup" : true + }, + { + "modelInfo" : { + "modelName" : "VhnfForDhvTest..base_TEST..module-1", + "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0b", + "modelInvariantUuid" : "extrovert", + "modelVersion" : "1", + "modelCustomizationUuid" : "1740536a-742e-40f5-b9c8-83918849a788" + }, "isBase" : false, + "vfModuleLabel" : "addon_TEST", + "initialCount" : 1, + "hasVolumeGroup" : true + } + ] + } + ], + "serviceNetworks": [ + { + "modelInfo" : { + "modelName" : "CONTRAIL_BASIC", + "modelUuid" : "fe5be3a6-dbe0-46d6-bcac-44dc841a7edc", + "modelInvariantUuid" : "ab07fbd8-185a-45ac-be45-db3eb02e98d5", + "modelVersion" : null, + "modelCustomizationUuid" : "0cb9b26a-9820-48a7-86e5-16c510e993d9", + "modelInstanceName" : "CONTRAIL_BASIC 5" + }, + "toscaNodeType" : null, + "networkType" : null, + "networkTechnology" : null, + "networkRole" : null, + "networkScope" : null + } + ], + "serviceAllottedResources": [ + { + "modelInfo" : { + "modelName" : "IP_MUX_Demux", + "modelUuid" : "64a1a718-556b-48ce-b3b7-ed3237ccc94f", + "modelInvariantUuid" : "f110ef53-a0a6-4d72-ab91-fd88a835e8c4", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "4bab0880-2f06-4aeb-87cb-3734c8e8bf93", + "modelInstanceName" : "Pri_IP_MUX_Demux 1" + }, + "toscaNodeType" : null, + "allottedResourceType" : "ContrailRoute", + "allottedResourceRole" : null, + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null + }, + { + "modelInfo" : { + "modelName" : "Service_Admin", + "modelUuid" : "73501e03-ee76-4509-a8ce-96d2a9f33ee9", + "modelInvariantUuid" : "462edf71-1a3c-487b-bf55-497460ab7de3", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "a896ffad-c8f9-404e-a527-7a8d0cc99ce6", + "modelInstanceName" : "Pri_Service_Admin 5" + }, + "toscaNodeType" : null, + "allottedResourceType" : "SecurityZone", + "allottedResourceRole" : null, + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null + } + ] + }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json new file mode 100644 index 0000000000..94c1152204 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json @@ -0,0 +1,110 @@ +{ +"serviceResources" : { + "modelInfo" : { + "modelName" : "CMW_Service", + "modelUuid" : "", + "modelInvariantId" : "cmw-123-456-789", + "modelVersion" : "", + "modelCustomizationUuid" : "", + "modelInstanceName" : "", + "modelCustomizationName" : "", + "modelVersionId" : "Cmw_123", + "modelType" : "" + }, + "serviceInstanceData" : { + "instanceId" : "ff5256d2-5a33-55df-13ab-12abad84e7ff" + }, + "serviceNetworks" : [ { + "modelInfo" : { + "modelName" : "CONTRAIL30_BASIC", + "modelUuid" : "", + "modelInvariantId" : "not yet implemented", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "z_network_123", + "modelInstanceName" : "", + "modelCustomizationName" : "", + "modelVersionId" : "mod-inst-uuid-123", + "modelType" : "network" + }, + "instanceData" : { }, + "networkType" : "CONTRAIL30_BASIC" + } ], + "serviceVnfs" : [ { + "modelInfo" : { + "modelName" : "vSAMP12", + "modelUuid" : "", + "modelInvariantId" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelInstanceName" : "", + "modelCustomizationName" : "", + "modelVersionId" : "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelType" : "vnf" + }, + "instanceData" : { }, + "vfModules" : [ { + "modelInfo" : { + "modelName" : "vSAMP12::base::module-0", + "modelUuid" : "", + "modelInvariantId" : "miu-1001", + "modelVersion" : "1", + "modelCustomizationUuid" : "1001", + "modelInstanceName" : "", + "modelCustomizationName" : "", + "modelVersionId" : "", + "modelType" : "vfModule" + }, + "instanceData" : { }, + "hasVolumeGroup" : false, + "isBase" : true, + "initialCount" : 1 + }, { + "modelInfo" : { + "modelName" : "base::module-0", + "modelUuid" : "", + "modelInvariantId" : "miu-1002", + "modelVersion" : "1", + "modelCustomizationUuid" : "1002", + "modelInstanceName" : "", + "modelCustomizationName" : "", + "modelVersionId" : "", + "modelType" : "vfModule" + }, + "instanceData" : { }, + "hasVolumeGroup" : false, + "isBase" : true, + "initialCount" : 1 + }, { + "modelInfo" : { + "modelName" : "vSAMP12DEV::base::module-0", + "modelUuid" : "", + "modelInvariantId" : "miu-1003", + "modelVersion" : "1", + "modelCustomizationUuid" : "f86e8800-7629-427f-b284-3dbfd04db01f", + "modelInstanceName" : "", + "modelCustomizationName" : "", + "modelVersionId" : "", + "modelType" : "vfModule" + }, + "instanceData" : { }, + "hasVolumeGroup" : false, + "isBase" : true, + "initialCount" : 0 + } ] + } ], + "serviceAllottedResources" : [ { + "modelInfo" : { + "modelName" : "Bruce Wayne", + "modelUuid" : "", + "modelInvariantId" : "not yet implemented", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "ar-mod-custid-456-456", + "modelInstanceName" : "Clark Kent", + "modelCustomizationName" : "", + "modelVersionId" : "123-123", + "modelType" : "allottedResource" + }, + "instanceData" : { } + } ] + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml index 110e4327df..7c30f75497 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml @@ -1,4 +1,4 @@ - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml index 181473543f..fe874717a8 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml @@ -1,4 +1,4 @@ - + 12345678-f41f-4822-9323-b75962763d74 STMTN5MMSC20 pcrf-capacity diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml index 85427e2fcc..4712a5a464 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml @@ -1,4 +1,4 @@ - + skask STMTN5MMSC20 pcrf-capacity diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml index 27cab6b422..10af29a210 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml @@ -6,7 +6,7 @@ 9ddf628a-9eca-430e-8974-22d520a31be1 assign - https://msojra.infra.aic.att.net:8443/adapters/rest/SDNCNotify + https://msojra.infra.aic.net:8443/adapters/rest/SDNCNotify notsurewecare diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml index be6f973260..f96a073ef6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml @@ -20,7 +20,7 @@ 5e168556-a5c6-4813-bff3-cc03007afbbc - http://mtanjv9moja01-eth1-0.aic.cip.att.com:8080/adapters/rest/SDNCNotify + http://mtanjv9moja01-eth1-0.aic.cip.com:8080/adapters/rest/SDNCNotify assign diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml new file mode 100644 index 0000000000..50a71c110e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml @@ -0,0 +1,81 @@ + + + + 0725b072-b854-4705-bf8e-c1a1eb08651e + vSAMP10aDEV::base::module-0 + zmtn6nf-code-111_base_0 + + + vSAMP10aDEV::base::module-0 + 819ef122-ca19-4141-a61e-62922f8fc279 + ff2ae348-214a-11e7-93ae-92361f002673 + 3a97db99-c4bb-498a-a13a-38f65f1ced3d + ff2ae348-214a-11e7-93ae-92361f002673 + + 19123c2924c648eb8e42a3c1f14b7682 + mtn6 + AUSTTXGR + + + image + Ubuntu_Perf + + + flavor + m1.small + + + + + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml new file mode 100644 index 0000000000..bc2c7b9e63 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml @@ -0,0 +1,82 @@ + + + + nf-type-1 + zmtn6nf-code-111 + nf-role-1 + nf-function-1 + nf-code-1 + eac30f85-f61f-4c5f-862e-2c62f9e135de + null + + + vSAMP10a_macro + 819ef122-ca19-4141-a61e-62922f8fc279 + 1.0 + ef176121-f02c-4dd3-927c-22131d48446b + ff2ae348-214a-11e7-93ae-92361f002672 + + + + 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 + + + 19123c2924c648eb8e42a3c1f14b7682 + mtn6 + AUSTTXGR + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml index 8de2f95901..8db8610501 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml @@ -1,4 +1,4 @@ - + lukewarm PCRF::module-1 slowburn diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml index e72d23d9d9..10e85c0568 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml @@ -1,4 +1,4 @@ - + b37d96db-7d2c-47ce-bf61-a6c7b82fe161 PCRF::module-0-2 00000000-0000-0000-0000-000000000000 diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml index 15a84aad05..4e7d567564 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -1,4 +1,4 @@ - + supercool PCRF::module-2 fastburn diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties index b14d49511a..8a557c433a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties @@ -9,10 +9,12 @@ mso.csi.pwd=4EA237303511EFBBC37F17A351562131 mso.csi.usrname=mso mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 +mso.healthcheck.log.debug=false + mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess mso.workflow.message.endpoint=http://localhost:8080/mso/WorkflowMessage -mso.catalog.db.endpoint=http://localhost:8090 -mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter +mso.adapters.db.endpoint=http://localhost:28090/dbadapters/MsoRequestsDbAdapter +mso.openecomp.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC mso.adapters.network.endpoint=http://localhost:28090/networks/NetworkAdapter @@ -24,6 +26,7 @@ mso.po.timeout=PT60S aai.auth=757A94191D685FD2092AC1490730A4FC +mso.default.adapter.namespace=http://org.openecomp.mso mso.adapters.sdnc.endpoint=http://localhost:28090/SDNCAdapter mso.adapters.sdnc.rest.endpoint=http://localhost:28090/SDNCAdapter/v1/sdnc mso.adapters.sdnc.timeout=PT60S @@ -38,7 +41,7 @@ mso.sdnc.timeout.ucpe.async.minutes=5 mso.workflow.message.endpoint=http://localhost:28080/mso/WorkflowMesssage mso.workflow.sdncadapter.callback=http://localhost:28080/mso/SDNCAdapterCallbackService -mso.catalog.db.endpoint=http://localhost:28090/ +mso.catalog.db.endpoint=http://localhost:28090 mso.adapters.tenant.endpoint=http://localhost:28090/tenantAdapterMock mso.adapters.vnf-async.endpoint=http://localhost:28090/vnfs/VnfAdapterAsync @@ -84,4 +87,31 @@ log.debug.FalloutHandler=true log.debug.GenericGetService=true log.debug.sdncAdapter=true log.debug.UpdateNetworkInstanceInfra=true -log.debug.VnfAdapterRestV1=true \ No newline at end of file +log.debug.VnfAdapterRestV1=true +log.debug.CreateNetworkInstance=true +log.debug.DoCreateNetworkInstance=true +log.debug.DoCreateNetworkInstanceRollback=true +log.debug.DeleteNetworkInstance=true +log.debug.DoDeleteNetworkInstance=true +log.debug.DoDeleteNetworkInstanceRollback=true +log.debug.UpdateNetworkInstance=true +log.debug.DoUpdateNetworkInstance=true +log.debug.DoUpdateNetworkInstanceRollback=true +log.debug.CreateVnfInfra=true +log.debug.DoCreateVnf=true + +policy.client.auth=Basic bTAzNzQzOnBvbGljeVIwY2sk +policy.auth=Basic dGVzdHBkcDphbHBoYTEyMw== +policy.environment=TEST +policy.endpoint=http://localhost:28090/pdp/api/getDecision + +appc.topic.read=APPC-CL-FUSION-LCM-RESPONSE +appc.topic.read.timeout=60000 +appc.client.response.timeout=3600000 +appc.topic.write=APPC-CL-FUSION-LCM +appc.pool.members=uebsb91bodc.it.openecomp.org:3904,uebsb92bodc.it.openecomp.org:3904,uebsb93bodc.it.openecomp.org:3904 +appc.client.key=iaEMAfjsVsZnraBP +appc.client.secret=wcivUjsjXzmGFBfxMmyJu9dz + + + -- cgit 1.2.3-korg