From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- bpmn/so-bpmn-infrastructure-flows/pom.xml | 286 ++ .../CompareModelofE2EServiceInstance.groovy | 256 ++ .../scripts/CreateCustomE2EServiceInstance.groovy | 331 ++ .../CreateGenericALaCarteServiceInstance.groovy | 357 ++ .../scripts/CreateNetworkInstance.groovy | 455 ++ .../scripts/CreateSDNCNetworkResource.groovy | 327 ++ .../scripts/CreateVFCNSResource.groovy | 326 ++ .../scripts/CreateVfModuleInfra.groovy | 620 +++ .../scripts/CreateVfModuleVolumeInfraV1.groovy | 356 ++ .../infrastructure/scripts/CreateVnfInfra.groovy | 542 +++ .../scripts/DeleteCustomE2EServiceInstance.groovy | 386 ++ .../DeleteGenericALaCarteServiceInstance.groovy | 362 ++ .../scripts/DeleteNetworkInstance.groovy | 420 ++ .../scripts/DeleteSDNCNetworkResource.groovy | 308 ++ .../scripts/DeleteVFCNSResource.groovy | 87 + .../scripts/DeleteVfModuleInfra.groovy | 367 ++ .../scripts/DeleteVfModuleVolumeInfraV1.groovy | 545 +++ .../infrastructure/scripts/DeleteVnfInfra.groovy | 207 + .../scripts/DoCompareModelVersions.groovy | 258 ++ .../DoCompareModelofE2EServiceInstance.groovy | 260 ++ .../scripts/DoCreateE2EServiceInstance.groovy | 451 ++ .../DoCreateE2EServiceInstanceRollback.groovy | 268 ++ .../scripts/DoCreateNetworkInstance.groovy | 1680 ++++++++ .../scripts/DoCreateNetworkInstanceRollback.groovy | 393 ++ .../scripts/DoCreateResources.groovy | 279 ++ .../scripts/DoCreateServiceInstance.groovy | 795 ++++ .../scripts/DoCreateServiceInstanceRollback.groovy | 242 ++ .../DoCreateServiceInstanceRollbackV2.groovy | 72 + .../scripts/DoCreateServiceInstanceV2.groovy | 104 + .../DoCreateVFCNetworkServiceInstance.groovy | 282 ++ .../infrastructure/scripts/DoCreateVfModule.groovy | 2133 ++++++++++ .../scripts/DoCreateVfModuleRollback.groovy | 666 +++ .../scripts/DoCreateVfModuleVolumeRollback.groovy | 242 ++ .../scripts/DoCreateVfModuleVolumeV2.groovy | 616 +++ .../bpmn/infrastructure/scripts/DoCreateVnf.groovy | 618 +++ .../scripts/DoCreateVnfAndModules.groovy | 467 +++ .../scripts/DoCreateVnfAndModulesRollback.groovy | 360 ++ .../DoCustomDeleteE2EServiceInstance.groovy | 640 +++ .../DoCustomDeleteE2EServiceInstanceV2.groovy | 1132 +++++ .../scripts/DoDeleteE2EServiceInstance.groovy | 439 ++ .../scripts/DoDeleteNetworkInstance.groovy | 1077 +++++ .../scripts/DoDeleteNetworkInstanceRollback.groovy | 338 ++ .../scripts/DoDeleteResources.groovy | 317 ++ .../scripts/DoDeleteResourcesV1.groovy | 400 ++ .../scripts/DoDeleteServiceInstance.groovy | 472 +++ .../DoDeleteVFCNetworkServiceInstance.groovy | 285 ++ .../infrastructure/scripts/DoDeleteVfModule.groovy | 711 ++++ .../scripts/DoDeleteVfModuleFromVnf.groovy | 609 +++ .../scripts/DoDeleteVfModuleVolumeV2.groovy | 355 ++ .../bpmn/infrastructure/scripts/DoDeleteVnf.groovy | 161 + .../scripts/DoDeleteVnfAndModules.groovy | 538 +++ .../scripts/DoScaleE2EServiceInstance.groovy | 142 + .../DoScaleVFCNetworkServiceInstance.groovy | 332 ++ .../scripts/DoUpdateE2EServiceInstance.groovy | 451 ++ .../DoUpdateE2EServiceInstanceRollback.groovy | 345 ++ .../scripts/DoUpdateNetworkInstance.groovy | 1408 +++++++ .../scripts/DoUpdateNetworkInstanceRollback.groovy | 310 ++ .../infrastructure/scripts/DoUpdateVfModule.groovy | 1040 +++++ .../scripts/DoUpdateVnfAndModules.groovy | 414 ++ .../scripts/HealchCheckActivate.groovy | 59 + .../infrastructure/scripts/ReplaceVnfInfra.groovy | 611 +++ .../bpmn/infrastructure/scripts/RollbackVnf.groovy | 148 + .../scripts/ScaleCustomE2EServiceInstance.groovy | 296 ++ .../scripts/UpdateCustomE2EServiceInstance.groovy | 570 +++ .../scripts/UpdateNetworkInstance.groovy | 403 ++ .../infrastructure/scripts/UpdateVfModule.groovy | 326 ++ .../scripts/UpdateVfModuleInfra.groovy | 504 +++ .../scripts/UpdateVfModuleInfraV2.groovy | 468 +++ .../scripts/UpdateVfModuleVolume.groovy | 445 ++ .../scripts/UpdateVfModuleVolumeInfraV1.groovy | 561 +++ .../infrastructure/scripts/UpdateVnfInfra.groovy | 481 +++ .../bpmn/infrastructure/scripts/VnfCmBase.groovy | 835 ++++ .../infrastructure/scripts/VnfConfigUpdate.groovy | 483 +++ .../infrastructure/scripts/VnfInPlaceUpdate.groovy | 599 +++ .../vcpe/scripts/CreateVcpeResCustService.groovy | 814 ++++ .../vcpe/scripts/DeleteVcpeResCustService.groovy | 461 +++ .../scripts/DoCreateAllottedResourceBRG.groovy | 678 +++ .../DoCreateAllottedResourceBRGRollback.groovy | 279 ++ .../scripts/DoCreateAllottedResourceTXC.groovy | 674 +++ .../DoCreateAllottedResourceTXCRollback.groovy | 278 ++ .../scripts/DoDeleteAllottedResourceBRG.groovy | 368 ++ .../scripts/DoDeleteAllottedResourceTXC.groovy | 369 ++ .../src/main/resources/META-INF/processes.xml | 37 + .../process/CompareModelofE2EServiceInstance.bpmn | 335 ++ .../process/CreateAndActivatePnfResource.bpmn | 325 ++ .../process/CreateCustomE2EServiceInstance.bpmn | 391 ++ .../CreateGenericALaCarteServiceInstance.bpmn | 452 ++ .../resources/process/CreateNetworkInstance.bpmn | 340 ++ .../process/CreateSDNCNetworkResource.bpmn | 287 ++ .../resources/process/CreateVFCNSResource.bpmn | 277 ++ .../process/CreateVcpeResCustService.bpmn | 1539 +++++++ .../process/CreateVcpeResCustServiceV2.bpmn | 1443 +++++++ .../resources/process/CreateVfModuleInfra.bpmn | 700 ++++ .../process/CreateVfModuleVolumeInfraV1.bpmn | 514 +++ .../src/main/resources/process/CreateVnfInfra.bpmn | 340 ++ .../process/DeleteCustomE2EServiceInstance.bpmn | 381 ++ .../DeleteGenericALaCarteServiceInstance.bpmn | 331 ++ .../resources/process/DeleteNetworkInstance.bpmn | 372 ++ .../process/DeleteSDNCNetworkResource.bpmn | 258 ++ .../resources/process/DeleteVFCNSResource.bpmn | 166 + .../process/DeleteVcpeResCustService.bpmn | 812 ++++ .../resources/process/DeleteVfModuleInfra.bpmn | 331 ++ .../process/DeleteVfModuleVolumeInfraV1.bpmn | 568 +++ .../src/main/resources/process/DeleteVnfInfra.bpmn | 353 ++ .../main/resources/process/ReplaceVnfInfra.bpmn | 1815 ++++++++ .../process/ScaleCustomE2EServiceInstance.bpmn | 379 ++ .../process/UpdateCustomE2EServiceInstance.bpmn | 693 ++++ .../resources/process/UpdateNetworkInstance.bpmn | 322 ++ .../resources/process/UpdateVfModuleInfra.bpmn | 297 ++ .../resources/process/UpdateVfModuleInfraV2.bpmn | 412 ++ .../process/UpdateVfModuleVolumeInfraV1.bpmn | 517 +++ .../src/main/resources/process/UpdateVnfInfra.bpmn | 1685 ++++++++ .../main/resources/process/VnfConfigUpdate.bpmn | 1636 ++++++++ .../main/resources/process/VnfInPlaceUpdate.bpmn | 2302 +++++++++++ .../subprocess/DoCompareModelVersions.bpmn | 330 ++ .../DoCompareModelofE2EServiceInstance.bpmn | 227 + .../subprocess/DoCreateAllottedResourceBRG.bpmn | 755 ++++ .../DoCreateAllottedResourceBRGRollback.bpmn | 575 +++ .../subprocess/DoCreateAllottedResourceTXC.bpmn | 755 ++++ .../DoCreateAllottedResourceTXCRollback.bpmn | 575 +++ .../subprocess/DoCreateE2ENetworkInstance.bpmn | 136 + .../subprocess/DoCreateE2EServiceInstance.bpmn | 544 +++ .../DoCreateE2EServiceInstanceRollback.bpmn | 373 ++ .../subprocess/DoCreateE2EServiceInstanceV2.bpmn | 1051 +++++ .../subprocess/DoCreateNetworkInstance.bpmn | 1363 ++++++ .../DoCreateNetworkInstanceRollback.bpmn | 517 +++ .../resources/subprocess/DoCreateResources.bpmn | 370 ++ .../subprocess/DoCreateServiceInstance.bpmn | 515 +++ .../DoCreateServiceInstanceRollback.bpmn | 373 ++ .../DoCreateServiceInstanceRollbackV2.bpmn | 103 + .../subprocess/DoCreateServiceInstanceV2.bpmn | 197 + .../DoCreateVFCNetworkServiceInstance.bpmn | 261 ++ .../resources/subprocess/DoCreateVfModule.bpmn | 1701 ++++++++ .../subprocess/DoCreateVfModuleRollback.bpmn | 978 +++++ .../subprocess/DoCreateVfModuleVolumeRollback.bpmn | 247 ++ .../subprocess/DoCreateVfModuleVolumeV2.bpmn | 362 ++ .../src/main/resources/subprocess/DoCreateVnf.bpmn | 635 +++ .../subprocess/DoCreateVnfAndModules.bpmn | 527 +++ .../subprocess/DoCreateVnfAndModulesRollback.bpmn | 541 +++ .../DoCustomDeleteE2EServiceInstance.bpmn | 470 +++ .../DoCustomDeleteE2EServiceInstanceV2.bpmn | 928 +++++ .../subprocess/DoDeleteAllottedResourceBRG.bpmn | 422 ++ .../subprocess/DoDeleteAllottedResourceTXC.bpmn | 422 ++ .../subprocess/DoDeleteE2EServiceInstance.bpmn | 378 ++ .../subprocess/DoDeleteNetworkInstance.bpmn | 933 +++++ .../DoDeleteNetworkInstanceRollback.bpmn | 547 +++ .../resources/subprocess/DoDeleteResources.bpmn | 486 +++ .../resources/subprocess/DoDeleteResourcesV1.bpmn | 455 ++ .../subprocess/DoDeleteServiceInstance.bpmn | 373 ++ .../DoDeleteVFCNetworkServiceInstance.bpmn | 275 ++ .../resources/subprocess/DoDeleteVfModule.bpmn | 433 ++ .../subprocess/DoDeleteVfModuleFromVnf.bpmn | 396 ++ .../subprocess/DoDeleteVfModuleVolumeV2.bpmn | 208 + .../src/main/resources/subprocess/DoDeleteVnf.bpmn | 303 ++ .../subprocess/DoDeleteVnfAndModules.bpmn | 490 +++ .../subprocess/DoScaleE2EServiceInstance.bpmn | 187 + .../subprocess/DoScaleVFCServiceInstance.bpmn | 89 + .../subprocess/DoUnderlayVpnOperation.bpmn | 293 ++ .../subprocess/DoUpdateE2EServiceInstance.bpmn | 648 +++ .../DoUpdateE2EServiceInstanceRollback.bpmn | 799 ++++ .../subprocess/DoUpdateNetworkInstance.bpmn | 829 ++++ .../DoUpdateNetworkInstanceRollback.bpmn | 374 ++ .../resources/subprocess/DoUpdateVfModule.bpmn | 671 +++ .../subprocess/DoUpdateVnfAndModules.bpmn | 275 ++ .../src/main/resources/subprocess/RollbackVnf.bpmn | 346 ++ .../subprocess/SetRefactorServiceDecomp.bpmn | 68 + .../CreateCustomE2EServiceInstanceTest.groovy | 84 + ...CreateGenericAlaCarteServiceInstanceTest.groovy | 235 ++ .../scripts/CreateNetworkInstanceTest.groovy | 379 ++ .../scripts/CreateVfModuleInfraTest.groovy | 96 + .../scripts/CreateVfModuleVolumeInfraV1Test.groovy | 208 + .../DeleteCustomE2EServiceInstanceTest.groovy | 148 + ...DeleteGenericAlaCarteServiceInstanceTest.groovy | 125 + .../scripts/DeleteNetworkInstanceTest.groovy | 418 ++ .../scripts/DeleteVfModuleVolumeInfraV1Test.groovy | 167 + .../scripts/DoCreateE2EServiceInstanceTest.groovy | 103 + .../DoCreateNetworkInstanceRollbackTest.groovy | 369 ++ .../scripts/DoCreateNetworkInstanceTest.groovy | 4324 ++++++++++++++++++++ .../scripts/DoCreateServiceInstanceTest.groovy | 135 + .../DoCreateVFCNetworkServiceInstanceTest.groovy | 106 + .../scripts/DoCreateVfModuleRollbackTest.groovy | 202 + .../scripts/DoCreateVfModuleTest.groovy | 229 ++ .../scripts/DoCreateVfModuleVolumeV2Test.groovy | 135 + .../infrastructure/scripts/DoCreateVnfTest.groovy | 106 + .../DoCustomDeleteE2EServiceInstanceTest.groovy | 169 + .../DoDeleteNetworkInstanceRollbackTest.groovy | 343 ++ .../scripts/DoDeleteNetworkInstanceTest.groovy | 1948 +++++++++ .../scripts/DoDeleteServiceInstanceTest.groovy | 127 + .../scripts/DoDeleteVfModuleFromVnfTest.groovy | 172 + .../scripts/DoDeleteVfModuleTest.groovy | 163 + .../scripts/DoDeleteVfModuleVolumeV2Test.groovy | 152 + .../scripts/DoDeleteVnfAndModulesTest.groovy | 162 + .../scripts/DoScaleE2EServiceInstanceTest.groovy | 110 + .../DoUpdateNetworkInstanceRollbackTest.groovy | 332 ++ .../scripts/DoUpdateNetworkInstanceTest.groovy | 2762 +++++++++++++ .../scripts/DoUpdateVfModuleTest.groovy | 309 ++ .../scripts/DoUpdateVnfAndModulesTest.groovy | 126 + .../ScaleCustomE2EServiceInstanceTest.groovy | 195 + .../scripts/UpdateNetworkInstanceTest.groovy | 358 ++ .../scripts/UpdateVfModuleVolumeInfraV1Test.groovy | 134 + .../scripts/CreateVcpeResCustServiceTest.groovy | 1269 ++++++ .../scripts/DeleteVcpeResCustServiceTest.groovy | 773 ++++ .../DoCreateAllottedResourceBRGRollbackTest.groovy | 654 +++ .../scripts/DoCreateAllottedResourceBRGTest.groovy | 999 +++++ .../DoCreateAllottedResourceTXCRollbackTest.groovy | 654 +++ .../scripts/DoCreateAllottedResourceTXCTest.groovy | 957 +++++ .../scripts/DoDeleteAllottedResourceBRGTest.groovy | 606 +++ .../scripts/DoDeleteAllottedResourceTXCTest.groovy | 607 +++ .../so/bpmn/vcpe/scripts/GroovyTestBase.groovy | 124 + .../org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy | 49 + .../org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy | 50 + .../src/test/resources/CreateSiSample.json | 72 + .../stubprocess/DoCreateAllottedResourceBRG.bpmn | 54 + .../DoCreateAllottedResourceBRGRollback.bpmn | 55 + .../stubprocess/DoCreateAllottedResourceTXC.bpmn | 38 + .../DoCreateServiceInstanceRollback.bpmn | 53 + .../VCPE/stubprocess/DoCreateVnfAndModules.bpmn | 53 + .../stubprocess/DoCreateVnfAndModulesRollback.bpmn | 53 + .../VCPE/stubprocess/DoDeleteVnfAndModules.bpmn | 37 + .../test/resources/VCPE/stubprocess/Homing.bpmn | 35 + .../AAI/AAI_defaultCloudRegionByCloudRegionId.json | 12 + .../resources/__files/AAI/AAI_genericVnfGet.json | 9 + .../__files/AAI/AAI_genericVnfsByVnfId.json | 434 ++ .../resources/__files/AAI/AAI_pserverByVnfId.json | 72 + .../__files/AAI/AAI_vfModuleByVfModuleId.json | 27 + .../src/test/resources/__files/AAI/mockObject.json | 10 + .../test/resources/__files/APPC/appc_error.json | 21 + .../Network/createNetworkRequest.xml | 75 + .../Network/createNetworkResponse.xml | 31 + .../BuildingBlocks/Network/defaultNetwork.json | 10 + .../BuildingBlocks/Network/l3NetworkBbObject.json | 226 + .../Network/payloadUpdateCreated.json | 216 + .../Network/queryAAICloudRegion.json | 596 +++ .../Network/queryAAICloudRegion25.json | 596 +++ .../Network/queryAAICloudRegionError.json | 596 +++ .../Network/queryAAINetworkTestResponse.json | 141 + .../BuildingBlocks/Network/queryAAIResponse.json | 166 + .../Network/queryAAIResponseEmptyUri.json | 53 + .../Network/queryAAIVpnBindingTestResponse.json | 891 ++++ .../BuildingBlocks/Network/queryIdAAIResponse.xml | 145 + .../unassignNetworkBB_queryAAIResponse_.json | 162 + .../Network/updateContrailAAIPayloadRequest.xml | 149 + .../__files/BuildingBlocks/sniroCallback2AR1Vnf | 107 + .../BuildingBlocks/sniroCallback2AR1Vnf2Net | 165 + .../BuildingBlocks/sniroCallbackNoSolutionFound | 15 + .../BuildingBlocks/sniroCallbackPolicyException | 9 + .../BuildingBlocks/sniroCallbackServiceException | 12 + .../cloudRegion25_AAIResponse_Success.xml | 20 + .../cloudRegion30_AAIResponse_Success.xml | 20 + .../CreateNetworkV2/createNetworkResponse_400.xml | 6 + .../CreateNetworkV2/createNetworkResponse_500.xml | 80 + .../createNetworkResponse_Success.xml | 24 + .../createNetwork_queryInstance_Success.xml | 4 + ...reateNetwork_queryName2_AAIResponse_Success.xml | 62 + ...Network_queryNameActive_AAIResponse_Success.xml | 74 + .../createNetwork_queryName_AAIResponse_404.xml | 19 + ...createNetwork_queryName_AAIResponse_Success.xml | 62 + ...reateNetwork_queryNetworkId_AAIResponse_404.xml | 19 + ...ueryNetworkId_AAIResponse_NoPayload_Success.xml | 73 + ...eNetwork_queryNetworkId_AAIResponse_Success.xml | 110 + ...work_queryNetworkPolicy_AAIResponse_Success.xml | 21 + ...k_queryNetworkTableRef1_AAIResponse_Success.xml | 20 + ...k_queryNetworkTableRef2_AAIResponse_Success.xml | 20 + ...ork_queryVpnBindingList_AAIResponse_Success.xml | 57 + ...Network_queryVpnBinding_AAIResponse_Success.xml | 46 + ...eNetwork_updateContrail_AAIResponse_Success.xml | 11 + ...sdncCreateNetworkTopologyRsrcAssignResponse.xml | 15 + .../sdncCreateNetworkTopologySimResponse.xml | 17 + .../DoCreateServiceInstanceInput.json | 42 + .../SetupServiceDecompJson.json | 36 + ...e_createServiceInstance_AAIResponse_Success.xml | 11 + ...e_queryGlobalCustomerId_AAIResponse_Success.xml | 62 + .../CreateVfModuleCallbackException.xml | 7 + .../CreateVfModuleVolumeCallbackResponse.xml | 53 + .../CreateVfModuleVolumeRequest.xml | 24 + .../CreateVfModuleVolumeInfraV1/GenericVnf.xml | 38 + .../RollbackVfModuleVolumeCallbackResponse.xml | 5 + .../createVfModuleVolume_VID_request.json | 71 + ...createVfModuleVolume_VID_request_noreqparm.json | 45 + ...Volume_createVolumeName_AAIResponse_Success.xml | 49 + ...Volume_deleteVolumeName_AAIResponse_Success.xml | 24 + ...oduleVolume_queryVolumeName_AAIResponse_404.xml | 31 + ...eVolume_queryVolumeName_AAIResponse_Success.xml | 50 + ...Volume_updateVolumeName_AAIResponse_Success.xml | 24 + .../CreateVfModuleVolumeInfraV1/getSIUrlById.xml | 6 + ...ryVolumeId_AAIResponse_HasVfModRelationship.xml | 62 + .../__files/CreateVfModule_VID_request.json | 77 + .../CreateVfModule_VID_request_noPreloads.json | 79 + .../CreateVfModule_VID_request_userParam.json | 77 + .../test/resources/__files/DBUpdateResponse.xml | 4 + .../test/resources/__files/Database/DBAdapter.xml | 1 + .../__files/Database/DBUpdateResponse.xml | 4 + .../DeleteGenericVNFV1/sdncAdapterResponse.xml | 7 + .../cloudRegion25_AAIResponse_Success.xml | 20 + .../cloudRegion30_AAIResponse_Success.xml | 20 + .../deleteAAIResponse_Failure500_RESTFault.xml | 19 + .../deleteNetworkAAIResponse_Success.xml | 61 + ...NetworkAAIResponse_withRelationship_Success.xml | 73 + .../sdncDeleteNetworkTopologySimResponse.xml | 17 + ...DeleteNetworkTopologySimResponse_noExtraTag.xml | 17 + .../__files/DeleteVfModuleCallbackResponse.xml | 21 + .../DeleteVfModuleVolumeCallbackResponse.xml | 5 + .../deleteVfModuleVolume_VID_request_st.json | 17 + .../queryVolumeId_AAIResponse_Success.xml | 42 + .../__files/DeleteVfModule_VID_request.json | 50 + .../DoCreateVfModule/DoCreateVfModuleRequest.xml | 31 + .../cloudRegion_AAIResponse_Success.xml | 20 + .../__files/DoCreateVfModule/createVnfARequest.xml | 169 + .../DoCreateVfModule/getGenericVnfResponse.xml | 28 + .../__files/DoCreateVfModule/sdncGetResponse.xml | 195 + .../DoCreateVfModuleRollback/GenericVnf.xml | 26 + .../GenericVnfVfModule.xml | 26 + .../deactivateSDNCRequest.xml | 36 + .../sdncAdapterWorkflowRequest.xml | 37 + .../vnfAdapterRestV1Request.xml | 14 + .../CreateVfModuleVolumeCallbackResponse.xml | 53 + .../CreateVfModuleVolumeNoRollbackRequest.xml | 24 + .../CreateVfModuleVolumeRequest.xml | 24 + .../DoCreateVfModuleVolumeV1/GenericVnf.xml | 38 + .../RollbackVfModuleVolumeCallbackResponse.xml | 5 + .../createVfModuleVolume_VID_request.json | 104 + ...Volume_createVolumeName_AAIResponse_Success.xml | 49 + ...Volume_deleteVolumeName_AAIResponse_Success.xml | 24 + ...eVolume_queryVolumeName_AAIResponse_Success.xml | 49 + ...Volume_updateVolumeName_AAIResponse_Success.xml | 24 + .../cloudRegion_AAIResponse_Success.xml | 20 + .../vnfAdapterDeleteRequest.xml | 13 + .../__files/DoCreateVfModule_getVnfResponse.xml | 26 + .../DoDeleteVfModule/getGenericVnfResponse.xml | 28 + .../sdncAdapterWorkflowRequest.xml | 36 + .../cloudRegion_AAIResponse_Success.xml | 20 + .../DoUpdateVfModule/getGenericVnfResponse.xml | 28 + .../DoUpdateVfModule/sdncActivateRequest.xml | 36 + .../DoUpdateVfModule/sdncChangeAssignRequest.xml | 36 + .../__files/DoUpdateVfModule/sdncGetResponse.xml | 195 + .../DoUpdateVfModule/sdncTopologyRequest.xml | 11 + .../DoUpdateVfModule/vnfAdapterRestRequest.xml | 170 + .../__files/GenericFlows/MsoCompletionRequest.xml | 11 + .../__files/GenericFlows/SDNCDeleteResponse.xml | 212 + .../__files/GenericFlows/aaiGetResponse.xml | 33 + .../__files/GenericFlows/getARUrlById.xml | 6 + .../GenericFlows/getGenericVnfByNameResponse.xml | 23 + .../__files/GenericFlows/getGenericVnfResponse.xml | 90 + .../getGenericVnfResponse_hasRelationships.xml | 90 + .../resources/__files/GenericFlows/getNotFound.xml | 2 + .../__files/GenericFlows/getParentSIUrlById.xml | 6 + .../GenericFlows/getParentServiceInstance.xml | 30 + .../__files/GenericFlows/getSINoRelations.xml | 6 + .../__files/GenericFlows/getSIUrlById.xml | 6 + .../__files/GenericFlows/getSIUrlByIdVipr.xml | 7 + .../__files/GenericFlows/getServiceInstance.xml | 30 + .../InfrastructureFlows/ConfigVnf_VID_request.json | 39 + .../InfrastructureFlows/CreateVnfInfraRequest.json | 46 + .../DeleteCustomE2EService.json | 21 + .../DeleteVnfInfraRequestCascadeDelete.json | 39 + .../DoCreateServiceInstance_request.json | 186 + .../DoScaleE2EServiceInstance.json | 38 + .../ReplaceVnf_VID_request.json | 49 + .../UpdateVfModule_VID_request.json | 62 + .../InfrastructureFlows/UpdateVnf_VID_request.json | 56 + .../VnfInPlaceUpdate_VID_request.json | 16 + .../__files/Macro/CreateNetworkCollection.json | 70 + .../__files/Macro/ServiceMacroAssign.json | 125 + .../__files/Policy/policyAbortResponse.json | 1 + .../__files/Policy/policySkipResponse.json | 1 + .../__files/Schemas/ActivateServiceInstance.json | 7 + .../__files/Schemas/ActivateVnfSchema.json | 13 + .../Schemas/AssignServiceInstanceSchema.json | 16 + .../resources/__files/Schemas/AssignVnfSchema.json | 13 + .../sdncUpdateNetworkTopologySimResponse.xml | 17 + .../UpdateNetworkV2/updateNetworkResponse_400.xml | 6 + .../UpdateNetworkV2/updateNetworkResponse_500.xml | 80 + .../updateNetworkResponse_Success.xml | 24 + .../updateNetwork_queryInstance_Success.xml | 4 + ...ueryNetworkId_AAIResponse_NoPayload_Success.xml | 73 + ...eNetwork_queryNetworkId_AAIResponse_Success.xml | 95 + ...work_queryNetworkPolicy_AAIResponse_Success.xml | 21 + ...k_queryNetworkTableRef1_AAIResponse_Success.xml | 20 + ...k_queryNetworkTableRef2_AAIResponse_Success.xml | 20 + ...ork_queryVpnBindingList_AAIResponse_Success.xml | 57 + ...Network_queryVpnBinding_AAIResponse_Success.xml | 46 + ...eNetwork_updateContrail_AAIResponse_Success.xml | 11 + .../queryVolumeId_AAIResponse_Success.xml | 44 + .../updateVfModuleVolume_VID_request.json | 64 + .../updateVfModuleVolume_VID_request_2.json | 64 + .../updateVolumeGroupRequest.xml | 38 + .../vf_module_aai_response.xml | 29 + .../SDNCTopologyQueryBRGCallback.xml | 37 + .../SDNCTopologyQueryTXCCallback.xml | 24 + .../VCPE/CreateVcpeResCustService/arGetById.xml | 31 + .../getCatalogServiceResourcesData.json | 127 + .../getCatalogServiceResourcesNoData.json | 11 + .../VCPE/CreateVcpeResCustService/getCustomer.xml | 7 + .../VCPE/CreateVcpeResCustService/request.json | 40 + .../CreateVcpeResCustService/requestNoSIName.json | 39 + .../requestNoSINameNoRollback.json | 39 + .../VCPE/DeleteVcpeResCustService/arGetBRGById.xml | 31 + .../VCPE/DeleteVcpeResCustService/arGetTXCById.xml | 31 + .../DeleteVcpeResCustService/getBRGArUrlById.xml | 6 + .../VCPE/DeleteVcpeResCustService/getSI.xml | 35 + .../DeleteVcpeResCustService/getSIAfterDelArs.xml | 8 + .../DeleteVcpeResCustService/getTXCArUrlById.xml | 6 + .../VCPE/DeleteVcpeResCustService/request.json | 40 + .../DeleteVcpeResCustService/serviceToDelete.xml | 36 + .../SDNCTopologyQueryCallback.xml | 37 + .../VCPE/DoCreateAllottedResourceBRG/getAR.xml | 8 + .../VCPE/DoCreateAllottedResourceBRG/getArBrg.xml | 31 + .../VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml | 31 + .../DoCreateAllottedResourceBRG/getSIandAR.xml | 38 + .../arGetById.xml | 31 + .../sdncActivateRollbackReq.xml | 51 + .../sdncAssignRollbackReq.xml | 51 + .../sdncCreateRollbackReq.xml | 51 + .../SDNCTopologyQueryCallback.xml | 24 + .../VCPE/DoCreateAllottedResourceTXC/getAR.xml | 8 + .../VCPE/DoCreateAllottedResourceTXC/getArTxc.xml | 31 + .../VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml | 31 + .../DoCreateAllottedResourceTXC/getSIandAR.xml | 38 + .../arGetById.xml | 31 + .../sdncActivateRollbackReq.xml | 51 + .../sdncAssignRollbackReq.xml | 51 + .../sdncCreateRollbackReq.xml | 51 + .../VCPE/DoDeleteAllottedResourceBRG/arGetById.xml | 31 + .../VCPE/DoDeleteAllottedResourceTXC/arGetById.xml | 31 + .../VIPR/getCatalogServiceResourcesData.json | 94 + ...alogServiceResourcesDataForReplaceVnfInfra.json | 98 + ...talogServiceResourcesDataForUpdateVnfInfra.json | 110 + .../resources/__files/VIPR/getCatalogVnfData.json | 44 + .../VIPR/getCatalogVnfNoTwoPhasedForVfModule.json | 44 + .../VIPR/getCatalogVnfYesTwoPhasedForVfModule.json | 44 + .../__files/VIPR/serviceDecompositionATMFW.json | 110 + .../AddNetworkPolicy_AAIResponse_Success.xml | 21 + .../CreateVfModuleVolumeCallbackResponse.xml | 53 + .../__files/VfModularity/DBUpdateResponse.xml | 4 + .../VfModularity/DoUpdateVfModuleRequest.xml | 29 + .../GenerateVfModuleName_AAIResponse_Success.xml | 51 + .../resources/__files/VfModularity/GenericVnf.xml | 38 + .../QueryNetworkPolicy_AAIResponse_Success.xml | 21 + .../VfModularity/SDNCSITopologyAssignCallback.xml | 11 + .../VfModularity/SDNCTopologyActivateCallback.xml | 13 + .../VfModularity/SDNCTopologyAssignCallback.xml | 16 + .../SDNCTopologyChangeAssignCallback.xml | 13 + .../VfModularity/SDNCTopologyCreateCallback.xml | 16 + .../SDNCTopologyDeactivateCallback.xml | 13 + .../SDNCTopologyDeactivateCallbackNotFound.xml | 8 + .../VfModularity/SDNCTopologyDeleteCallback.xml | 16 + .../VfModularity/SDNCTopologyQueryCallback.xml | 315 ++ .../SDNCTopologyQueryCallbackVfModule.xml | 141 + .../SDNCTopologyQueryCallbackVfModuleNoVnf.xml | 81 + .../VfModularity/SDNCTopologyQueryCallbackVnf.xml | 82 + .../VfModularity/SDNCTopologyUnassignCallback.xml | 16 + .../VfModularity/StandardSDNCSynchResponse.xml | 5 + .../VfModularity/VNFAdapterRestCreateCallback.xml | 55 + .../VfModularity/VNFAdapterRestDeleteRequest.xml | 15 + .../VfModularity/VNFAdapterRestDeleteResponse.xml | 56 + .../VfModularity/VNFAdapterRestUpdateCallback.xml | 16 + .../VNFAdapterRestVolumeGroupCallback.xml | 15 + .../__files/VfModularity/VfModule-lukewarm.xml | 10 + .../VfModule-new-PendingActivation.xml | 9 + .../__files/VfModularity/VfModule-new.xml | 9 + .../__files/VfModularity/VfModule-supercool.xml | 27 + .../resources/__files/VfModularity/VolumeGroup.xml | 25 + .../__files/deleteNetworkResponse_Success.xml | 3 + .../src/test/resources/__files/requestDetails.json | 37 + .../src/test/resources/__files/schema.json | 16 + .../src/test/resources/application-test.yml | 340 ++ .../resources/applicationContext_forPnfTesting.xml | 65 + .../test/resources/catalogDBClientProps.properties | 1 + .../src/test/resources/logback-test.xml | 44 + .../resources/requestsDBClientProps.properties | 1 + .../test/resources/stubprocess/GenericStub.bpmn | 35 + 471 files changed, 122568 insertions(+) create mode 100644 bpmn/so-bpmn-infrastructure-flows/pom.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResources.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HealchCheckActivate.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/META-INF/processes.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CompareModelofE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVFCNSResource.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVFCNSResource.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVnfInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ScaleCustomE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfConfigUpdate.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfInPlaceUpdate.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelVersions.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelofE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRGRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXCRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2ENetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollbackV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceBRG.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceTXC.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResources.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleVFCServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUnderlayVpnOperation.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/RollbackVnf.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/SetRefactorServiceDecomp.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/CreateSiSample.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_defaultCloudRegionByCloudRegionId.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfGet.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_pserverByVnfId.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_vfModuleByVfModuleId.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/mockObject.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/APPC/appc_error.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/defaultNetwork.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/l3NetworkBbObject.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/payloadUpdateCreated.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion25.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegionError.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponse.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponseEmptyUri.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIVpnBindingTestResponse.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryIdAAIResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/unassignNetworkBB_queryAAIResponse_.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/updateContrailAAIPayloadRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_400.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_500.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryInstance_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName2_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNameActive_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_404.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_404.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/DoCreateServiceInstanceInput.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/SetupServiceDecompJson.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_createServiceInstance_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleCallbackException.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/GenericVnf.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/RollbackVfModuleVolumeCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_404.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/getSIUrlById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_userParam.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DBUpdateResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBAdapter.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBUpdateResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteGenericVNFV1/sdncAdapterResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion25_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteAAIResponse_Failure500_RESTFault.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/DeleteVfModuleVolumeCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModule_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/DoCreateVfModuleRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/cloudRegion_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/getGenericVnfResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/sdncGetResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnf.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnfVfModule.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/deactivateSDNCRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/sdncAdapterWorkflowRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/vnfAdapterRestV1Request.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/GenericVnf.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/RollbackVfModuleVolumeCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/vnfAdapterDeleteRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/getGenericVnfResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/sdncAdapterWorkflowRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/getGenericVnfResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncActivateRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncChangeAssignRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncGetResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncTopologyRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/vnfAdapterRestRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/MsoCompletionRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/SDNCDeleteResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/aaiGetResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getARUrlById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getNotFound.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentSIUrlById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentServiceInstance.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSINoRelations.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getServiceInstance.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ConfigVnf_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteCustomE2EService.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoCreateServiceInstance_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoScaleE2EServiceInstance.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policyAbortResponse.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policySkipResponse.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateServiceInstance.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateVnfSchema.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignServiceInstanceSchema.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignVnfSchema.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/sdncUpdateNetworkTopologySimResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesData.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfData.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfNoTwoPhasedForVfModule.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfYesTwoPhasedForVfModule.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DBUpdateResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenericVnf.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteRequest.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteResponse.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new-PendingActivation.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-supercool.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VolumeGroup.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/deleteNetworkResponse_Success.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/requestDetails.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/schema.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/applicationContext_forPnfTesting.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/catalogDBClientProps.properties create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/requestsDBClientProps.properties create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn (limited to 'bpmn/so-bpmn-infrastructure-flows') diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml new file mode 100644 index 0000000000..ee51ecd66e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -0,0 +1,286 @@ + + + org.onap.so + bpmn + 1.3.0-SNAPSHOT + + 4.0.0 + so-bpmn-infrastructure-flows + jar + + 7.8.0 + + + + + org.apache.cxf + cxf-codegen-plugin + 2.5.2 + + + org.apache.maven.plugins + maven-dependency-plugin + + + maven-failsafe-plugin + 2.6 + + + + integration-test + verify + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-antrun-plugin + + + [1.3,) + + + run + + + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + **/AllTestsTestSuite.java + + + + + tasks-test + + test + + + + **/AllTasksTestsTestSuite.java + + + + + bpmn-test + + test + + + + **/AllBPMNTestSuites.java + + + + + + + + ${project.artifactId}-${project.version} + + + + + + org.camunda.bpm + camunda-bom + ${camunda.version} + import + pom + + + + + + + org.camunda.bpm.springboot + camunda-bpm-spring-boot-starter + 2.3.0 + test + + + org.springframework.boot + spring-boot-starter-web + test + + + org.springframework.boot + spring-boot-starter-data-jpa + true + + + org.apache.cxf + cxf-spring-boot-starter-jaxws + 3.1.12 + + + org.apache.cxf + cxf-spring-boot-starter-jaxrs + 3.1.12 + + + org.apache.cxf + cxf-rt-rs-service-description-swagger + 3.1.11 + + + com.h2database + h2 + test + + + com.google.guava + guava + 22.0 + + + org.mockito + mockito-core + 1.10.19 + test + + + com.fasterxml.uuid + java-uuid-generator + + + org.codehaus.groovy + groovy-all + + + org.apache.commons + commons-lang3 + 3.4 + + + org.onap.so + MSOCoreBPMN + ${project.version} + + + org.onap.so + MSOCommonBPMN + ${project.version} + + + org.onap.so + MSOCoreBPMN + ${project.version} + tests + test + + + javax.ws.rs + javax.ws.rs-api + 2.0 + + + org.onap.so + MSORESTClient + ${project.version} + + + org.camunda.spin + camunda-spin-core + test + + + org.camunda.spin + camunda-spin-dataformat-all + test + + + camunda-spin-dataformat-all + org.camunda.spin + test + + + org.camunda.bpm + camunda-engine-plugin-spin + + + + org.camunda.bpm + camunda-engine-plugin-connect + test + + + javax.annotation + javax.annotation-api + 1.3 + + + org.onap.msb.java-sdk + msb-java-sdk + 1.0.0 + + + com.eclipsesource.jaxrs + jersey-all + + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + org.slf4j + slf4j-api + + + org.mariadb.jdbc + mariadb-java-client + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy new file mode 100644 index 0000000000..880a44c1b2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy @@ -0,0 +1,256 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.CompareModelsResult +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger + +import groovy.json.* + + +/** + * This groovy class supports the CompareModelofE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId + * @param - subscriptionServiceType + * @param - serviceInstanceId + * @param - modelInvariantIdTarget + * @param - modelVersionIdTarget + + * + * Outputs: + * @param - WorkflowException + */ +public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CompareModelofE2EServiceInstance.class); + + String Prefix="CMPMDSI_" + private static final String DebugFlag = "isDebugEnabled" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + public void preProcessRequest (DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + String msg = "" + + msoLogger.trace("preProcessRequest Request ") + + try { + // check for incoming json message/input + String siRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(siRequest) + + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + msoLogger.info("Input Request:" + siRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + msg = "Input serviceInstanceId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + utils.log("INFO", msg, isDebugEnabled) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //subscriptionServiceType + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("serviceType", subscriptionServiceType) + } + + //modelInvariantIdTarget + String modelInvariantIdTarget = jsonUtil.getJsonValue(siRequest, "modelInvariantIdTarget") + if (isBlank(modelInvariantIdTarget)) { + msg = "Input modelInvariantIdTarget' is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("modelInvariantIdTarget", modelInvariantIdTarget) + } + + //modelVersionIdTarget + String modelVersionIdTarget = jsonUtil.getJsonValue(siRequest, "modelVersionIdTarget") + if (isBlank(modelVersionIdTarget)) { + msg = "Input modelVersionIdTarget is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("modelVersionIdTarget", modelVersionIdTarget) + } + + execution.setVariable("operationType", "CompareModel") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void sendSyncResponse (DelegateExecution execution) { + msoLogger.trace("sendSyncResponse ") + + try { + CompareModelsResult compareModelsResult = execution.getVariable("compareModelsResult") + + // RESTResponse (for API Handler(APIH) Reply Task) + String syncResponse = compareModelsResult.toJsonStringNoRootName() + msoLogger.info(" sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse: " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit sendSyncResopnse ") + } + + public void sendSyncError (DelegateExecution execution) { + msoLogger.trace("sendSyncError ") + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + msoLogger.info(" Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + + } + + public void prepareCompletionRequest (DelegateExecution execution) { + msoLogger.trace("prepareCompletion ") + + try { + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + COMPAREMODEL + ${MsoUtils.xmlEscape(source)} + + E2E Service Instance Compare model successfully. + CompareModelofE2EServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + msoLogger.info(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit prepareCompletionRequest ") + } + + public void prepareFalloutRequest(DelegateExecution execution){ + msoLogger.trace("prepareFalloutRequest ") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.info(" Input Workflow Exception: " + wfex.toString()) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + COMPAREMODEL + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.info("Exception prepareFalloutRequest:" + ex.getMessage()) + String errorException = " Bpmn error encountered in CompareModelofE2EServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + COMPAREMODEL + UUI + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + msoLogger.trace("Exit prepareFalloutRequest ") + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy new file mode 100644 index 0000000000..1034fa2d4d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -0,0 +1,331 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils + +import groovy.json.* + +/** + * This groovy class supports the CreateServiceInstance.bpmn process. + * AlaCarte flow for 1702 ServiceInstance Create + * + */ +public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor { + String Prefix="CRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateCustomE2EServiceInstance.class); + + + public void preProcessRequest (DelegateExecution execution) { + msoLogger.trace("start preProcessRequest") + execution.setVariable("prefix",Prefix) + String msg = "" + + try { + String siRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(siRequest) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + msoLogger.debug("Input Request:" + siRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + serviceInstanceId = UUID.randomUUID().toString() + } + msoLogger.debug("Generated new Service Instance:" + serviceInstanceId) + serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestInfo + execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source")) + execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName")) + execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback")) + String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") + if (isBlank(productFamilyId)) + { + msg = "Input productFamilyId is null" + msoLogger.debug(msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("productFamilyId", productFamilyId) + } + + //modelInfo + String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") + if (isBlank(serviceModelInfo)) { + msg = "Input serviceModelInfo is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + msoLogger.debug("modelInfo: " + serviceModelInfo) + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } 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 userParamsList = reqMap.requestDetails?.requestParameters?.userParams + + Map inputMap = [:] + if (userParamsList) { + for (def i=0; i inputMap.put(param.key, param.value)} + } + } + + msoLogger.debug("User Input Parameters map: " + inputMap.toString()) + execution.setVariable("serviceInputParams", inputMap) + execution.setVariable("uuiRequest", inputMap.get("UUIRequest")) + execution.setVariable("mso.adapters.openecomp.db.endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + //TODO + //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) + //execution.setVariable("failExists", true) + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("finished preProcessRequest") + } + + public void sendSyncResponse (DelegateExecution execution) { + msoLogger.trace("start sendSyncResponse") + try { + String operationId = execution.getVariable("operationId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + // RESTResponse for API Handler (APIH) Reply Task + String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim() + msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + createServiceRestRequest) + sendWorkflowResponse(execution, 202, createServiceRestRequest) + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("finished sendSyncResponse") + } + + + public void sendSyncError (DelegateExecution execution) { + msoLogger.trace("start sendSyncError") + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + msoLogger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + msoLogger.trace("finished sendSyncError") + } + + public void prepareCompletionRequest (DelegateExecution execution) { + msoLogger.trace("start prepareCompletionRequest") + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + + Service Instance was created successfully. + ${MsoUtils.xmlEscape(serviceInstanceId)} + CreateGenericALaCarteServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + msoLogger.debug("Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("finished prepareCompletionRequest") + } + + public void prepareFalloutRequest(DelegateExecution execution){ + msoLogger.trace("start prepareFalloutRequest") + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug("Input Workflow Exception: " + wfex.toString()) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.debug("Exception prepareFalloutRequest:" + ex.getMessage()) + String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + UUI + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + msoLogger.trace("finished prepareFalloutRequest") + } + + /** + * Init the service Operation Status + */ + public void prepareInitServiceOperationStatus(DelegateExecution execution){ + msoLogger.trace("start prepareInitServiceOperationStatus") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = UUID.randomUUID().toString() + String operationType = "CREATE" + String userId = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + msoLogger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution) + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + msoLogger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(userId)} + ${MsoUtils.xmlEscape(result)} + ${MsoUtils.xmlEscape(operationContent)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(reason)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + msoLogger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload) + msoLogger.debug("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("finished prepareInitServiceOperationStatus") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy new file mode 100644 index 0000000000..4405718c57 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy @@ -0,0 +1,357 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONException; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils + +import groovy.json.* + +/** + * This groovy class supports the CreateGenericALaCarteServiceInstance.bpmn process. + * AlaCarte flow for 1702 ServiceInstance Create + * + */ +public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { + String Prefix="CRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateGenericALaCarteServiceInstance.class); + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + + try { + + String siRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(siRequest) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + msoLogger.debug("Input Request:" + siRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + serviceInstanceId = UUID.randomUUID().toString() + msoLogger.debug("Generated new Service Instance ID:" + serviceInstanceId) + } else { + msoLogger.debug("Using provided Service Instance ID:" + serviceInstanceId) + } + + serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestInfo + execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source")) + execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName")) + execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback")) + String productFamilyId = null; + try { + productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") + } catch (JSONException e) { + productFamilyId = null; + } + if (isBlank(productFamilyId)) + { + msg = "Input productFamilyId is null" + msoLogger.debug(msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("productFamilyId", productFamilyId) + } + + //modelInfo + String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") + if (isBlank(serviceModelInfo)) { + msg = "Input serviceModelInfo is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + msoLogger.debug("modelInfo" + serviceModelInfo) + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } 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.toString()) + } + } + + msoLogger.debug("User Input Parameters map: " + userParams.toString()) + execution.setVariable("serviceInputParams", inputMap) + + //TODO + //execution.setVariable("failExists", true) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest") + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Start sendSyncResponse") + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + // RESTResponse for API Handler (APIH) Reply Task + String createServiceRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + createServiceRestRequest) + sendWorkflowResponse(execution, 202, createServiceRestRequest) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit sendSyncResopnse") + } + + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Start sendSyncError") + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + msoLogger.debug(" Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + + } + + // ******************************* + // + // ******************************* + public void prepareDecomposeService(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Inside prepareDecomposeService of CreateGenericALaCarteServiceInstance ") + try { + String siRequest = execution.getVariable("bpmnRequest") + String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") + execution.setVariable("serviceModelInfo", serviceModelInfo) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.trace("Completed prepareDecomposeService of CreateGenericALaCarteServiceInstance") + } + + + // ******************************* + // + // ******************************* + public void prepareCreateServiceInstance(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + msoLogger.trace("Inside prepareCreateServiceInstance of CreateGenericALaCarteServiceInstance") + + /* + * Extracting User Parameters from incoming Request and converting into a Map + */ + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + def siRequest = execution.getVariable("bpmnRequest") + Map reqMap = jsonSlurper.parseText(siRequest) + //InputParams + def userParams = reqMap.requestDetails?.requestParameters?.userParams + Map inputMap = [:] + if (userParams != null) { + userParams.each { + userParam -> inputMap.put(userParam.name, userParam.value) + } + } + + msoLogger.debug("User Input Parameters map: " + userParams.toString()) + execution.setVariable("serviceInputParams", inputMap) + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + serviceDecomposition.getServiceInstance().setInstanceId(serviceInstanceId) + + String serviceInstanceName = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName") + serviceDecomposition.getServiceInstance().setInstanceName(serviceInstanceName) + execution.setVariable("serviceInstanceName", serviceInstanceName) + execution.setVariable("serviceDecomposition", serviceDecomposition) + execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString()) + msoLogger.debug("serviceDecomposition.serviceInstanceName: " + serviceDecomposition.getServiceInstance().getInstanceName()) + + msoLogger.trace("Completed prepareCreateServiceInstance of CreateGenericALaCarteServiceInstance ***** ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + public void prepareCompletionRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("prepareCompletion *** ") + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + + Service Instance was created successfully. + ${MsoUtils.xmlEscape(serviceInstanceId)} + CreateGenericALaCarteServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit prepareCompletionRequest") + } + + public void prepareFalloutRequest(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("prepareFalloutRequest") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug(" Input Workflow Exception: " + wfex.toString()) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.debug("Exception prepareFalloutRequest:" + ex.getMessage()) + String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + VID + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + msoLogger.trace("Exit prepareFalloutRequest") + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy new file mode 100644 index 0000000000..d665de2ba7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy @@ -0,0 +1,455 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger + +import groovy.json.* + +/** + * This groovy class supports the CreateNetworkInstance.bpmn process. + * + */ +public class CreateNetworkInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateNetworkInstance.class); + + String Prefix="CRENI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public InitializeProcessVariables(DelegateExecution execution){ + + execution.setVariable(Prefix + "source", "") + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "CompleteMsoProcessRequest", "") + execution.setVariable(Prefix + "FalloutHandlerRequest", "") + execution.setVariable(Prefix + "isSilentSuccess", false) + + } + + + /** + * This method is executed during the preProcessRequest task of the CreateNetworkInstance.bpmn process. + * @param execution + */ + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the CreateNetworkInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Start preProcessRequest") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null || sdncVersion == '1610') { + // 'a-la-cart' default, sdncVersion = '1610' + execution.setVariable("sdncVersion", "1610") + String bpmnRequest = execution.getVariable("bpmnRequest") + // set 'disableRollback' + if (bpmnRequest != null) { + String disableRollback = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.requestInfo.suppressRollback") + if (disableRollback != null) { + execution.setVariable("disableRollback", disableRollback) + msoLogger.debug("Received 'suppressRollback': " + disableRollback ) + } else { + execution.setVariable("disableRollback", false) + } + msoLogger.debug(" Set 'disableRollback' : " + execution.getVariable("disableRollback") ) + } else { + String dataErrorMessage = " Invalid 'bpmnRequest' request." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } else { + // 'macro' TEST ONLY, sdncVersion = '1702' + msoLogger.debug(" 'disableRollback' : " + execution.getVariable("disableRollback") ) + } + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + + // get/set 'requestId' + if (execution.getVariable("requestId") == null) { + execution.setVariable("requestId", requestId) + } + + //Place holder for additional code. + + // TODO ??? + // userParams??? 1) pre-loads indicator, 2) 'auto-activation' + // Tag/Value parameters + // + // Map: 'networkInputParams': 'auto-activation'' + // Sample format? + // "requestParameters": { + // "userParams": [ + // { + // "name": "someUserParam1", + // "value": "someValue1" + // } + // ] + // } + // + // String userParams = //use json util to extract "userParams"// + // execution.setVariable("networkInputParams", userParams) + // else: execution.setVariable("networkInputParams", null) + // + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in CreateNetworkInstance, PreProcessRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Start sendSyncResponse") + + try { + String requestId = execution.getVariable("mso-request-id") + + // RESTResponse (for API Handler (APIH) Reply Task) + String createNetworkRestRequest = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim() + + msoLogger.debug(" sendSyncResponse to APIH - " + "\n" + createNetworkRestRequest) + sendWorkflowResponse(execution, 202, createNetworkRestRequest) + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in CreateNetworkInstance flow. sendSyncResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + public void getNetworkModelInfo (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Start getNetworkModelInfo") + + try { + + // 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) + String exceptionMessage = "Bpmn error encountered in CreateNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Start sendSyncError") + + try { + + String requestId = execution.getVariable("mso-request-id") + + // REST Error (for API Handler (APIH) Reply Task) + String syncError = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim() + + sendWorkflowResponse(execution, 500, syncError) + + } catch (Exception ex) { + msoLogger.debug(" Bpmn error encountered in CreateNetworkInstance flow. sendSyncError() - " + ex.getMessage()) + } + + } + + public void prepareDBRequestError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + try { + msoLogger.trace("Start prepareDBRequestError") + + // set DB Header Authorization + setBasicDBAuthHeader(execution, isDebugEnabled) + + String statusMessage = "" + WorkflowException wfe = null + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + wfe = execution.getVariable("WorkflowException") + statusMessage = wfe.getErrorMessage() + } + + String requestId = execution.getVariable(Prefix + "requestId") + String networkName = execution.getVariable("networkName") !=null ? execution.getVariable("networkName") : "" + String networkId = execution.getVariable("networkId") !=null ? execution.getVariable("networkId") : "" + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + FAILED + <network-id>${MsoUtils.xmlEscape(networkId)}</network-id><network-name>${MsoUtils.xmlEscape(networkName)}</network-names> + + + """ + + execution.setVariable(Prefix + "createDBRequest", dbRequest) + msoLogger.debug(" DB Adapter Request - " + "\n" + dbRequest) + msoLogger.debug(dbRequest) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareDBRequestError() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareCompletion (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Start prepareCompletion") + + try { + + String requestId = execution.getVariable("mso-request-id") + String source = execution.getVariable(Prefix + "source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + VID + + Network has been created successfully. + BPMN Network action: CREATE + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + // normal path + execution.setVariable(Prefix + "Success", true) + execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + + + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void postProcessResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Start postProcessResponse") + + try { + + if (execution.getVariable("CMSO_ResponseCode") == "200") { + execution.setVariable(Prefix + "Success", true) + msoLogger.trace("CreateNetworkInstance Success ****") + // Place holder for additional code. + + } else { + execution.setVariable(Prefix + "Success", false) + msoLogger.trace("CreateNetworkInstance Failed in CompletionMsoProces flow!. ****") + + } + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + public void processRollbackData (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Start processRollbackData") + + try { + //execution.getVariable("orchestrationStatus") + //execution.getVariable("networkId") + //execution.getVariable("networkName") + //networkOutputParams + //rollbackData + //rolledBack + + } catch (Exception ex) { + msoLogger.debug(" Bpmn error encountered in CreateNetworkInstance flow. callDBCatalog() - " + ex.getMessage()) + } + + } + + // Prepare for FalloutHandler + public void buildErrorResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.debug("DB updateInfraRequest ResponseCode: " + execution.getVariable(Prefix + "dbReturnCode")) + msoLogger.debug("DB updateInfraRequest Response: " + execution.getVariable(Prefix + "createDBResponse")) + + msoLogger.trace("Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler.") + + 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() + falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + VID + + + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + + """ + + msoLogger.debug(falloutHandlerRequest) + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + msoLogger.debug(" Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest) + + } catch (Exception ex) { + String errorException = " Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse()" + msoLogger.debug("Exception error in CreateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage()) + falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + VID + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + msoLogger.debug(" Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest) + + } + + } + + public void processJavaException(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.debug("Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy new file mode 100644 index 0000000000..1c0975f8c4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -0,0 +1,327 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.json.XML; +import org.onap.so.bpmn.common.recipe.ResourceInput; +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger + +import groovy.json.* + +/** + * This groovy class supports the CreateSDNCCNetworkResource.bpmn process. + * flow for SDNC Network Resource Create + */ +public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateSDNCNetworkResource.class); + + String Prefix="CRESDNCRES_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest(DelegateExecution execution){ + msoLogger.trace("Started preProcessRequest ") + try { + + //get bpmn inputs from resource request. + String requestId = execution.getVariable("mso-request-id") + String requestAction = execution.getVariable("requestAction") + msoLogger.info("The requestAction is: " + requestAction) + String recipeParamsFromRequest = execution.getVariable("recipeParams") + msoLogger.info("The recipeParams is: " + recipeParamsFromRequest) + String resourceInput = execution.getVariable("resourceInput") + msoLogger.info("The resourceInput is: " + resourceInput) + //Get ResourceInput Object + ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) + execution.setVariable(Prefix + "resourceInput", resourceInputObj) + + //Deal with recipeParams + String recipeParamsFromWf = execution.getVariable("recipeParamXsd") + String resourceName = resourceInputObj.getResourceInstanceName() + //For sdnc requestAction default is "createNetworkInstance" + String operationType = "Network" + if(!StringUtils.isBlank(recipeParamsFromRequest)){ + //the operationType from worflow(first node) is second priority. + operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType") + } + if(!StringUtils.isBlank(recipeParamsFromWf)){ + //the operationType from worflow(first node) is highest priority. + operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") + } + + + //For sdnc, generate svc_action and request_action + String sdnc_svcAction = "create" + if(StringUtils.containsIgnoreCase(resourceInputObj.getResourceInstanceName(), "overlay")){ + //This will be resolved in R3. + sdnc_svcAction ="activate" + operationType = "NCINetwork" + } + if(StringUtils.containsIgnoreCase(resourceInputObj.getResourceInstanceName(), "underlay")){ + //This will be resolved in R3. + operationType ="Network" + } + String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" + execution.setVariable(Prefix + "svcAction", sdnc_svcAction) + execution.setVariable(Prefix + "requestAction", sdnc_requestAction) + execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) + execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) + //TODO Here build networkrequest + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + String customizeResourceParam(String netowrkInputParametersJson) { + List> paramList = new ArrayList(); + JSONObject jsonObject = new JSONObject(netowrkInputParametersJson); + Iterator iterator = jsonObject.keys(); + while (iterator.hasNext()) { + String key = iterator.next(); + HashMap hashMap = new HashMap(); + hashMap.put("name", key); + hashMap.put("value", jsonObject.get(key)) + paramList.add(hashMap) + } + Map>> paramMap = new HashMap(); + paramMap.put("param", paramList); + + return new JSONObject(paramMap).toString(); + } + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + public void prepareSDNCRequest (DelegateExecution execution) { + msoLogger.trace("Started prepareSDNCRequest ") + + try { + // get variables + String sdnc_svcAction = execution.getVariable(Prefix + "svcAction") + String sdnc_requestAction = execution.getVariable(Prefix + "requestAction") + String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String hdrRequestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + String source = execution.getVariable("source") + String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId") + ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") + String serviceType = resourceInputObj.getServiceType() + String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid() + String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid() + String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion() + String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName() + String globalCustomerId = resourceInputObj.getGlobalSubscriberId() + String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid(); + String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() + String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid() + String modelName = resourceInputObj.getResourceModelInfo().getModelName() + String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion() + String resourceInputPrameters = resourceInputObj.getResourceParameters() + String netowrkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs") + //here convert json string to xml string + String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(netowrkInputParametersJson))) + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = + """ + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(sdnc_svcAction)} + network-topology-operation + sdncCallback + generic-resource + + + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(sdnc_requestAction)} + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceType)} + + ${MsoUtils.xmlEscape(serviceModelInvariantUuid)} + ${MsoUtils.xmlEscape(serviceModelUuid)} + ${MsoUtils.xmlEscape(serviceModelVersion)} + ${MsoUtils.xmlEscape(serviceModelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(globalCustomerId)} + + + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + ${MsoUtils.xmlEscape(netowrkInputParameters)} + + + """.trim() + + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + msoLogger.debug(sndcTopologyCreateRequesAsString) + execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString) + msoLogger.debug("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyCreateRequesAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + msoLogger.trace("Exit prepareSDNCRequest ") + } + + private void setProgressUpdateVariables(DelegateExecution execution, String body) { + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + execution.setVariable("CVFMI_updateResOperStatusRequest", body) + } + + public void prepareUpdateBeforeCreateSDNCResource(DelegateExecution execution) { + ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") + String operType = resourceInputObj.getOperationType() + String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() + String ServiceInstanceId = resourceInputObj.getServiceInstanceId() + String operationId = resourceInputObj.getOperationId() + String progress = "20" + String status = "processing" + String statusDescription = "SDCN resource creation invoked" + + execution.getVariable("operationId") + + String body = """ + + + + + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(resourceCustomizationUuid)} + ${MsoUtils.xmlEscape(ServiceInstanceId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(statusDescription)} + + + """; + + setProgressUpdateVariables(execution, body) + + } + + public void prepareUpdateAfterCreateSDNCResource(execution) { + ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") + String operType = resourceInputObj.getOperationType() + String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() + String ServiceInstanceId = resourceInputObj.getServiceInstanceId() + String operationId = resourceInputObj.getOperationId() + String progress = "100" + String status = "finished" + String statusDescription = "SDCN resource creation completed" + + execution.getVariable("operationId") + + String body = """ + + + + + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(resourceCustomizationUuid)} + ${MsoUtils.xmlEscape(ServiceInstanceId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(statusDescription)} + + + """; + + setProgressUpdateVariables(execution, body) + } + + public void postCreateSDNCCall(DelegateExecution execution){ + msoLogger.trace("Started prepareSDNCRequest ") + String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") + String responseObj = execution.getVariable(Prefix + "SuccessIndicator") + + msoLogger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj) + msoLogger.trace("Exit prepareSDNCRequest ") + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) + + try { + String operationStatus = "finished" + // RESTResponse for main flow + String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() + utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled) + sendWorkflowResponse(execution, 202, resourceOperationResp) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy new file mode 100644 index 0000000000..26f12831bd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy @@ -0,0 +1,326 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import groovy.json.* + +/** + * This groovy class supports the DoCreateVFCNetworkServiceInstance.bpmn process. + * flow for VFC Network Service Create + */ +public class CreateVFCNSResource extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVFCNSResource.class); + + + String vfcUrl = "/vfc/rest/v1/vfcadapter" + + String host = "http://mso.mso.testlab.openecomp.org:8080" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + /** + * CreateVFCNSResource + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + public void preProcessRequest (DelegateExecution execution) { + JsonUtils jsonUtil = new JsonUtils() + + String msg = "" + msoLogger.trace("preProcessRequest() ") + try { + //deal with nsName and Description + String resourceInput = execution.getVariable("resourceInput") + + String resourceParameters = jsonUtil.getJsonValue(resourceInput, "resourceParameters") + // get service name + String resourceName = jsonUtil.getJsonValue(resourceInput, "resourceInstanceName") + execution.setVariable("nsServiceName", resourceName) + + String nsServiceDescription = execution.getVariable("nsServiceDescription") + msoLogger.info("nsServiceName:" + resourceName + " nsServiceDescription:" + nsServiceDescription) + //deal with operation key + String globalSubscriberId = jsonUtil.getJsonValue(resourceInput, "globalSubscriberId") + msoLogger.info("globalSubscriberId:" + globalSubscriberId) + //set local globalSubscriberId variable + execution.setVariable("globalSubscriberId", globalSubscriberId); + String serviceType = execution.getVariable("serviceType") + msoLogger.info("serviceType:" + serviceType) + + String serviceId = execution.getVariable("serviceInstanceId") + msoLogger.info("serviceId:" + serviceId) + + String operationId = jsonUtil.getJsonValue(resourceInput, "operationId") + msoLogger.info("serviceType:" + serviceType) + + String nodeTemplateUUID = jsonUtil.getJsonValue(resourceInput, "resourceModelInfo.modelCustomizationUuid") + String nsServiceModelUUID = jsonUtil.getJsonValue(resourceParameters, "requestInputs.nsd0_providing_service_uuid") + msoLogger.info("nodeTemplateUUID:" + nodeTemplateUUID) + /* + * segmentInformation needed as a object of segment + * { + * "domain":"", + * "nodeTemplateName":"", + * "nodeType":"", + * "nsParameters":{ + * //this is the nsParameters sent to VF-C + * } + * } + */ + String nsParameters = jsonUtil.getJsonValue(resourceInput, "resourceParameters") + msoLogger.info("nsParameters:" + nsParameters) + String nsOperationKey = """{ + "globalSubscriberId":"${globalSubscriberId}", + "serviceType":"${serviceType}", + "serviceId":"${serviceId}", + "operationId":"${operationId}", + "nodeTemplateUUID":"${nodeTemplateUUID}" + }""" + execution.setVariable("nsOperationKey", nsOperationKey); + execution.setVariable("nsParameters", nsParameters) + execution.setVariable("nsServiceModelUUID", nsServiceModelUUID); + + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + /** + * create NS task + */ + public void createNetworkService(DelegateExecution execution) { + msoLogger.trace("createNetworkService ") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID"); + String nsParameters = execution.getVariable("nsParameters"); + String nsServiceName = execution.getVariable("nsServiceName") + String nsServiceDescription = execution.getVariable("nsServiceDescription") + String locationConstraints = jsonUtil.getJsonValue(nsParameters, "locationConstraints") + String requestInputs = jsonUtil.getJsonValue(nsParameters, "requestInputs") + String reqBody ="""{ + "nsServiceName":"${nsServiceName}", + "nsServiceDescription":"${nsServiceDescription}", + "nsServiceModelUUID":"${nsServiceModelUUID}", + "nsOperationKey":${nsOperationKey}, + "nsParameters":{ + "locationConstraints":${locationConstraints}, + "additionalParamForNs":${requestInputs} + } + }""" + APIResponse apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String nsInstanceId = ""; + if(returnCode== "200" || returnCode == "201"){ + nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId") + } + execution.setVariable("nsInstanceId", nsInstanceId) + msoLogger.info(" *****Exit createNetworkService *****") + } + + /** + * instantiate NS task + */ + public void instantiateNetworkService(DelegateExecution execution) { + msoLogger.trace("instantiateNetworkService ") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String nsParameters = execution.getVariable("nsParameters"); + String nsServiceName = execution.getVariable("nsServiceName") + String nsServiceDescription = execution.getVariable("nsServiceDescription") + String reqBody ="""{ + "nsServiceName":"${nsServiceName}", + "nsServiceDescription":"${nsServiceDescription}", + "nsOperationKey":${nsOperationKey}, + "nsParameters":${nsParameters} + }""" + String nsInstanceId = execution.getVariable("nsInstanceId") + String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate" + APIResponse apiResponse = postRequest(execution, url, reqBody) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String jobId = ""; + if(returnCode== "200"|| returnCode == "201"){ + jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") + } + execution.setVariable("jobId", jobId) + msoLogger.info(" *****Exit instantiateNetworkService *****") + } + + /** + * query NS task + */ + public void queryNSProgress(DelegateExecution execution) { + msoLogger.trace("queryNSProgress ") + String jobId = execution.getVariable("jobId") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String url = host + vfcUrl + "/jobs/" + jobId + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String operationStatus = "error" + if(returnCode== "200"|| returnCode == "201"){ + operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status") + } + execution.setVariable("operationStatus", operationStatus) + msoLogger.info(" *****Exit queryNSProgress *****") + } + + /** + * delay 5 sec + */ + public void timeDelay(DelegateExecution execution) { + try { + Thread.sleep(5000); + } catch(InterruptedException e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Time Delay exception" + e , "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + } + } + + /** + * finish NS task + */ + public void addNSRelationship(DelegateExecution execution) { + msoLogger.trace("addNSRelationship ") + String nsInstanceId = execution.getVariable("nsInstanceId") + if(nsInstanceId == null || nsInstanceId == ""){ + msoLogger.info(" create NS failed, so do not need to add relationship") + return + } + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceId = execution.getVariable("serviceInstanceId") + String addRelationPayload = """ + service-instance + /aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId} + + customer.global-customer-id + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + service-subscription.service-type + ${MsoUtils.xmlEscape(serviceType)} + + + service-instance.service-instance-id + ${MsoUtils.xmlEscape(nsInstanceId)} + + """ + String endpoint = execution.getVariable("URN_aai_endpoint") + msoLogger.info("Add Relationship req:\n" + addRelationPayload) + String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship" + APIResponse aaiRsp = executeAAIPutCall(execution, url, addRelationPayload) + msoLogger.info("aai response status code:" + aaiRsp.getStatusCode()) + msoLogger.info("aai response content:" + aaiRsp.getResponseBodyAsString()) + msoLogger.info(" *****Exit addNSRelationship *****") + } + + public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){ + msoLogger.trace("Started Execute AAI Put Process ") + APIResponse apiResponse = null + try{ + String uuid = utils.getRequestID() + msoLogger.info("Generated uuid is: " + uuid) + msoLogger.info("URL to be used is: " + url) + String userName = execution.getVariable("URN_aai_auth") + String password = execution.getVariable("URN_mso_msoKey") + String basicAuthCred = utils.getBasicAuth(userName,password) + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + apiResponse = client.httpPut(payload) + msoLogger.trace("Completed Execute AAI Put Process ") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + + /** + * post request + * url: the url of the request + * requestBody: the body of the request + */ + private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){ + msoLogger.trace("Started Execute VFC adapter Post Process ") + msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) + APIResponse apiResponse = null + try{ + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); + apiResponse = client.httpPost(requestBody) + msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.trace("Completed Execute VF-C adapter Post Process ") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) + + try { + String operationStatus = execution.getVariable("operationStatus") + // RESTResponse for main flow + String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() + utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled) + sendWorkflowResponse(execution, 202, resourceOperationResp) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy new file mode 100644 index 0000000000..308c93540f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -0,0 +1,620 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.v12.GenericVnf; +import org.onap.appc.client.lcm.model.Action +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils; +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.aai.AAICreateResources; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVfModuleInfra.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + private AbstractServiceTaskProcessor taskProcessor + + public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + } + + /** + * Validates the request message and sets up the workflow. + * @param execution the execution + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.debug('Started ' + method) + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + + execution.setVariable("CVFMI_sentSyncResponse", false) + + def prefix = 'CVFMI_' + execution.setVariable('prefix', prefix) + execution.setVariable("isVidRequest", "false") + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + execution.setVariable("RollbackData", rollbackData) + + def incomingRequest = execution.getVariable('bpmnRequest') + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + msoLogger.debug("CreateVfModule Infra incoming Request: " + incomingRequest) + + setBasicDBAuthHeader(execution, isDebugLogEnabled) + + // check if request is xml or json + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + 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 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.toString()) + } + } + + msoLogger.debug('Processed user params: ' + userParamsMap) + + 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) + + // This is aLaCarte flow, so aLaCarte flag is always on + execution.setVariable(prefix + 'aLaCarte', true) + + 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("CreateVfModuleInfraSuccessIndicator", false) + execution.setVariable("RollbackCompleted", false) + + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("CVFMI_source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("CVFMI_requestInfo", requestInfo) + + //backoutOnFailure + + execution.setVariable("CVFMI_originalWorkflowException", null) + + + def newVfModuleId = UUID.randomUUID().toString() + execution.setVariable("newVfModuleId", newVfModuleId) + execution.setVariable(prefix + 'vfModuleId', newVfModuleId) + execution.setVariable('actionHealthCheck', Action.HealthCheck) + execution.setVariable('actionConfigScaleOut', Action.ConfigScaleOut) + execution.setVariable('controllerType', "APPC") + def controllerType = execution.getVariable('controllerType') + execution.setVariable(prefix + 'controllerType', controllerType) + execution.setVariable('healthCheckIndex0', 0) + + msoLogger.debug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo")) + + msoLogger.debug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled")) + + msoLogger.trace('Finished ' + method) + } catch (BpmnError bpmnError) { + throw bpmnError + } + catch(groovy.json.JsonException je) { + msoLogger.debug("Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest") + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + //execution.setVariable("CVFMODVOL2_RESTFault", restFaultMessage) + //execution.setVariable("CVFMODVOL2_isDataOk", false) + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest") + } + + } + + /** + * Validates a workflow response. + * @param execution the execution + * @param responseVar the execution variable in which the response is stored + * @param responseCodeVar the execution variable in which the response code is stored + * @param errorResponseVar the execution variable in which the error response is stored + */ + public void validateWorkflowResponse(DelegateExecution execution, String responseVar, + String responseCodeVar, String errorResponseVar) { + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar) + } + + + /** + * Sends the empty, synchronous response back to the API Handler. + * @param execution the execution + */ + public void sendResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Started ' + method) + + try { + def requestInfo = execution.getVariable('CVFMI_requestInfo') + def requestId = execution.getVariable('CVFMI_requestId') + def source = execution.getVariable('CVFMI_source') + + // RESTResponse (for API Handler (APIH) Reply Task) + def newVfModuleId = execution.getVariable("newVfModuleId") + String synchResponse = """{"requestReferences":{"instanceId":"${newVfModuleId}","requestId":"${requestId}"}}""".trim() + + sendWorkflowResponse(execution, 200, synchResponse) + + execution.setVariable("CVFMI_sentSyncResponse", true) + msoLogger.debug("CreateVfModule Infra Response: " + synchResponse) + msoLogger.trace('Finished ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered ", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + /** + * Query AAI for vnf orchestration status to determine if health check and config scaling should be run + */ + public void queryAAIForVnfOrchestrationStatus(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def vnfId = execution.getVariable("CVFMI_vnfId") + execution.setVariable("runHealthCheck", false); + execution.setVariable("runConfigScaleOut", false); + AAICreateResources aaiCreateResources = new AAICreateResources(); + Optional vnf = aaiCreateResources.getVnfInstance(vnfId); + if(vnf.isPresent()){ + def vnfOrchestrationStatus = vnf.get().getOrchestrationStatus(); + if("active".equalsIgnoreCase(vnfOrchestrationStatus)){ + execution.setVariable("runHealthCheck", false); + execution.setVariable("runConfigScaleOut", true); + } + } + } + + /** + * Retrieve data for ConfigScaleOut from SDNC topology + */ + + public void retreiveConfigScaleOutData(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def vfModuleId = execution.getVariable("CVFMI_vfModuleId") + String ipAddress = ""; + String oamIpAddress = ""; + String vnfHostIpAddress = ""; + + String vnfGetSDNC = execution.getVariable("DCVFM_getSDNCAdapterResponse"); + + String data = utils.getNodeXml(vnfGetSDNC, "response-data") + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") + + InputSource source = new InputSource(new StringReader(data)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document responseXml = docBuilder.parse(source) + + NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + Element eElement = (Element) node + String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") + String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") + if (vnfParameterName.equals("vlb_private_ip_1")) { + vnfHostIpAddress = vnfParameterValue + } + else if (vnfParameterName.equals("vdns_private_ip_0")) { + ipAddress = vnfParameterValue + } + else if (vnfParameterName.equals("vdns_private_ip_1")) { + oamIpAddress = vnfParameterValue + } + } + + String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"" + vnfHostIpAddress + "\",\"vf-module-id\":\"" + vfModuleId + "\"},\"configuration-parameters\":{\"ip-addr\":\"" + ipAddress +"\", \"oam-ip-addr\":\""+ oamIpAddress +"\",\"enabled\":\"true\"}}" + execution.setVariable("payload", payload); + } + + /** + * + * @param execution the execution + */ + public void postProcessResponse(DelegateExecution execution){ + msoLogger.trace("STARTED PostProcessResponse Process") + try{ + def requestInfo = execution.getVariable("CVFMI_requestInfo") + def action = utils.getNodeText(requestInfo, "action") + + msoLogger.debug("requestInfo is: " + requestInfo) + msoLogger.debug("action is: " + action) + + String payload = + """ + + ${requestInfo} + + Vf Module has been created successfully. + BPMN + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_SuccessFlag", true) + execution.setVariable("CVFMI_msoCompletionRequest", payload) + msoLogger.debug("CreateVfModuleInfra completion request: " + payload) + msoLogger.debug("Outgoing MsoCompletionRequest: \n" + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occured Processing PostProcessResponse - " + "\n", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occured during PostProcessResponse Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED PostProcessResponse Process") + } + + + + + + /** + * Validates the request, request id and service instance id. If a problem is found, + * a WorkflowException is generated and an MSOWorkflowException event is thrown. This + * method also sets up the log context for the workflow. + * @param execution the execution + * @return the validated request + */ + public String validateInfraRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateInfraRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Started ' + method) + + String processKey = getProcessKey(execution); + def prefix = execution.getVariable("prefix") + + if (prefix == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null") + } + + try { + def request = execution.getVariable(prefix + 'Request') + + if (request == null) { + request = execution.getVariable(processKey + 'Request') + + if (request == null) { + request = execution.getVariable('bpmnRequest') + } + + setVariable(execution, processKey + 'Request', null); + setVariable(execution, 'bpmnRequest', null); + setVariable(execution, prefix + 'Request', request); + } + + if (request == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null") + } + + /* + + def requestId = execution.getVariable("mso-request-id") + + if (requestId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") + } + + setVariable(execution, prefix + 'requestId', requestId) + + def serviceInstanceId = execution.getVariable("mso-service-instance-id") + + if (serviceInstanceId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") + } + + utils.logContext(requestId, serviceInstanceId) + */ + msoLogger.debug("CreateVfModule incoming request: " + request) + msoLogger.debug('Incoming message: ' + System.lineSeparator() + request) + msoLogger.trace('Finished ' + method) + return request + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") + } + } + + public void prepareUpdateInfraRequest(DelegateExecution execution){ + msoLogger.trace("STARTED prepareUpdateInfraRequest Process") + try{ + + String requestInfo = execution.getVariable("CVFMI_requestInfo") + def aicCloudRegion = execution.getVariable("CVFMI_lcpCloudRegionId") + def tenantId = execution.getVariable("CVFMI_tenantId") + def requestId = utils.getNodeText(requestInfo, "request-id") + def vnfId = execution.getVariable("CVFMI_vnfId") + def vfModuleId = execution.getVariable("CVFMI_vfModuleId") + // vfModuleName may be generated by DoCreateVfModule subprocess if it is not specified on the input + def vfModuleName = execution.getVariable("CVFMI_vfModuleName") + + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution) + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + msoLogger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + VF Module successfully created + + COMPLETE + 100 + <vnf-outputs xmlns="http://org.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"><vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id><vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id></vnf-outputs> + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleName)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateInfraRequest", payload) + msoLogger.debug("Outgoing UpdateInfraRequest: \n" + payload) + msoLogger.debug("CreateVfModuleInfra Outgoing UpdateInfra Request: " + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing prepareUpdateInfraRequest.", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateInfraRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED prepareUpdateInfraRequest Process") + } + + /** + * 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace("Started " + method) + + + try { + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def requestInformation = execution.getVariable("CVFMI_requestInfo") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInformation} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + + msoLogger.debug("CONTENT before translation: " + content) + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + msoLogger.debug("CreateVfModuleInfra FallOutHander Request: " + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } + + public void logAndSaveOriginalException(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateRollbackResponse(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + logWorkflowException(execution, 'CreateVfModuleInfra caught an event') + saveWorkflowException(execution, 'CVFMI_originalWorkflowException') + } + + public void validateRollbackResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateRollbackResponse(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + def originalException = execution.getVariable("CVFMI_originalWorkflowException") + execution.setVariable("WorkflowException", originalException) + + execution.setVariable("RollbackCompleted", true) + + } + + public void sendErrorResponse(DelegateExecution execution){ + msoLogger.trace("STARTED CreateVfModulenfra sendErrorResponse Process") + try { + def sentSyncResponse = execution.getVariable("CVFMI_sentSyncResponse") + if(sentSyncResponse == false){ + WorkflowException wfex = execution.getVariable("WorkflowException") + String response = exceptionUtil.buildErrorResponseXml(wfex) + msoLogger.debug(response) + sendWorkflowResponse(execution, 500, response) + }else{ + msoLogger.debug("Not Sending Error Response. Sync Response Already Sent") + } + + } catch (Exception ex) { + msoLogger.debug("Error Occured in CreateVfModuleInfra sendErrorResponse Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVfModuleInfra sendErrorResponse Process") + } + msoLogger.trace("COMPLETED CreateVfModuleInfra sendErrorResponse Process") + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy new file mode 100644 index 0000000000..aa569655f4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -0,0 +1,356 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.scripts.AaiUtil; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVfModuleVolumeInfraV1.class); + public static final String prefix='CVMVINFRAV1_' + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + setBasicDBAuthHeader(execution, isDebugEnabled) + preProcessRequest(execution, isDebugEnabled) + } + + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * @param execution + * @param isDebugEnabled + */ + public void preProcessRequest (DelegateExecution execution, isDebugEnabled) { + + execution.setVariable("prefix",prefix) + setSuccessIndicator(execution, false) + execution.setVariable(prefix+'syncResponseSent', false) + + String createVolumeIncoming = validateRequest(execution, 'vnfId') + msoLogger.debug(createVolumeIncoming) + + try { + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(createVolumeIncoming) + setupVariables(execution, reqMap, isDebugEnabled) + msoLogger.debug("XML request:\n" + createVolumeIncoming) + } + catch(groovy.json.JsonException je) { + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'Request is not a valid JSON document') + } + + // For rollback in this flow + setBasicDBAuthHeader(execution, isDebugEnabled) + setRollbackEnabled(execution, isDebugEnabled) + } + + + /** + * Set up variables that will be passed to the BB DoCreatevfModuleVolume flow + * @param execution + * @param requestMap + * @param serviceInstanceId + * @param isDebugLogEnabled + */ + public void setupVariables(DelegateExecution execution, Map requestMap, isDebugLogEnabled) { + + def jsonOutput = new JsonOutput() + + // volumeGroupId - is generated + String volumeGroupId = UUID.randomUUID() + execution.setVariable('volumeGroupId', volumeGroupId) + msoLogger.debug("Generated volumeGroupId: " + volumeGroupId) + + // volumeGroupName + def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: '' + execution.setVariable('volumeGroupName', volGrpName) + + // 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.toString()) + } + execution.setVariable('vfModuleInputParams', vfModuleInputMap) + + // disableRollback (true or false) + def disableRollback = requestMap.requestDetails.requestInfo.suppressRollback + execution.setVariable('disableRollback', disableRollback) + msoLogger.debug('disableRollback (suppressRollback) from request: ' + disableRollback) + + } + + + + public void sendSyncResponse (DelegateExecution execution, isDebugEnabled) { + def volumeGroupId = execution.getVariable('volumeGroupId') + def requestId = execution.getVariable("mso-request-id") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + String syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug("Sync Response: " + "\n" + syncResponse) + sendWorkflowResponse(execution, 200, syncResponse) + + execution.setVariable(prefix+'syncResponseSent', true) + } + + + public void sendSyncError (DelegateExecution execution, isDebugEnabled) { + WorkflowException we = execution.getVariable('WorkflowException') + def errorCode = we?.getErrorCode() + def errorMessage = we?.getErrorMessage() + //default to 400 since only invalid request will trigger this method + sendWorkflowResponse(execution, 400, errorMessage) + } + + + /** + * Create a WorkflowException + * @param execution + * @param isDebugEnabled + */ + public void buildWorkflowException(DelegateExecution execution, int errorCode, errorMessage, isDebugEnabled) { + msoLogger.debug(errorMessage) + (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) + } + + + /** + * Build Infra DB Request + * @param execution + * @param isDebugEnabled + */ + public void prepareDbInfraSuccessRequest(DelegateExecution 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" + + /* + from: $gVolumeGroup/aai:volume-group-id/text() + to: vnfreq:volume-outputs/vnfreq:volume-group-id + */ + // for now assume, generated volumeGroupId is accepted + def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') + + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + ${MsoUtils.xmlEscape(requestStatus)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(dbVnfOutputs)} + ${MsoUtils.xmlEscape(volumeGroupId)} + + + """ + + String buildDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable(prefix+"createDBRequest", buildDBRequestAsString) + msoLogger.debug("DB Infra Request: " + buildDBRequestAsString) + } + + + /** + * Build CommpleteMsoProcess request + * @param execution + * @param isDebugEnabled + */ + public void postProcessResponse (DelegateExecution execution, isDebugEnabled) { + + def dbReturnCode = execution.getVariable(prefix+'dbReturnCode') + def createDBResponse = execution.getVariable(prefix+'createDBResponse') + + msoLogger.debug('DB return code: ' + dbReturnCode) + msoLogger.debug('DB response: ' + createDBResponse) + + def requestId = execution.getVariable("mso-request-id") + def source = execution.getVariable(prefix+'source') + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + + Volume Group has been created successfully. + BPMN VF Module Volume action: CREATE + """ + + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable(prefix+'Success', true) + execution.setVariable(prefix+'CompleteMsoProcessRequest', xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } + + public void prepareFalloutHandlerRequest(DelegateExecution execution, isDebugEnabled) { + + WorkflowException we = execution.getVariable('WorkflowException') + def errorCode = we?.getErrorCode() + def errorMessage = we?.getErrorMessage() + + def requestId = execution.getVariable("mso-request-id") + def source = execution.getVariable(prefix+'source') + + String falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + + + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + + + """ + + // Format Response + String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest) + + execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest) + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Overall Error Response going to FalloutHandler", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "\n" + xmlHandlerRequest); + } + + + /** + * Query AAI service instance + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAIServiceInstance(DelegateExecution execution, isDebugEnabled) { + + def request = execution.getVariable(prefix+"Request") + def serviceInstanceId = utils.getNodeText(request, "service-instance-id") + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getSearchNodesQueryEndpoint(execution) + + def String queryAAIRequest = aaiEndpoint + "?search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId + msoLogger.debug("AAI query service instance request: " + queryAAIRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query service instance return code: " + returnCode) + msoLogger.debug("AAI query service instance response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode=='200') { + msoLogger.debug('Service instance ' + serviceInstanceId + ' found in AAI.') + } else { + if (returnCode=='404') { + def message = 'Service instance ' + serviceInstanceId + ' was not found in AAI. Return code: 404.' + msoLogger.debug(message) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + public void logAndSaveOriginalException(DelegateExecution execution, isDebugLogEnabled) { + logWorkflowException(execution, 'CreateVfModuleVolumeInfraV1 caught an event') + saveWorkflowException(execution, 'CVMVINFRAV1_originalWorkflowException') + } + + public void validateRollbackResponse(DelegateExecution execution, isDebugLogEnabled) { + + def originalException = execution.getVariable("CVMVINFRAV1_originalWorkflowException") + execution.setVariable("WorkflowException", originalException) + execution.setVariable("RollbackCompleted", true) + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy new file mode 100644 index 0000000000..9c25a57adc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -0,0 +1,542 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.CatalogDbUtils; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils; +import org.onap.so.bpmn.common.scripts.VidUtils; +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + + +/** + * This class supports the CreateVnfInfra Flow + * with the creation of a generic vnf for + * infrastructure. + */ +class CreateVnfInfra extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVnfInfra.class); + + + String Prefix="CREVI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + CatalogDbUtils cutils = new CatalogDbUtils() + AAICreateResources aaiCR = new AAICreateResources() + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED CreateVnfInfra PreProcessRequest Process") + + setBasicDBAuthHeader(execution, isDebugEnabled) + execution.setVariable("CREVI_sentSyncResponse", false) + + try{ + // Get Variables + String createVnfRequest = execution.getVariable("bpmnRequest") + execution.setVariable("CREVI_createVnfRequest", createVnfRequest) + msoLogger.debug("Incoming CreateVnfInfra Request is: \n" + createVnfRequest) + + if(createVnfRequest != null){ + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("CREVI_requestId", requestId) + msoLogger.debug("Incoming Request Id is: " + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("CREVI_serviceInstanceId", serviceInstanceId) + msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + + String vnfType = execution.getVariable("vnfType") + execution.setVariable("CREVI_vnfType", vnfType) + msoLogger.debug("Incoming Vnf Type is: " + vnfType) + + String vnfName = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.instanceName") + execution.setVariable("CREVI_vnfName", vnfName) + msoLogger.debug("Incoming Vnf Name is: " + vnfName) + + String serviceId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("CREVI_serviceId", serviceId) + msoLogger.debug("Incoming Service Id is: " + serviceId) + + String source = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.source") + execution.setVariable("CREVI_source", source) + msoLogger.debug("Incoming Source is: " + source) + + String suppressRollback = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("CREVI_suppressRollback", suppressRollback) + msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback) + + def vnfModelInfo = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo") + execution.setVariable("CREVI_vnfModelInfo", vnfModelInfo) + + String modelInvariantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelInvariantUuid") + execution.setVariable("CREVI_modelInvariantId", modelInvariantId) + msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId) + + String modelVersion = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelVersion") + execution.setVariable("CREVI_modelVersion", modelVersion) + msoLogger.debug("Incoming Model Version is: " + modelVersion) + + def cloudConfiguration = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration") + execution.setVariable("CREVI_cloudConfiguration", cloudConfiguration) + + String cloudSiteId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("CREVI_cloudSiteId", cloudSiteId) + msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId) + + String tenantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("CREVI_tenantId", tenantId) + msoLogger.debug("Incoming Tenant Id is: " + tenantId) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("CREVI_requestInfo", requestInfo) + + //TODO: Orch Status - TBD, will come from SDN-C Response in 1702 + String orchStatus = "Created" + execution.setVariable("CREVI_orchStatus", orchStatus) + + //TODO: Equipment Role - Should come from SDN-C Response in 1702 + String equipmentRole = " " + execution.setVariable("CREVI_equipmentRole", equipmentRole) + + String vnfId = execution.getVariable("testVnfId") // for junits + if(isBlank(vnfId)){ + vnfId = UUID.randomUUID().toString() + msoLogger.debug("Generated Vnf Id is: " + vnfId) + } + execution.setVariable("CREVI_vnfId", vnfId) + + // Setting for Sub Flow Calls + execution.setVariable("CREVI_type", "generic-vnf") + execution.setVariable("GENGS_type", "service-instance") + + String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError); + + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("CREVI_sdncCallbackUrl", sdncCallbackUrl) + + def vnfInputParameters = null + try { + vnfInputParameters = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestParameters.userParams") + } + catch (Exception e) { + msoLogger.debug("userParams are not present in the request") + } + execution.setVariable("CREVI_vnfInputParameters", vnfInputParameters) + + + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Bpmn Request is Null.") + } + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error Occurred in CreateVnfInfra PreProcessRequest method", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra PreProcessRequest") + + } + msoLogger.trace("COMPLETED CreateVnfInfra PreProcessRequest Process") + } + + public void sendSyncResponse (DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED CreateVnfInfra SendSyncResponse Process") + + try { + String requestId = execution.getVariable("CREVI_requestId") + String vnfId = execution.getVariable("CREVI_vnfId") + + String createVnfResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug("CreateVnfInfra Sync Response is: \n" + createVnfResponse) + + sendWorkflowResponse(execution, 202, createVnfResponse) + + execution.setVariable("CREVI_sentSyncResponse", true) + + } catch (Exception ex) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error Occurred in CreateVnfInfra SendSyncResponse Process", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra SendSyncResponse Process") + + } + msoLogger.trace("COMPLETED CreateVnfInfra SendSyncResponse Process") + } + + + public void preProcessSDNCAssignRequest(DelegateExecution execution){ + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCAssignRequest") + def vnfId = execution.getVariable("CREVI_vnfId") + def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId") + msoLogger.debug("NEW VNF ID: " + vnfId) + + try{ + //Build SDNC Request + + String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign") + + assignSDNCRequest = utils.formatXml(assignSDNCRequest) + execution.setVariable("CREVI_assignSDNCRequest", assignSDNCRequest) + msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCAssignRequest") + } + + public void preProcessSDNCActivateRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCActivateRequest Process") + try{ + String vnfId = execution.getVariable("CREVI_vnfId") + String serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId") + + String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate") + + execution.setVariable("CREVI_activateSDNCRequest", activateSDNCRequest) + msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCActivateRequest", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process") + } + + public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("CREVI_sdncCallbackUrl") + def requestId = execution.getVariable("CREVI_requestId") + def serviceId = execution.getVariable("CREVI_serviceId") + def vnfType = execution.getVariable("CREVI_vnfType") + def vnfName = execution.getVariable("CREVI_vnfName") + def tenantId = execution.getVariable("CREVI_tenantId") + def source = execution.getVariable("CREVI_source") + def vnfId = execution.getVariable("CREVI_vnfId") + def cloudSiteId = execution.getVariable("CREVI_cloudSiteId") + + String sdncVNFParamsXml = "" + + if(execution.getVariable("CREVI_vnfParamsExistFlag") == true){ + sdncVNFParamsXml = buildSDNCParamsXml(execution) + }else{ + sdncVNFParamsXml = "" + } + + String sdncRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + + + + ${MsoUtils.xmlEscape(requestId)} + VNFActivateRequest + ${MsoUtils.xmlEscape(source)} + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(svcInstId)} + notsurewecare + + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + ${sdncVNFParamsXml} + + + """ + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + execution.setVariable("prefix",Prefix) + msoLogger.debug("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + msoLogger.debug("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.trace("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.trace("COMPLETED ValidateSDNCResponse Process") + } + + public void prepareCompletionHandlerRequest(DelegateExecution execution){ + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED CreateVnfInfra PrepareCompletionHandlerRequest Process") + + try { + String requestInfo = execution.getVariable("CREVI_requestInfo") + String vnfId = execution.getVariable("CREVI_vnfId") + requestInfo = utils.removeXmlPreamble(requestInfo) + + String request = + """ + ${requestInfo} + Vnf has been created successfully. + ${MsoUtils.xmlEscape(vnfId)} + CreateVnfInfra + """ + + execution.setVariable("CREVI_completionHandlerRequest", request) + msoLogger.debug("Completion Handler Request is: " + request) + + execution.setVariable("WorkflowResponse", "Success") // for junits + + } catch (Exception ex) { + msoLogger.debug("Error Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process") + + } + msoLogger.trace("COMPLETED CreateVnfInfra PrepareCompletionHandlerRequest Process") + } + + public void sendErrorResponse(DelegateExecution execution){ + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED CreateVnfInfra sendErrorResponse Process") + try { + def sentSyncResponse = execution.getVariable("CREVI_sentSyncResponse") + if(sentSyncResponse == false){ + WorkflowException wfex = execution.getVariable("WorkflowException") + String response = exceptionUtil.buildErrorResponseXml(wfex) + + msoLogger.debug(response) + sendWorkflowResponse(execution, 500, response) + }else{ + msoLogger.debug("Not Sending Error Response. Sync Response Already Sent") + } + + } catch (Exception ex) { + msoLogger.debug("Error Occured in CreateVnfInfra sendErrorResponse Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra sendErrorResponse Process") + + } + msoLogger.trace("COMPLETED CreateVnfInfra sendErrorResponse Process") + } + + public void prepareFalloutRequest(DelegateExecution execution){ + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED CreateVnfInfra prepareFalloutRequest Process") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug(" Incoming Workflow Exception: " + wfex.toString()) + String requestInfo = execution.getVariable("CREVI_requestInfo") + msoLogger.debug(" Incoming Request Info: " + requestInfo) + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable("CREVI_falloutRequest", falloutRequest) + + + } catch (Exception ex) { + msoLogger.debug("Error Occured in CreateVnfInfra prepareFalloutRequest Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra prepareFalloutRequest Process") + + } + msoLogger.trace("COMPLETED CreateVnfInfra prepareFalloutRequest Process") + } + + + public void queryCatalogDB (DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED CreateVnfInfra QueryCatalogDB Process") + try { + //Get Vnf Info + String vnfModelInfo = execution.getVariable("CREVI_vnfModelInfo") + String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") + msoLogger.debug("querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) + + JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(execution, + vnfModelCustomizationUuid, "v2") + msoLogger.debug("obtained VNF list: " + vnfs) + + if (vnfs == null) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + 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) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + 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) { + msoLogger.debug("Error Occurred in CreateVnfInfra QueryCatalogDB Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra QueryCatalogDB Process") + } + + + msoLogger.trace("COMPLETED CreateVnfInfra QueryCatalogDb Process") + } + public void createPlatform (DelegateExecution execution) { + msoLogger.trace("START createPlatform") + + String request = execution.getVariable("bpmnRequest") + String platformName = jsonUtil.getJsonValue(request, "requestDetails.platform.platformName") + String vnfId = execution.getVariable("CREVI_vnfId") + + msoLogger.debug("Platform NAME: " + platformName) + msoLogger.debug("VnfID: " + vnfId) + + if(platformName == null||platformName.equals("")){ + String msg = "Exception in createPlatform. platformName was not found in the request."; + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + }else{ + msoLogger.debug("platformName was found.") + try{ + AAICreateResources aaiCR = new AAICreateResources() + aaiCR.createAAIPlatform(platformName, vnfId) + }catch(Exception ex){ + String msg = "Exception in createPlatform. " + ex.getMessage(); + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + msoLogger.trace("Exit createPlatform") + } + public void createLineOfBusiness (DelegateExecution execution) { + msoLogger.trace("START createLineOfBusiness") + + String request = execution.getVariable("bpmnRequest") + String lineOfBusiness = jsonUtil.getJsonValue(request, "requestDetails.lineOfBusiness.lineOfBusinessName") + String vnfId = execution.getVariable("CREVI_vnfId") + + msoLogger.debug("LineOfBusiness NAME: " + lineOfBusiness) + msoLogger.debug("VnfID: " + vnfId) + + if(lineOfBusiness == null || lineOfBusiness.equals("")){ + msoLogger.debug("LineOfBusiness was not found. Continuing on with flow...") + }else{ + msoLogger.debug("LineOfBusiness was found.") + try{ + AAICreateResources aaiCR = new AAICreateResources() + aaiCR.createAAILineOfBusiness(lineOfBusiness, vnfId) + }catch(Exception ex){ + String msg = "Exception in LineOfBusiness. " + ex.getMessage(); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + msoLogger.trace("Exit createLineOfBusiness") + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy new file mode 100644 index 0000000000..cbbc5189f4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy @@ -0,0 +1,386 @@ +/*- + + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils; + +import groovy.json.* + +/** + * This groovy class supports the DelE2EServiceInstance.bpmn process. + * + */ +public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DELSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteCustomE2EServiceInstance.class); + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + + msoLogger.info("Starting preProcessRequest") + + try { + // check for incoming json message/input + String siRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(siRequest) + + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + msoLogger.info("Input Request:" + siRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + msg = "Input serviceInstanceId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + + //requestInfo +// String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") +// if (isBlank(productFamilyId)) +// { +// msg = "Input productFamilyId is null" +// utils.log("INFO", msg, isDebugEnabled) +// //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) +// } else { +// execution.setVariable("productFamilyId", productFamilyId) +// } + String source = jsonUtil.getJsonValue(siRequest, "source") + execution.setVariable("source", source) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + msoLogger.info(msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + msoLogger.debug(msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + String operationId = jsonUtil.getJsonValue(siRequest, "operationId") + execution.setVariable("operationId", operationId) + + execution.setVariable("operationType", "DELETE") + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest") + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Staring sendSyncResponse") + + try { + String operationId = execution.getVariable("operationId") + String syncResponse = """{"operationId":"${operationId}"}""".trim() + msoLogger.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse: " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.trace("Exit sendSyncResopnse") + } + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.info("Starting sendSyncError") + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.info(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + msoLogger.info("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + + } + + public void prepareCompletionRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Starting prepareCompletion") + + try { + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + + E2E Service Instance was deleted successfully. + DeleteCustomE2EServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + msoLogger.info(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit prepareCompletionRequest") + } + + public void prepareFalloutRequest(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Starting prepareFalloutRequest ") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.info(" Input Workflow Exception: " + wfex.toString()) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.info("Exception prepareFalloutRequest:" + ex.getMessage()) + String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + VID + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + msoLogger.trace("Exit prepareFalloutRequest") + } + + + // ******************************* + // Build DB request Section + // ******************************* + public void prepareDBRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + msoLogger.info("Starting prepareDBRequest") + + String requestId = execution.getVariable("DELSI_requestId") + String statusMessage = "E2E Service Instance successfully deleted." + + //TODO - verify the format for Service Instance Delete, + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + COMPLETED + 100 + + + """ + + String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString) + msoLogger.info(buildDeleteDBRequestAsString) + + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteCustomE2EServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ******************************* + // Build Error Section + // ******************************* + public void prepareDBRequestError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Start prepareDBRequestError") + + try { + String requestId = execution.getVariable("DELSI_requestId") + String statusMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + statusMessage = wfe.getErrorMessage() + + } else { + statusMessage = "Encountered Error during DeleteCustomE2EServiceInstance proccessing. " + } + + //TODO - verify the format for Service Instance Create, + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + FAILED + + + """ + + String buildDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString) + msoLogger.info(buildDBRequestAsString) + + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteCustomE2EServiceInstance flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage() + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void processJavaException(DelegateExecution execution) { + //TODO: + } + + /** + * Init the service Operation Status + */ + public void prepareInitServiceOperationStatus(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String userId = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + DELETE + ${MsoUtils.xmlEscape(userId)} + ${MsoUtils.xmlEscape(result)} + ${MsoUtils.xmlEscape(operationContent)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(reason)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + } + utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy new file mode 100644 index 0000000000..b43a96bdb0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy @@ -0,0 +1,362 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger + +import groovy.json.* + +/** + * This groovy class supports the DelServiceInstance.bpmn process. + * + */ +public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DELSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteGenericALaCarteServiceInstance.class); + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + + msoLogger.trace("Start preProcessRequest") + + try { + // check for incoming json message/input + String siRequest = execution.getVariable("bpmnRequest") + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + msoLogger.debug("Input Request:" + siRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + msg = "Input serviceInstanceId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //String xmlRequestDetails = vidUtils.getJsonRequestDetailstoXml(siRequest) + //execution.setVariable("requestDetails", xmlRequestDetails) + + //modelInfo + String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") + if (isBlank(serviceModelInfo)) { + msg = "Input serviceModelInfo is null" + msoLogger.debug(msg) + } else + { + execution.setVariable("serviceModelInfo", serviceModelInfo) + //msoLogger.debug("modelInfo" + serviceModelInfo) + } + + //requestInfo + String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") + if (isBlank(productFamilyId)) + { + msg = "Input productFamilyId is null" + msoLogger.debug(msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("productFamilyId", productFamilyId) + } + String source = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source") + execution.setVariable("source", source) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + msoLogger.debug(msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + msoLogger.debug(msg) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } 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.toString()) + } + } + + msoLogger.debug("User Input Parameters map: " + userParams.toString()) + execution.setVariable("serviceInputParams", inputMap) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest") + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Start sendSyncResponse") + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // RESTResponse (for API Handler (APIH) Reply Task) + String syncResponse = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + msoLogger.debug(" sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse: " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.trace("Exit sendSyncResopnse") + } + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Start sendSyncError") + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + MsoLogger.info(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + msoLogger.debug(" Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + + } + + public void prepareCompletionRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Start prepareCompletion") + + try { + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + + Service Instance was deleted successfully. + DeleteGenericALaCarteServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit prepareCompletionRequest") + } + + public void prepareFalloutRequest(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("Start prepareFalloutRequest") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug(" Input Workflow Exception: " + wfex.toString()) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.debug("Exception prepareFalloutRequest:" + ex.getMessage()) + String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + VID + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + msoLogger.trace("Exit prepareFalloutRequest ") + } + + + // ******************************* + // Build DB request Section + // ******************************* + public void prepareDBRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + msoLogger.trace("Inside prepareDBRequest of DeleteGenericALaCarteServiceInstance ") + + String requestId = execution.getVariable("DELSI_requestId") + String statusMessage = "Service Instance successfully deleted." + + //TODO - verify the format for Service Instance Delete, + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + COMPLETED + 100 + + + """ + + String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString) + msoLogger.info(buildDeleteDBRequestAsString) + + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ******************************* + // Build Error Section + // ******************************* + public void prepareDBRequestError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareDBRequestError of DeleteGenericALaCarteServiceInstance ") + + try { + String requestId = execution.getVariable("DELSI_requestId") + String statusMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + statusMessage = wfe.getErrorMessage() + + } else { + statusMessage = "Encountered Error during DeleteGenericALaCarteServiceInstance proccessing. " + } + + //TODO - verify the format for Service Instance Create, + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + FAILED + + + """ + + String buildDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString) + msoLogger.info(buildDBRequestAsString) + + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage() + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy new file mode 100644 index 0000000000..816ba859ee --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy @@ -0,0 +1,420 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.* + +public class DeleteNetworkInstance extends AbstractServiceTaskProcessor { + String Prefix="DELNI_" + String groovyClassName = "DeleteNetworkInstance" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteNetworkInstance.class); + + + public InitializeProcessVariables(DelegateExecution execution){ + + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "CompleteMsoProcessRequest", "") + execution.setVariable(Prefix + "FalloutHandlerRequest", "") + execution.setVariable(Prefix + "isSilentSuccess", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest() of " + groovyClassName + "") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null || sdncVersion == '1610') { + // 'a-la-cart' default, sdncVersion = '1610' + execution.setVariable("sdncVersion", "1610") + String bpmnRequest = execution.getVariable("bpmnRequest") + // set 'disableRollback' + if (bpmnRequest != null) { + String disableRollback = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.requestInfo.suppressRollback") + if (disableRollback != null) { + execution.setVariable("disableRollback", disableRollback) + msoLogger.debug("Received 'suppressRollback': " + disableRollback ) + } else { + execution.setVariable("disableRollback", false) + } + msoLogger.debug(" Set 'disableRollback' : " + execution.getVariable("disableRollback") ) + } else { + String dataErrorMessage = " Invalid 'bpmnRequest' request." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } else { + // 'macro' test ONLY, sdncVersion = '1702' + msoLogger.debug(" 'disableRollback' : " + execution.getVariable("disableRollback") ) + } + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + + // get/set 'requestId' + if (execution.getVariable("requestId") == null) { + execution.setVariable("requestId", requestId) + } + + // set action to "DELETE" + execution.setVariable("action", "DELETE") + + //Place holder for additional code. + + // TODO ??? + // userParams??? 1) pre-loads indicator, 2) 'auto-activation' + // Tag/Value parameters + // + // Map: 'networkInputParams': 'auto-activation'' + // Sample format? + // "requestParameters": { + // "userParams": [ + // { + // "name": "someUserParam1", + // "value": "someValue1" + // } + // ] + // } + // + // String userParams = //use json util to extract "userParams"// + // execution.setVariable("networkInputParams", userParams) + // else: execution.setVariable("networkInputParams", null) + // + + + } catch (Exception ex){ + sendSyncError(execution) + String exceptionMessage = "Exception Encountered in " + groovyClassName + ", PreProcessRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void getNetworkModelInfo (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside getNetworkModelInfo() of DeleteNetworkInstance") + + try { + + // 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 DeleteNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside sendSyncResponse() of DeleteNetworkInstance") + + try { + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // RESTResponse (for API Handler (APIH) Reply Task) + String deleteNetworkRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug(" sendSyncResponse to APIH - " + "\n" + deleteNetworkRestRequest) + + sendWorkflowResponse(execution, 202, deleteNetworkRestRequest) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Exception Encountered in DeleteNetworkInstance, sendSyncResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareCompletion (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareCompletion() of CreateNetworkInstance") + + try { + + String requestId = execution.getVariable("mso-request-id") + String source = execution.getVariable(Prefix + "source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + VID + + Network has been deleted successfully. + BPMN Network action: DELETE + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + // normal path + execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + public void prepareDBRequestError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + msoLogger.trace("Inside prepareDBRequestError of DeleteNetworkInstance") + + // set DB Header Authorization + setBasicDBAuthHeader(execution, isDebugEnabled) + + WorkflowException wfe = execution.getVariable("WorkflowException") + String statusMessage = wfe.getErrorMessage() + String requestId = execution.getVariable(Prefix +"requestId") + + String dbRequest = + """ + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + + FAILED + + <network-outputs xmlns="http://org.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> + + + """ + + execution.setVariable(Prefix + "deleteDBRequest", dbRequest) + msoLogger.debug(" DB Adapter Request - " + "\n" + dbRequest) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, prepareDBRequestError() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void postProcessResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside postProcessResponse() of DeleteNetworkInstance") + + try { + if (execution.getVariable("CMSO_ResponseCode") == "200") { + execution.setVariable(Prefix + "Success", true) + msoLogger.trace("DeleteNetworkInstance Success") + // Place holder for additional code. + + } else { + execution.setVariable(Prefix + "Success", false) + msoLogger.trace("DeleteNetworkInstance Failed in CompletionMsoProces flow!.") + + } + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DeleteNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + // Prepare for FalloutHandler + public void buildErrorResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler.") + + String dbReturnCode = execution.getVariable(Prefix + "dbReturnCode") + msoLogger.debug("DB Update Response Code : " + dbReturnCode) + msoLogger.debug("DB Update Response String: " + '\n' + execution.getVariable(Prefix + "deleteDBResponse")) + + String falloutHandlerRequest = "" + String requestId = execution.getVariable("mso-request-id") + String source = execution.getVariable(Prefix + "source") + execution.setVariable(Prefix + "Success", false) + try { + WorkflowException wfe = execution.getVariable("WorkflowException") + String errorCode = String.valueOf(wfe.getErrorCode()) + String errorMessage = wfe.getErrorMessage() + + falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + + + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + + """ + + msoLogger.debug(falloutHandlerRequest) + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG,"Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest,"BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "") + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, buildErrorResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELEtE + ${MsoUtils.xmlEscape(source)} + + + ${MsoUtils.xmlEscape(exceptionMessage)} + 9999 + + """ + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG,"Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest,"BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex) + } + } + + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // RESTResponse (for API Handler (APIH) Reply Task) + String deleteNetworkRestError = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug(" sendSyncResponse to APIH - " + "\n" + deleteNetworkRestError) + + sendWorkflowResponse(execution, 500, deleteNetworkRestError) + + } catch (Exception ex) { + msoLogger.debug(" Sending Sync Error Activity Failed - DeleteNetworkInstance, sendSyncError(): " + "\n" + ex.getMessage()) + } + } + + public void processJavaException(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a Java Exception") + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") + } + msoLogger.debug("Completed processJavaException Method of " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy new file mode 100644 index 0000000000..ab5500602f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -0,0 +1,308 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.recipe.ResourceInput; +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.json.JsonUtils + +import groovy.json.* + +/** + * This groovy class supports the DeleteSDNCCNetworkResource.bpmn process. + * flow for SDNC Network Resource + */ +public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { + + String Prefix="DELSDNCRES_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + public void preProcessRequest(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled) + try { + + //get bpmn inputs from resource request. + String requestId = execution.getVariable("mso-request-id") + String requestAction = execution.getVariable("requestAction") + utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled) + String recipeParamsFromRequest = execution.getVariable("recipeParams") + utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled) + String resourceInput = execution.getVariable("resourceInput") + utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled) + //Get ResourceInput Object + ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) + execution.setVariable(Prefix + "resourceInput", resourceInputObj) + + //Deal with recipeParams + String recipeParamsFromWf = execution.getVariable("recipeParamXsd") + String resourceModelName = resourceInputObj.getResourceModelInfo().getModelName() + //For sdnc requestAction default is "NetworkInstance" + String operationType = "Network" + if(!StringUtils.isBlank(recipeParamsFromRequest) && "null" != recipeParamsFromRequest){ + //the operationType from worflow(first node) is second priority. + operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType") + } + if(!StringUtils.isBlank(recipeParamsFromWf)){ + //the operationType from worflow(first node) is highest priority. + operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") + } + + + //For sdnc, generate svc_action and request_action + String sdnc_svcAction = "delete" + if(StringUtils.containsIgnoreCase(resourceModelName, "overlay")){ + //This will be resolved in R3. + sdnc_svcAction ="deactivate" + operationType = "NCINetwork" + } + if(StringUtils.containsIgnoreCase(resourceModelName, "underlay")){ + //This will be resolved in R3. + operationType ="Network" + } + String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" + execution.setVariable(Prefix + "svcAction", sdnc_svcAction) + execution.setVariable(Prefix + "requestAction", sdnc_requestAction) + execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) + execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) + //TODO Here build networkrequest + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + public void prepareSDNCRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled) + + try { + // get variables + String sdnc_svcAction = execution.getVariable(Prefix + "svcAction") + String sdnc_requestAction = execution.getVariable(Prefix + "requestAction") + String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String hdrRequestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + String source = execution.getVariable("source") + String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId") + ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") + String serviceType = resourceInputObj.getServiceType() + String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid() + String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid() + String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion() + String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName() + String globalCustomerId = resourceInputObj.getGlobalSubscriberId() + String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid(); + String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() + String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid() + String modelName = resourceInputObj.getResourceModelInfo().getModelName() + String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion() + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyDeleteRequest = + """ + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(sdnc_svcAction)} + network-topology-operation + sdncCallback + generic-resource + + + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(sdnc_requestAction)} + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceType)} + + ${MsoUtils.xmlEscape(serviceModelInvariantUuid)} + ${MsoUtils.xmlEscape(serviceModelUuid)} + ${MsoUtils.xmlEscape(serviceModelVersion)} + ${MsoUtils.xmlEscape(serviceModelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(globalCustomerId)} + + + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + + + + """.trim() + + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) + utils.logAudit(sndcTopologyDeleteRequesAsString) + execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyDeleteRequesAsString) + utils.log("INFO","sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DeleteSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled) + } + + private void setProgressUpdateVariables(DelegateExecution execution, String body) { + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + execution.setVariable("CVFMI_updateResOperStatusRequest", body) + } + + public void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) { + ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") + String operType = resourceInputObj.getOperationType() + String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() + String serviceInstanceId = resourceInputObj.getServiceInstanceId() + String operationId = resourceInputObj.getOperationId() + String progress = "20" + String status = "processing" + String statusDescription = "SDCN resource delete invoked" + + //String operationId = execution.getVariable("operationId") + + String body = """ + + + + + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(resourceCustomizationUuid)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(statusDescription)} + + + """; + + setProgressUpdateVariables(execution, body) + + } + + public void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) { + ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") + String operType = resourceInputObj.getOperationType() + String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() + String serviceInstanceId = resourceInputObj.getServiceInstanceId() + String operationId = resourceInputObj.getOperationId() + String progress = "100" + String status = "finished" + String statusDescription = "SDCN resource delete completed" + + //String operationId = execution.getVariable("operationId") + + String body = """ + + + + + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(resourceCustomizationUuid)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(statusDescription)} + + + """; + + setProgressUpdateVariables(execution, body) + } + + public void postDeleteSDNCCall(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled) + String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") + String responseObj = execution.getVariable(Prefix + "SuccessIndicator") + + utils.log("INFO","response from sdnc, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled) + utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled) + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) + + try { + String operationStatus = "finished" + // RESTResponse for main flow + String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() + utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled) + sendWorkflowResponse(execution, 202, resourceOperationResp) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy new file mode 100644 index 0000000000..536783bc33 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy @@ -0,0 +1,87 @@ + +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil + + +public class DeleteVFCNSResource extends AbstractServiceTaskProcessor { + + String Prefix = "DCUSE_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** start preProcessRequest *****", isDebugEnabled) + + String resourceInputStr = execution.getVariable("resourceInput") + ResourceInput resourceInput = new ObjectMapper().readValue(resourceInputStr, ResourceInput.class) + + String globalSubscriberId = resourceInput.getGlobalSubscriberId() + String serviceType = execution.getVariable("serviceType") + String operationId = resourceInput.getOperationId() + String resourceModeluuid = resourceInput.getResourceModelInfo().getModelCustomizationUuid() + String resourceInstanceId = resourceInput.getResourceInstancenUuid() + + + execution.setVariable("globalSubscriberId",globalSubscriberId) + execution.setVariable("serviceType", serviceType) + execution.setVariable("operationId", operationId) + execution.setVariable("resourceTemplateId", resourceModeluuid) + execution.setVariable("resourceInstanceId", resourceInstanceId) + + utils.log("INFO"," ***** end preProcessRequest *****", isDebugEnabled) + } + + public void postProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** start postProcessRequest *****", isDebugEnabled) + + utils.log("INFO"," ***** end postProcessRequest *****", isDebugEnabled) + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) + + try { + String nsInstanceId = execution.getVariable("nsInstanceId") + String operationStatus = execution.getVariable("operationStatus") + // RESTResponse for main flow + String createVFCResourceRestRsp = """{"nsInstanceId":"${nsInstanceId}","operationStatus":"${operationStatus}"}""".trim() + utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createVFCResourceRestRsp, isDebugEnabled) + sendWorkflowResponse(execution, 202, createVFCResourceRestRsp) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy new file mode 100644 index 0000000000..682421e806 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy @@ -0,0 +1,367 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils; +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonSlurper + + + +public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteVfModuleInfra.class); + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'DELVfModI_') + execution.setVariable('DELVfModI_requestInfo', null) + execution.setVariable('DELVfModI_requestId', null) + execution.setVariable('DELVfModI_source', null) + execution.setVariable('DELVfModI_vnfInputs', null) + execution.setVariable('DELVfModI_vnfId', null) + execution.setVariable('DELVfModI_vfModuleId', null) + execution.setVariable('DELVfModI_tenantId', null) + execution.setVariable('DELVfModI_volumeGroupId', null) + execution.setVariable('DELVfModI_vnfParams', null) + execution.setVariable('DELVfModI_updateInfraRequest', null) + execution.setVariable('DeleteVfModuleRequest', null) + execution.setVariable('DeleteVfModuleSuccessIndicator', false) + } + + /** + * Process the incoming DELETE_VF_MODULE vnf-request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + execution.setVariable("isVidRequest", "false") + initProcessVariables(execution) + + def prefix = execution.getVariable('prefix') + + def incomingRequest = execution.getVariable('bpmnRequest') + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + + // check if request is xml or json + try { + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + msoLogger.debug("serviceInstanceId is: " + serviceInstanceId) + def vnfId = execution.getVariable('vnfId') + msoLogger.debug("vnfId is: " + vnfId) + def cloudConfiguration = jsonUtil.getJsonValue(incomingRequest, "requestDetails.cloudConfiguration") + execution.setVariable("cloudConfiguration", cloudConfiguration) + msoLogger.debug("CloudConfiguration is: " + cloudConfiguration) + def vfModuleModelInfo = jsonUtil.getJsonValue(incomingRequest, "requestDetails.modelInfo") + + execution.setVariable("vfModuleModelInfo", vfModuleModelInfo) + msoLogger.debug("VfModuleModelInfo is: " + vfModuleModelInfo) + + // This is aLaCarte flow, so aLaCarte flag is always on + execution.setVariable('aLaCarte', true) + + def vidUtils = new VidUtils(this) + + String requestInXmlFormat = vidUtils.createXmlVfModuleRequest(execution, reqMap, 'DELETE_VF_MODULE', serviceInstanceId) + + msoLogger.debug(" Request in XML format: " + requestInXmlFormat) + + setBasicDBAuthHeader(execution, isDebugLogEnabled) + + execution.setVariable(prefix + 'Request', requestInXmlFormat) + execution.setVariable(prefix+'vnfId', vnfId) + execution.setVariable("isVidRequest", "true") + + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG,"Caught exception", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") + } + + + try { + + String request = validateRequest(execution) + execution.setVariable('DeleteVfModuleRequest', request) + msoLogger.debug("DeleteVfModuleInfra Request: " + request) + + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') + execution.setVariable('DELVfModI_requestInfo', requestInfo) + execution.setVariable('DELVfModI_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) + execution.setVariable('DELVfModI_source', getNodeTextForce(requestInfo, 'source')) + + def vnfInputs = getRequiredNodeXml(execution, request, 'vnf-inputs') + execution.setVariable('DELVfModI_vnfInputs', vnfInputs) + execution.setVariable('DELVfModI_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) + execution.setVariable('DELVfModI_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) + execution.setVariable('DELVfModI_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name')) + execution.setVariable('DELVfModI_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) + execution.setVariable('DELVfModI_volumeGroupId', getNodeTextForce(vnfInputs, 'volume-group-id')) + + def vnfParams = utils.getNodeXml(request, 'vnf-params') + execution.setVariable('DELVfModI_vnfParams', vnfParams) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG,"Caught exception in "+method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Sends the 'IN_PROGRESS' synchronous response. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendResponse(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = execution.getVariable('DELVfModI_requestInfo') + def requestId = execution.getVariable('DELVfModI_requestId') + def source = execution.getVariable('DELVfModI_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('DELVfModI_vfModuleId') + String synchResponse = """{"requestReferences":{"instanceId":"${vfModuleId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug("DeleteVfModuleInfra Synch Response: " + synchResponse) + sendWorkflowResponse(execution, 200, synchResponse) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG,"Caught exception in "+method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + /** + * Currently passing the entire DELETE_VF_MODULE vnf-request to DoDeleteVfModule. + * 'DeleteVfModuleRequest' is now being set in preProcessRequest(). + * TBD: may want to eventually create a specific request that only contains the needed fields. + * + * @param execution The flow's execution instance. + */ + public void prepDoDeleteVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoDeleteVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoDeleteVfModule(): ' + e.getMessage()) + } + } + + /** + * Prepare the DB update to add an entry for the Vf Module request. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateInfraRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateInfraRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + def requestId = execution.getVariable('DELVfModI_requestId') + def vnfId = execution.getVariable('DELVfModI_vnfId') + def vfModuleId = execution.getVariable('DELVfModI_vfModuleId') + def tenantId = execution.getVariable('DELVfModI_tenantId') + def volumeGroupId = execution.getVariable('DELVfModI_volumeGroupId') + + String updateInfraRequest = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + COMPLETED + 100 + + + + """ + + updateInfraRequest = utils.formatXml(updateInfraRequest) + execution.setVariable('DELVfModI_updateInfraRequest', updateInfraRequest) + msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepInfraRequest(): ' + 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + def request = execution.getVariable("DeleteVfModuleRequest") + def requestInfo = utils.getNodeXml(request, 'request-info', false) + def action = utils.getNodeText(requestInfo, "action") + + String content = + """ + + ${requestInfo} + + Vf Module has been deleted successfully. + BPMN + """ + + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + def prefix = execution.getVariable('prefix') + def request = execution.getVariable("DeleteVfModuleRequest") + def requestInfo = utils.getNodeXml(request, 'request-info', false) + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInfo} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy new file mode 100644 index 0000000000..2cbfeac239 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -0,0 +1,545 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils; +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +import groovy.json.JsonSlurper + +/** + * This groovy class supports the DeleteVfModuleVolume.bpmn process. + */ +public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteVfModuleVolumeInfraV1.class); + + private XmlParser xmlParser = new XmlParser() + /** + * This method is executed during the preProcessRequest task of the DeleteVfModuleVolume.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + execution.setVariable('prefix', 'DELVfModVol_') + execution.setVariable("DELVfModVol_volumeRequest", null) + execution.setVariable('DELVfModVol_requestInfo', null) + execution.setVariable('DELVfModVol_requestId', null) + execution.setVariable('DELVfModVol_source', null) + execution.setVariable('DELVfModVol_volumeInputs', null) + execution.setVariable('DELVfModVol_volumeOutputs', null) + execution.setVariable('DELVfModVol_volumeGroupId', null) + execution.setVariable('DELVfModVol_vnfType', null) + execution.setVariable('DELVfModVol_serviceId', null) + execution.setVariable('DELVfModVol_cloudRegion', null) + execution.setVariable('DELVfModVol_tenantId', null) + execution.setVariable('DELVfModVol_volumeParams', null) + execution.setVariable('DELVfModVol_volumeGroupHeatStackId', null) + execution.setVariable('DELVfModVol_volumeGroupTenantId', null) + execution.setVariable("DELVfModVol_queryAAIVolGrpResponse", null) + execution.setVariable('DELVfModVol_messageId', null) + execution.setVariable('DELVfModVol_deleteVnfARequest', null) + execution.setVariable('DELVfModVol_updateInfraRequest', null) + execution.setVariable('DELVfModVol_CompleteMsoProcessRequest', null) + execution.setVariable('DELVfModVol_WorkflowException', null) + execution.setVariable('DELVfModVol_TransactionSuccessIndicator', false) + execution.setVariable("DELVfModVol_isErrorMessageException", false) + execution.setVariable('DELVfModVol_syncResponseSent', false) + } + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + /** + * This method is executed during the preProcessRequest task of the DeleteVfModuleVolume.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution, isDebugLogEnabled) { + + InitializeProcessVariables(execution) + + String createVolumeIncoming = validateRequest(execution) + + // check if request is xml or json + try { + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(createVolumeIncoming) + msoLogger.debug(" Request is in JSON format.") + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def volumeGroupId = execution.getVariable('volumeGroupId') + def vidUtils = new VidUtils(this) + createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'DELETE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId) + execution.setVariable("DELVfModVol_isVidRequest", true) + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is in XML format.") + // assume request is in XML format - proceed as usual to process XML request + } + + String request = utils.getNodeXml(createVolumeIncoming, "volume-request").drop(38).trim().replace("tag0:","").replace(":tag0","") + execution.setVariable("DELVfModVol_volumeRequest", request) + + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') + execution.setVariable('DELVfModVol_requestInfo', requestInfo) + String requestId = execution.getVariable("mso-request-id") + if (requestId == null || requestId == "") { + requestId = getRequiredNodeText(execution, requestInfo, 'request-id') + } + execution.setVariable('DELVfModVol_requestId', requestId) + execution.setVariable('DELVfModVol_source', getNodeTextForce(requestInfo, 'source')) + + def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs') + execution.setVariable('DELVfModVol_volumeInputs', volumeInputs) + execution.setVariable('DELVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id')) + execution.setVariable('DELVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type')) + execution.setVariable('DELVfModVol_serviceId', utils.getNodeText(volumeInputs, 'service-id')) + execution.setVariable('DELVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) + execution.setVariable('DELVfModVol_messageId', UUID.randomUUID().toString()) + execution.setVariable('DELVfModVol_volumeOutputs', utils.getNodeXml(request, 'volume-outputs', false)) + execution.setVariable('DELVfModVol_volumeParams', utils.getNodeXml(request, 'volume-params')) + execution.setVariable('DELVfModVol_cloudRegion', utils.getNodeText(request, 'aic-cloud-region')) + + setBasicDBAuthHeader(execution, isDebugLogEnabled) + + msoLogger.debug('Request: ' + createVolumeIncoming) + } + + public void sendSyncResponse (DelegateExecution execution, isDebugEnabled) { + + String volumeRequest = execution.getVariable("DELVfModVol_volumeRequest") + msoLogger.debug(" DELVfModVol_volumeRequest - " + "\n" + volumeRequest) + // RESTResponse (for API Handler (APIH) Reply Task) + String deleteVolumeRequest = + """ + + ${volumeRequest} + + """.trim() + + def isVidRequest = execution.getVariable('DELVfModVol_isVidRequest') + def syncResponse = '' + + if(isVidRequest) { + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def volumeGroupId = execution.getVariable('volumeGroupId') + def requestId = execution.getVariable('DELVfModVol_requestId') + syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() + } + else { + syncResponse = utils.formatXml(deleteVolumeRequest) + } + + execution.setVariable('DELVfModVol_syncResponseSent', true) + + sendWorkflowResponse(execution, 200, syncResponse) + } + + + public void sendSyncError (DelegateExecution execution, isDebugEnabled) { + WorkflowException we = execution.getVariable('WorkflowException') + def errorCode = we?.getErrorCode() + def errorMessage = we?.getErrorMessage() + //default to 400 since only invalid request will trigger this method + sendWorkflowResponse(execution, 400, errorMessage) + } + + + public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) { + + String cloudRegion = execution.getVariable('DELVfModVol_cloudRegion') + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + execution.setVariable("DELVfModVol_queryCloudRegionRequest", queryCloudRegionRequest) + msoLogger.debug(" DELVfModVol_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) + + cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if ((cloudRegion != "ERROR")) { + if(execution.getVariable("DELVfModVol_queryCloudRegionReturnCode") == "404"){ + execution.setVariable("DELVfModVol_aicCloudRegion", "AAIAIC25") + }else{ + execution.setVariable("DELVfModVol_aicCloudRegion", cloudRegion) + } + execution.setVariable("DELVfModVol_cloudRegion", cloudRegion) + execution.setVariable("DELVfModVol_isCloudRegionGood", true) + + } else { + msoLogger.debug("AAI Query Cloud Region Unsuccessful.") + execution.setVariable("DELVfModVol_isCloudRegionGood", false) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable("DELVfModVol_queryCloudRegionReturnCode")) + } + + msoLogger.debug(" is Cloud Region Good: " + execution.getVariable("DELVfModVol_isCloudRegionGood")) + } + + /** + * Query volume group by id + * @param execution + */ + public void queryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId') + if(volumeGroupId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'volume-group-id is not provided in the request') + throw new Exception('volume-group-id is not provided in the request') + } + String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query volume group by id return code: " + returnCode) + msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString) + + execution.setVariable("DELVfModVol_queryAAIVolGrpResponse", aaiResponseAsString) + + if (returnCode=='200' || returnCode == '204') { + + def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id') + execution.setVariable('DELVfModVol_volumeGroupHeatStackId', heatStackId) + + if(hasVfModuleRelationship(aaiResponseAsString)){ + msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use') + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") + } + + def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) + if (volumeGroupTenantId == null) { + msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") + } + + execution.setVariable('DELVfModVol_volumeGroupTenantId', volumeGroupTenantId) + msoLogger.debug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId ) + } + else { + if (returnCode=='404') { + msoLogger.debug("Volume Group ${volumeGroupId} not found in AAI") + 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") + } + } + } + + /** + * 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 + } + + private boolean hasVnfRelationship(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('generic-vnf'))) { + def Node relatedLink = utils.getChildNode(relationship, 'related-link') + if (relatedLink !=null && relatedLink.text() != null){ + return true + } + } + } + } + return false + } + + 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 + } + + public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) { + def cloudRegion = execution.getVariable('DELVfModVol_cloudRegion') + def tenantId = execution.getVariable('DELVfModVol_tenantId') + def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId') + def volumeGroupHeatStackId = execution.getVariable('DELVfModVol_volumeGroupHeatStackId') + def requestId = execution.getVariable('DELVfModVol_requestId') + def serviceId = execution.getVariable('DELVfModVol_serviceId') + + def messageId = execution.getVariable('DELVfModVol_messageId') + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host", execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String vnfAdapterRestRequest = """ + + ${MsoUtils.xmlEscape(cloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupHeatStackId)} + true + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable('DELVfModVol_deleteVnfARequest', vnfAdapterRestRequest) + msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) + } + + + public void deleteVolGrpId(DelegateExecution execution, isDebugEnabled) { + + // get variables + String queryAAIVolGrpIdResponse = execution.getVariable("DELVfModVol_queryAAIVolGrpResponse") + String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id") + String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version") + String messageId = execution.getVariable('DELVfModVol_messageId') + String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") + + if(resourceVersion !=null){ + deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8') + } + + msoLogger.debug("Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest) + + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI delete volume group return code: " + returnCode) + msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + if (returnCode=='200' || (returnCode == '204')) { + msoLogger.debug("Volume group $groupId deleted.") + } 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") + } + } + } + + + public void prepareDBRequest (DelegateExecution 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" + def progress = "100" + def requestStatus = "COMPLETE" + + if (workflowExceptionObj != null) { + statusMessage = (workflowExceptionObj.getErrorMessage()) + execution.setVariable("DELVfModVol_WorkflowExceptionMessage", statusMessage) + execution.setVariable("DELVfModVol_WorkflowExceptionCode", workflowExceptionObj.getErrorCode()) + requestStatus = "FAILURE" + progress = "" + } + + String updateInfraRequest = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPMN + ${MsoUtils.xmlEscape(statusMessage)} + ${MsoUtils.xmlEscape(requestStatus)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(volOutputs)} + + + + """ + + updateInfraRequest = utils.formatXml(updateInfraRequest) + execution.setVariable('DELVfModVol_updateInfraRequest', updateInfraRequest) + msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) + + } + + + public void prepareCompletionHandlerRequest (DelegateExecution execution, isDebugLogEnabled) { + def requestId = execution.getVariable("mso-request-id") + def source = execution.getVariable("DELVfModVol_source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + + Volume Group has been deleted successfully. + BPMN VF Module Volume action: DELETE + """ + + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + execution.setVariable('DELVfModVol_CompleteMsoProcessRequest', xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } + + + + public void prepareFalloutHandler (DelegateExecution execution, isDebugEnabled) { + + execution.setVariable("DELVfModVol_Success", false) + String requestId = execution.getVariable("DELVfModVol_requestId") + String source = execution.getVariable("DELVfModVol_source") + + WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException") + def errorMessage = workflowExceptionObj.getErrorMessage() + def errorCode = workflowExceptionObj.getErrorCode() + + String falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + + + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + + """ + + // Format Response + String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest) + msoLogger.debug(xmlHandlerRequest) + + execution.setVariable("DELVfModVol_FalloutHandlerRequest", xmlHandlerRequest) + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Overall Error Response going to FalloutHandler", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "\n" + xmlHandlerRequest); + + } + + + /** + * Create a WorkflowException for the error case where the Tenant Id from + * AAI did not match the Tenant Id in the incoming request. + * + * @param execution The flow's execution instance. + */ + public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) { + + def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId') + def aicCloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') + def tenantId = execution.getVariable('DELVfModVol_tenantId') + def volumeGroupTenantId = execution.getVariable('DELVfModVol_volumeGroupTenantId') + + def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + + ' retrieved from AAI for Volume Group Id ' + volumeGroupId + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error in DeleteVfModuleVolume: " + "\n" + errorMessage, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildWorkflowException(execution, 5000, errorMessage) + + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy new file mode 100644 index 0000000000..9dfb9107b2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils; +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.logger.MsoLogger + + +/** + * This class supports the DeleteVnfInfra Flow + * with the Deletion of a generic vnf for + * infrastructure. + */ +class DeleteVnfInfra extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteVnfInfra.class); + + String Prefix="DELVI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + */ + public void preProcessRequest(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DeleteVnfInfra PreProcessRequest Process") + + execution.setVariable("DELVI_SuccessIndicator", false) + execution.setVariable("DELVI_vnfInUse", false) + + try{ + // Get Variables + String deleteVnfRequest = execution.getVariable("bpmnRequest") + execution.setVariable("DELVI_DeleteVnfRequest", deleteVnfRequest) + msoLogger.debug("Incoming DeleteVnfInfra Request is: \n" + deleteVnfRequest) + + if(deleteVnfRequest != null){ + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("DELVI_requestId", requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DELVI_serviceInstanceId", serviceInstanceId) + msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + + String vnfId = execution.getVariable("vnfId") + execution.setVariable("DELVI_vnfId", vnfId) + msoLogger.debug("Incoming Vnf(Instance) Id is: " + vnfId) + + String source = jsonUtil.getJsonValue(deleteVnfRequest, "requestDetails.requestInfo.source") + execution.setVariable("DELVI_source", source) + msoLogger.debug("Incoming Source is: " + source) + + def cloudConfiguration = jsonUtil.getJsonValue(deleteVnfRequest, "requestDetails.cloudConfiguration") + execution.setVariable("DELVI_cloudConfiguration", cloudConfiguration) + + boolean cascadeDelete = false + Boolean cascadeDeleteObj = jsonUtil.getJsonRawValue(deleteVnfRequest, "requestDetails.requestParameters.cascadeDelete") + if(cascadeDeleteObj!=null){ + cascadeDelete = cascadeDeleteObj.booleanValue() + } + execution.setVariable("DELVI_cascadeDelete", cascadeDelete) + msoLogger.debug("Incoming cascadeDelete is: " + cascadeDelete) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("DELVI_requestInfo", requestInfo) + + // Setting for sub flow calls + execution.setVariable("DELVI_type", "generic-vnf") + + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Bpmn Request is Null.") + } + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DeleteVnfInfra PreProcessRequest method!" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra PreProcessRequest") + + } + msoLogger.trace("COMPLETED DeleteVnfInfra PreProcessRequest Process") + } + + public void sendSyncResponse (DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED DeleteVnfInfra SendSyncResponse Process") + + try { + String requestId = execution.getVariable("DELVI_requestId") + String vnfId = execution.getVariable("DELVI_vnfId") + + String DeleteVnfResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug("DeleteVnfInfra Sync Response is: \n" + DeleteVnfResponse) + execution.setVariable("DELVI_sentSyncResponse", true) + + sendWorkflowResponse(execution, 202, DeleteVnfResponse) + + } catch (Exception ex) { + msoLogger.debug("Error Occured in DeleteVnfInfra SendSyncResponse Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra SendSyncResponse Process") + + } + msoLogger.trace("COMPLETED DeleteVnfInfra SendSyncResponse Process") + } + + public void prepareCompletionHandlerRequest(DelegateExecution execution){ + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED DeleteVnfInfra PrepareCompletionHandlerRequest Process") + + try { + String requestInfo = execution.getVariable("DELVI_requestInfo") + requestInfo = utils.removeXmlPreamble(requestInfo) + String vnfId = execution.getVariable("DELVI_vnfId") + + String request = + """ + ${requestInfo} + Vnf has been deleted successfully. + ${MsoUtils.xmlEscape(vnfId)} + DeleteVnfInfra + """ + + execution.setVariable("DELVI_completionHandlerRequest", request) + msoLogger.debug("Completion Handler Request is: " + request) + + execution.setVariable("WorkflowResponse", "Success") // for junits + + } catch (Exception ex) { + msoLogger.debug("Error Occured in DeleteVnfInfra PrepareCompletionHandlerRequest Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra PrepareCompletionHandlerRequest Process") + + } + msoLogger.trace("COMPLETED DeleteVnfInfra PrepareCompletionHandlerRequest Process") + } + + public void sendErrorResponse(DelegateExecution execution){ + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED DeleteVnfInfra sendErrorResponse Process") + try { + def sentSyncResponse = execution.getVariable("DELVI_sentSyncResponse") + if(sentSyncResponse == false){ + msoLogger.debug("Sending a Sync Error Response") + WorkflowException wfex = execution.getVariable("WorkflowException") + String response = exceptionUtil.buildErrorResponseXml(wfex) + + msoLogger.debug(response) + sendWorkflowResponse(execution, 500, response) + }else{ + msoLogger.debug("A Sync Response has already been sent. Skipping Send Sync Error Response.") + } + + } catch(Exception ex) { + msoLogger.debug("Error Occured in DeleteVnfInfra sendErrorResponse Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra sendErrorResponse Process") + } + msoLogger.trace("COMPLETED DeleteVnfInfra sendErrorResponse Process") + } + + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy new file mode 100644 index 0000000000..98605fea8b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy @@ -0,0 +1,258 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInstance +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.AllottedResource +import org.onap.so.bpmn.core.domain.NetworkResource +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.recipe.BpmnRestClient +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtils; +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import java.util.List; +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution +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; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + + + +/** + * This groovy class supports the DoCompareModelVersions.bpmn process. + * + * Inputs: + * @param - model-invariant-id-target + * @param - model-version-id-target + * @param - model-invariant-id-original + * @param - model-version-id-original + * + * Outputs: + * @param - addResourceList + * @param - delResourceList + * + */ +public class DoCompareModelVersions extends AbstractServiceTaskProcessor { + + String Prefix="DCMPMDV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) + + try { + execution.setVariable("prefix", Prefix) + + //Inputs + String modelInvariantUuid_target = execution.getVariable("model-invariant-id-target") + if (isBlank(modelInvariantUuid_target)) { + msg = "Input model-invariant-id-target is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String modelUuid_target = execution.getVariable("model-version-id-target") + if (isBlank(modelUuid_target)) { + msg = "Input model-version-id-target is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String modelInvariantUuid_original = execution.getVariable("model-invariant-id-original") + if (isBlank(modelInvariantUuid_original)) { + msg = "Input model-invariant-id-original is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String modelUuid_original = execution.getVariable("model-version-id-original") + if (isBlank(modelUuid_original)) { + msg = "Input model-version-id-original is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + // Target and original modelInvariantUuid must to be the same + if(modelInvariantUuid_target != modelInvariantUuid_original){ + msg = "Input model-invariant-id-target and model-invariant-id-original must to be the same" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + // Target and original modelUuid must not to be the same + if(modelUuid_target == modelUuid_original){ + msg = "Input model-version-id-target and model-version-id-original must not to be the same" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + public void prepareDecomposeService_Target(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled) + String modelInvariantUuid = execution.getVariable("model-invariant-id-target") + String modelUuid = execution.getVariable("model-version-id-target") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + + execution.setVariable("serviceModelInfo_Target", serviceModelInfo) + + utils.log("DEBUG", " ***** Completed prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Target() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition_Target(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside processDecomposition_Target() of update generic e2e service flow ***** ", isDebugEnabled) + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecomposition_Target", serviceDecomposition) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method processDecomposition_Target() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareDecomposeService_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled) + String modelInvariantUuid = execution.getVariable("model-invariant-id-original") + String modelUuid = execution.getVariable("model-version-id-original") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + + execution.setVariable("serviceModelInfo_Original", serviceModelInfo) + + utils.log("DEBUG", " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Original() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition_Original(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ", isDebugEnabled) + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecomposition_Original", serviceDecomposition) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. processDecomposition_Original() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void doCompareModelVersions(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start doCompareModelVersions Process ======== ", isDebugEnabled) + + ServiceDecomposition serviceDecomposition_Target = execution.getVariable("serviceDecomposition_Target") + ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original") + + List allSR_target = serviceDecomposition_Target.getServiceResources(); + List allSR_original = serviceDecomposition_Original.getServiceResources(); + + List addResourceList = new ArrayList() + List delResourceList = new ArrayList() + + addResourceList.addAll(allSR_target) + delResourceList.addAll(allSR_original) + + //Compare + for (Resource rc_t : allSR_target){ + String muuid = rc_t.getModelInfo().getModelUuid() + String mIuuid = rc_t.getModelInfo().getModelInvariantUuid() + String mCuuid = rc_t.getModelInfo().getModelCustomizationUuid() + for (Resource rc_o : allSR_original){ + if(rc_o.getModelInfo().getModelUuid() == muuid + && rc_o.getModelInfo().getModelInvariantUuid() == mIuuid + && rc_o.getModelInfo().getModelCustomizationUuid() == mCuuid) { + addResourceList.remove(rc_t); + delResourceList.remove(rc_o); + } + } + } + + execution.setVariable("addResourceList", addResourceList) + execution.setVariable("delResourceList", delResourceList) + utils.log("INFO", "addResourceList: " + addResourceList, isDebugEnabled) + utils.log("INFO", "delResourceList: " + delResourceList, isDebugEnabled) + + utils.log("INFO", "======== COMPLETED doCompareModelVersions Process ======== ", isDebugEnabled) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy new file mode 100644 index 0000000000..eceba5abe3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy @@ -0,0 +1,260 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInstance +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.CompareModelsResult +import org.onap.so.bpmn.core.domain.ResourceModelInfo +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + + +import java.util.List +import java.util.Map +import java.util.UUID; +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +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; + +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource +/** + * This groovy class supports the DoCompareModelofE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId + * @param - subscriptionServiceType + * @param - serviceInstanceId + * @param - modelInvariantIdTarget + * @param - modelVersionIdTarget + * + * Outputs: + * @param - compareModelsResult CompareModelsResult + + */ +public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DCMPMDSI_" + private static final String DebugFlag = "isDebugEnabled" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String msg = "" + utils.log("INFO"," ***** Enter DoCompareModelofE2EServiceInstance preProcessRequest *****", isDebugEnabled) + + execution.setVariable("prefix", Prefix) + //Inputs + + //subscriberInfo. for AAI GET + String globalSubscriberId = execution.getVariable("globalSubscriberId") + utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled) + + String serviceType = execution.getVariable("serviceType") + utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled) + + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (isBlank(serviceType)) { + msg = "Input serviceType is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String modelInvariantUuid = execution.getVariable("modelInvariantIdTarget") + if (isBlank(modelInvariantUuid)){ + msg = "Input modelInvariantUuid is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String modelUuid = execution.getVariable("modelVersionIdTarget") + if (isBlank(modelUuid)){ + msg = "Input modelUuid is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + // Set Target Template info + execution.setVariable("model-invariant-id-target", modelInvariantUuid) + execution.setVariable("model-version-id-target", modelUuid) + + + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessAAIGET(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) + String msg = "" + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + String serviceType = "" + + if(foundInAAI){ + utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) + + String siData = execution.getVariable("GENGS_service") + utils.log("INFO", "SI Data", isDebugEnabled) + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI, Id:" + serviceInstanceId + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + utils.log("INFO", "SI Data" + siData, isDebugEnabled) + + // Get Template uuid and version + if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { + utils.log("INFO", "SI Data model-invariant-id and model-version-id exist", isDebugEnabled) + + def modelInvariantId = utils.getNodeText(siData, "model-invariant-id") + def modelVersionId = utils.getNodeText(siData, "model-version-id") + + // Set Original Template info + execution.setVariable("model-invariant-id-original", modelInvariantId) + execution.setVariable("model-version-id-original", modelVersionId) + } + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET ") + } + + public void postCompareModelVersions(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + + List addResourceList = execution.getVariable("addResourceList") + List delResourceList = execution.getVariable("delResourceList") + + CompareModelsResult cmpResult = new CompareModelsResult() + List addedResourceList = new ArrayList() + List deletedResourceList = new ArrayList() + + + String serviceModelUuid = execution.getVariable("model-version-id-target") + List requestInputs = new ArrayList() + ModelInfo mi = null; + for(Resource rc : addResourceList) { + mi = rc.getModelInfo() + String resourceCustomizationUuid = mi.getModelCustomizationUuid() + ResourceModelInfo rmodel = new ResourceModelInfo() + rmodel.setResourceName(mi.getModelName()) + rmodel.setResourceInvariantUuid(mi.getModelInvariantUuid()) + rmodel.setResourceUuid(mi.getModelUuid()) + rmodel.setResourceCustomizationUuid(resourceCustomizationUuid) + addedResourceList.add(rmodel) + + Map resourceParameters = ResourceRequestBuilder.buildResouceRequest(serviceModelUuid, resourceCustomizationUuid, null) + requestInputs.addAll(resourceParameters.keySet()) + } + + for(Resource rc : delResourceList) { + mi = rc.getModelInfo() + String resourceCustomizationUuid = mi.getModelCustomizationUuid() + ResourceModelInfo rmodel = new ResourceModelInfo() + rmodel.setResourceName(mi.getModelName()) + rmodel.setResourceInvariantUuid(mi.getModelInvariantUuid()) + rmodel.setResourceUuid(mi.getModelUuid()) + rmodel.setResourceCustomizationUuid(resourceCustomizationUuid) + deletedResourceList.add(rmodel) + } + + cmpResult.setAddedResourceList(addedResourceList) + cmpResult.setDeletedResourceList(deletedResourceList) + cmpResult.setRequestInputs(requestInputs) + + execution.setVariable("compareModelsResult", cmpResult) + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy new file mode 100644 index 0000000000..bb48671e73 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -0,0 +1,451 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils; +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils; + +import groovy.json.* + + + +/** + * This groovy class supports the DoCreateServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId + * @param - subscriptionServiceType + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceModelInfo + * @param - productFamilyId + * @param - disableRollback + * @param - failExists - 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) + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * @param - WorkflowException + * @param - serviceInstanceName - (GET from AAI if null in input) + * + */ +public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateE2EServiceInstance.class); + + + String Prefix="DCRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() + + public void preProcessRequest (DelegateExecution execution) { + String msg = "" + msoLogger.trace("preProcessRequest ") + + try { + execution.setVariable("prefix", Prefix) + //Inputs + //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology + String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + msoLogger.info(" ***** globalSubscriberId *****" + globalSubscriberId) + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + msoLogger.info(" ***** serviceType *****" + serviceType) + //requestDetails.requestParameters. for SDNC assignTopology + String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId + + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (isBlank(serviceType)) { + msg = "Input serviceType is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (productFamilyId == null) { + execution.setVariable("productFamilyId", "") + } + + String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.info("SDNC Callback URL: " + sdncCallbackUrl) + + //requestDetails.modelInfo.for AAI PUT servieInstanceData + //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String uuiRequest = execution.getVariable("uuiRequest") + String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") + String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") + String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName") + execution.setVariable("serviceModelName", serviceModelName) + //aai serviceType and Role can be setted as fixed value now. + String aaiServiceType = "E2E Service" + String aaiServiceRole = "E2E Service" + + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + execution.setVariable("modelUuid", modelUuid) + + //AAI PUT + String oStatus = execution.getVariable("initialStatus") ?: "" + if ("TRANSPORT".equalsIgnoreCase(serviceType)) + { + oStatus = "Created" + } + + String statusLine = isBlank(oStatus) ? "" : "${MsoUtils.xmlEscape(oStatus)}" + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String serviceInstanceData = + """ + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${MsoUtils.xmlEscape(aaiServiceType)} + ${MsoUtils.xmlEscape(aaiServiceRole)} + ${statusLine} + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + """.trim() + execution.setVariable("serviceInstanceData", serviceInstanceData) + msoLogger.debug(serviceInstanceData) + msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace) + msoLogger.info(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void prepareDecomposeService(DelegateExecution execution) { + try { + msoLogger.trace("Inside prepareDecomposeService of create generic e2e service ") + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + msoLogger.trace("Completed prepareDecomposeService of create generic e2e service ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void processDecomposition(DelegateExecution execution) { + msoLogger.trace("Inside processDecomposition() of create generic e2e service flow ") + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void doServicePreOperation(DelegateExecution execution){ + //we need a service plugin platform here. + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String uuiRequest = execution.getVariable("uuiRequest") + String newUuiRequest = ServicePluginFactory.getInstance().preProcessService(serviceDecomposition, uuiRequest); + execution.setVariable("uuiRequest", newUuiRequest) + } + + public void doServiceHoming(DelegateExecution execution) { + //we need a service plugin platform here. + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String uuiRequest = execution.getVariable("uuiRequest") + String newUuiRequest = ServicePluginFactory.getInstance().doServiceHoming(serviceDecomposition, uuiRequest); + execution.setVariable("uuiRequest", newUuiRequest) + } + + public void postProcessAAIGET(DelegateExecution execution) { + msoLogger.trace("postProcessAAIGET ") + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error getting Service-instance from AAI", + serviceInstanceName) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + msoLogger.info("Found Service-instance in AAI") + msg = "ServiceInstance already exists in AAI:" + serviceInstanceName + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET ") + } + + public void postProcessAAIPUT(DelegateExecution execution) { + msoLogger.trace("postProcessAAIPUT ") + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + } + else + { + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIPUT ") + } + + public void postProcessAAIGET2(DelegateExecution execution) { + msoLogger.trace("postProcessAAIGET2 ") + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + String aaiService = execution.getVariable("GENGS_service") + if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) { + execution.setVariable("serviceInstanceName", utils.getNodeText(aaiService, "service-instance-name")) + msoLogger.info("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName")) + } + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET2 ") + } + + public void preProcessRollback (DelegateExecution execution) { + msoLogger.trace("preProcessRollback ") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.info("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.info("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.info(msg) + } + msoLogger.trace("Exit preProcessRollback ") + } + + public void postProcessRollback (DelegateExecution execution) { + msoLogger.trace("postProcessRollback ") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.info("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + msoLogger.info("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.info(msg) + } + msoLogger.trace("Exit postProcessRollback ") + } + + public void preInitResourcesOperStatus(DelegateExecution execution){ + msoLogger.trace("STARTED preInitResourcesOperStatus Process ") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + List resourceList = serviceDecomposition.getServiceResources() + + for(Resource resource : resourceList){ + resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" + } + + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(resourceTemplateUUIDs)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload) + msoLogger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ") + } + + // prepare input param for using DoCreateResources.bpmn + public void preProcessForAddResource(DelegateExecution execution) { + msoLogger.trace("STARTED preProcessForAddResource Process ") + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + List addResourceList = serviceDecomposition.getServiceResources() + execution.setVariable("addResourceList", addResourceList) + + msoLogger.trace("COMPLETED preProcessForAddResource Process ") + } + + public void postProcessForAddResource(DelegateExecution execution) { + // do nothing now + + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy new file mode 100644 index 0000000000..05a0ea86d3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy @@ -0,0 +1,268 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import static org.apache.commons.lang3.StringUtils.*; + +import groovy.xml.XmlUtil +import groovy.json.* + +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.onap.so.logger.MsoLogger +import org.onap.so.logger.MessageEnum + +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; +/** + * This groovy class supports the DoCreateServiceInstanceRollback.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - rollbackData with + * globalCustomerId + * subscriptionServiceType + * serviceInstanceId + * disableRollback + * rollbackAAI + * rollbackSDNC + * sdncRollbackRequest + * + * + * Outputs: + * @param - rollbackError + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * + */ +public class DoCreateE2EServiceInstanceRollback extends AbstractServiceTaskProcessor{ + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateE2EServiceInstanceRollback.class); + String Prefix="DCRESIRB_" + + public void preProcessRequest(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + msoLogger.trace("Start preProcessRequest") + execution.setVariable("rollbackAAI",false) + execution.setVariable("rollbackSDNC",false) + + try { + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("RollbackData:" + rollbackData) + + if (rollbackData != null) { + if (rollbackData.hasType("SERVICEINSTANCE")) { + + def serviceInstanceId = rollbackData.get("SERVICEINSTANCE", "serviceInstanceId") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + def subscriptionServiceType = rollbackData.get("SERVICEINSTANCE", "subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + + def globalSubscriberId = rollbackData.get("SERVICEINSTANCE", "globalSubscriberId") + execution.setVariable("globalSubscriberId", globalSubscriberId) + + def rollbackAAI = rollbackData.get("SERVICEINSTANCE", "rollbackAAI") + if ("true".equals(rollbackAAI)) + { + execution.setVariable("rollbackAAI",true) + } + + def rollbackSDNC = rollbackData.get("SERVICEINSTANCE", "rollbackSDNC") + if ("true".equals(rollbackSDNC)) + { + execution.setVariable("rollbackSDNC", true) + } + + if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true) + { + execution.setVariable("skipRollback", true) + } + + def sdncDelete = rollbackData.get("SERVICEINSTANCE", "sdncDelete") + execution.setVariable("sdncDelete", sdncDelete) + def sdncDeactivate = rollbackData.get("SERVICEINSTANCE", "sdncDeactivate") + execution.setVariable("sdncDeactivate", sdncDeactivate) + msoLogger.debug("sdncDeactivate:\n" + sdncDeactivate) + msoLogger.debug("sdncDelete:\n" + sdncDelete) + } + else { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in Create ServiceInstance Rollback preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) //TODO how does this even compile without exceptionUtil being declared + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method) { + + msoLogger.trace("validateSDNCResponse") + String msg = "" + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msg = "SDNC Adapter service-instance rollback successful for " + method + msoLogger.debug(msg) + }else{ + execution.setVariable("rolledBack", false) + msg = "Error Response from SDNC Adapter service-instance rollback for " + method + execution.setVariable("rollbackError", msg) + msoLogger.debug(msg) + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in Create ServiceInstance rollback for " + method + " Exception:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit validateSDNCResponse ") + } + + /** + * Deletes the service instance in aai + */ + public void deleteServiceInstance(DelegateExecution execution) { + msoLogger.trace("Started Delete Service Instance") + try { + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + resourceClient.delete(serviceInstanceUri) + + msoLogger.trace("Completed Delete Service Instance") + }catch(Exception e){ + msoLogger.debug("Error occured within deleteServiceInstance method: " + e) + } + } + + public void postProcessRequest(DelegateExecution execution) { + + msoLogger.trace("postProcessRequest") + String msg = "" + try { + execution.setVariable("rollbackData", null) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean rollbackAAI = execution.getVariable("rollbackAAI") + boolean rollbackSDNC = execution.getVariable("rollbackSDNC") + if (rollbackAAI || rollbackSDNC) + { + execution.setVariable("rolledBack", true) + } + if (rollbackAAI) + { + boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") + if(!succInAAI){ + execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful + execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback") + msoLogger.debug("Error deleting service-instance in AAI for rollback", + serviceInstanceId) + } + } + msoLogger.trace("Exit postProcessRequest ") + + } catch (BpmnError e) { + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage() + msoLogger.debug(msg) + } catch (Exception ex) { + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() + msoLogger.debug(msg) + } + + } + + public void processRollbackException(DelegateExecution execution){ + + msoLogger.trace("processRollbackException") + try{ + msoLogger.debug("Caught an Exception in DoCreateServiceInstanceRollback") + execution.setVariable("rollbackData", null) + execution.setVariable("rollbackError", "Caught exception in ServiceInstance Create Rollback") + execution.setVariable("WorkflowException", null) + + }catch(BpmnError b){ + msoLogger.debug("BPMN Error during processRollbackExceptions Method: ") + }catch(Exception e){ + msoLogger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage()) + } + + msoLogger.trace(" Exit processRollbackException") + } + + public void processRollbackJavaException(DelegateExecution execution){ + + msoLogger.trace("processRollbackJavaException") + try{ + execution.setVariable("rollbackData", null) + execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Create Rollback") + msoLogger.debug("Caught Exception in processRollbackJavaException") + + }catch(Exception e){ + msoLogger.debug("Caught Exception in processRollbackJavaException " + e.getMessage()) + } + msoLogger.trace("Exit processRollbackJavaException") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy new file mode 100644 index 0000000000..4bbaef8ecb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -0,0 +1,1680 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse; +import org.springframework.web.util.UriUtils + +import groovy.json.* +import groovy.xml.XmlUtil + + +/** + * This groovy class supports the DoCreateNetworkInstance.bpmn process. + * + */ +public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateNetworkInstance.class); + + String Prefix="CRENWKI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the DoCreateNetworkInstance.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "networkRequest", "") + execution.setVariable(Prefix + "rollbackEnabled", null) + execution.setVariable(Prefix + "networkInputs", "") + //execution.setVariable(Prefix + "requestId", "") + execution.setVariable(Prefix + "messageId", "") + execution.setVariable(Prefix + "source", "") + execution.setVariable("BasicAuthHeaderValuePO", "") + execution.setVariable("BasicAuthHeaderValueSDNC", "") + execution.setVariable(Prefix + "serviceInstanceId","") + execution.setVariable("GENGS_type", "") + execution.setVariable(Prefix + "rsrc_endpoint", null) + execution.setVariable(Prefix + "networkOutputs", "") + execution.setVariable(Prefix + "networkId","") + execution.setVariable(Prefix + "networkName","") + + // AAI query Name + execution.setVariable(Prefix + "queryNameAAIRequest","") + execution.setVariable(Prefix + "queryNameAAIResponse", "") + execution.setVariable(Prefix + "aaiNameReturnCode", "") + execution.setVariable(Prefix + "isAAIqueryNameGood", false) + + // AAI query Cloud Region + execution.setVariable(Prefix + "queryCloudRegionRequest","") + execution.setVariable(Prefix + "queryCloudRegionReturnCode","") + execution.setVariable(Prefix + "queryCloudRegionResponse","") + execution.setVariable(Prefix + "cloudRegionPo","") + execution.setVariable(Prefix + "cloudRegionSdnc","") + execution.setVariable(Prefix + "isCloudRegionGood", false) + + // AAI query Id + execution.setVariable(Prefix + "queryIdAAIRequest","") + execution.setVariable(Prefix + "queryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiIdReturnCode", "") + + // AAI query vpn binding + execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") + execution.setVariable(Prefix + "vpnBindings", null) + execution.setVariable(Prefix + "vpnCount", 0) + execution.setVariable(Prefix + "routeCollection", "") + + // AAI query network policy + execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") + execution.setVariable(Prefix + "networkPolicyUriList", null) + execution.setVariable(Prefix + "networkPolicyCount", 0) + execution.setVariable(Prefix + "networkCollection", "") + + // AAI query route table reference + execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") + execution.setVariable(Prefix + "networkTableRefUriList", null) + execution.setVariable(Prefix + "networkTableRefCount", 0) + execution.setVariable(Prefix + "tableRefCollection", "") + + // AAI requery Id + execution.setVariable(Prefix + "requeryIdAAIRequest","") + execution.setVariable(Prefix + "requeryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") + + // AAI update contrail + execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") + execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") + execution.setVariable(Prefix + "updateContrailAAIResponse", "") + execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") + + execution.setVariable(Prefix + "createNetworkRequest", "") + execution.setVariable(Prefix + "createNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + //execution.setVariable(Prefix + "rollbackNetworkResponse", "") + execution.setVariable(Prefix + "networkReturnCode", "") + //execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") + execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) + + execution.setVariable(Prefix + "assignSDNCRequest", "") + execution.setVariable(Prefix + "assignSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + //execution.setVariable(Prefix + "rollbackSDNCResponse", "") + execution.setVariable(Prefix + "sdncReturnCode", "") + //execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") + execution.setVariable(Prefix + "isSdncRollbackNeeded", false) + execution.setVariable(Prefix + "sdncResponseSuccess", false) + + execution.setVariable(Prefix + "activateSDNCRequest", "") + execution.setVariable(Prefix + "activateSDNCResponse", "") + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") + //execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") + execution.setVariable(Prefix + "sdncActivateReturnCode", "") + //execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") + execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", false) + execution.setVariable(Prefix + "sdncActivateResponseSuccess", false) + + execution.setVariable(Prefix + "orchestrationStatus", "") + execution.setVariable(Prefix + "isVnfBindingPresent", false) + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "isException", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the DoCreateNetworkInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request & validate 3 kinds of format. + execution.setVariable("action", "CREATE") + String networkRequest = execution.getVariable("bpmnRequest") + if (networkRequest != null) { + if (networkRequest.contains("requestDetails")) { + // JSON format request is sent, create xml + try { + def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) + msoLogger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) + networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) + + } catch (Exception ex) { + String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } else { + // XML format request is sent + + } + } else { + // vIPR format request is sent, create xml from individual variables + networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) + } + + networkRequest = utils.formatXml(networkRequest) + execution.setVariable(Prefix + "networkRequest", networkRequest) + msoLogger.debug(Prefix + "networkRequest - " + '\n' + networkRequest) + + // validate 'backout-on-failure' to override 'mso.rollback' + boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) + execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) + msoLogger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) + + String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") + execution.setVariable(Prefix + "networkInputs", networkInputs) + msoLogger.debug(Prefix + "networkInputs - " + '\n' + networkInputs) + + // prepare messageId + String messageId = execution.getVariable("testMessageId") // for testing + if (messageId == null || messageId == "") { + messageId = UUID.randomUUID() + msoLogger.debug(Prefix + "messageId, random generated: " + messageId) + } else { + msoLogger.debug(Prefix + "messageId, pre-assigned: " + messageId) + } + execution.setVariable(Prefix + "messageId", messageId) + + String source = utils.getNodeText(networkRequest, "source") + execution.setVariable(Prefix + "source", source) + msoLogger.debug(Prefix + "source - " + source) + + // validate cloud region + String lcpCloudRegionId = utils.getNodeText(networkRequest, "aic-cloud-region") + if ((lcpCloudRegionId == null) || (lcpCloudRegionId == "") || (lcpCloudRegionId == "null")) { + String dataErrorMessage = "Missing value/element: 'lcpCloudRegionId' or 'cloudConfiguration' or 'aic-cloud-region'." + msoLogger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // validate service instance id + String serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id") + if ((serviceInstanceId == null) || (serviceInstanceId == "") || (serviceInstanceId == "null")) { + String dataErrorMessage = "Missing value/element: 'serviceInstanceId'." + msoLogger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey",execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // Set variables for Generic Get Sub Flow use + execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) + msoLogger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId) + + execution.setVariable("GENGS_type", "service-instance") + msoLogger.debug("GENGS_type - " + "service-instance") + msoLogger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution)) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion? : " + sdncVersion) + + // build 'networkOutputs' + String networkId = utils.getNodeText(networkRequest, "network-id") + if ((networkId == null) || (networkId == "null")) { + networkId = "" + } + String networkName = utils.getNodeText(networkRequest, "network-name") + if ((networkName == null) || (networkName == "null")) { + networkName = "" + } + String networkOutputs = + """ + ${MsoUtils.xmlEscape(networkId)} + ${MsoUtils.xmlEscape(networkName)} + """ + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + msoLogger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs) + execution.setVariable(Prefix + "networkId", networkId) + execution.setVariable(Prefix + "networkName", networkName) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkName (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkName() of DoCreateNetworkInstance ***** " ) + + // get variables + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String networkName = utils.getNodeText(networkInputs, "network-name") + networkName = UriUtils.encode(networkName,"UTF-8") + + // Prepare AA&I url with network-name + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String queryAAINameRequest = "${aai_endpoint}${aai_uri}" + "?network-name=" + networkName + execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest) + msoLogger.debug(Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest) + + try { + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAINameRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiNameReturnCode", returnCode) + msoLogger.debug(" ***** AAI Query Name Response Code : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + msoLogger.debug(" ***** AAI Query Name Response : " +'\n'+ aaiResponseAsString) + + if (returnCode=='200') { + execution.setVariable(Prefix + "queryNameAAIResponse", aaiResponseAsString) + execution.setVariable(Prefix + "isAAIqueryNameGood", true) + String orchestrationStatus = "" + try { + // response is NOT empty + orchestrationStatus = utils.getNodeText(aaiResponseAsString, "orchestration-status") + execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase()) + msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase()) + execution.setVariable("orchestrationStatus", orchestrationStatus) + + } catch (Exception ex) { + // response is empty + execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus) + msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus) + } + + } else { + if (returnCode=='404') { + msoLogger.debug(" QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Error Response from QueryAAINetworkName - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage) + + } + + } + + msoLogger.debug(Prefix + "isAAIqueryNameGood? : " + execution.getVariable(Prefix + "isAAIqueryNameGood")) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // try error + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAINetworkName() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAICloudRegion (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAICloudRegion() of DoCreateNetworkInstance ***** " ) + + try { + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) + + String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) + + if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { + execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) + execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) + execution.setVariable(Prefix + "isCloudRegionGood", true) + + } else { + String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood")) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // try error + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkId(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkId() of DoCreateNetworkInstance ***** " ) + + try { + // get variables + String networkId = "" + String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") + if (execution.getVariable("sdncVersion") != "1610") { + String networkResponseInformation = "" + try { + networkResponseInformation = utils.getNodeXml(assignSDNCResponse, "network-response-information", false).replace("tag0:","").replace(":tag0","") + networkId = utils.getNodeText(networkResponseInformation, "instance-id") + } catch (Exception ex) { + String dataErrorMessage = " SNDC Response network validation for 'instance-id' (network-id) failed: Empty " + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } else { + networkId = utils.getNodeText(assignSDNCResponse, "network-id") + } + if (networkId == null || networkId == "null") { + String dataErrorMessage = "SNDC Response did not contains 'instance-id' or 'network-id' element, or the value is null." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } else { + msoLogger.debug(" SNDC Response network validation for 'instance-id' (network-id)' is good: " + networkId) + } + + + execution.setVariable(Prefix + "networkId", networkId) + String networkName = utils.getNodeText(assignSDNCResponse, "network-name") + execution.setVariable(Prefix + "networkName", networkName) + + networkId = UriUtils.encode(networkId,"UTF-8") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) + msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiIdReturnCode", returnCode) + + msoLogger.debug(" ***** AAI Response Code : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString) + + String netId = utils.getNodeText(aaiResponseAsString, "network-id") + execution.setVariable(Prefix + "networkId", netId) + String netName = utils.getNodeText(aaiResponseAsString, "network-name") + execution.setVariable(Prefix + "networkName", netName) + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." + msoLogger.debug(" AAI Query Failed. " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode + msoLogger.debug("Unexpected Response from QueryAAINetworkId - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTReQueryAAINetworkId(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTReQueryAAINetworkId() of DoCreateNetworkInstance ***** " ) + + try { + // get variables + String networkId = execution.getVariable(Prefix + "networkId") + String netId = networkId + networkId = UriUtils.encode(networkId,"UTF-8") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) + msoLogger.debug(Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode) + msoLogger.debug(" ***** AAI ReQuery Response Code : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString) + msoLogger.debug(" ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString) + + String netName = utils.getNodeText(aaiResponseAsString, "network-name") + String networkOutputs = + """ + ${MsoUtils.xmlEscape(netId)} + ${MsoUtils.xmlEscape(netName)} + """ + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs) + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." + msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding() of DoCreateNetworkInstance ***** " ) + + try { + + // get variables + String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") + String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") + msoLogger.debug(" relationship - " + relationship) + + // Check if Vnf Binding is present, then build a List of vnfBinding + List vpnBindingUri = networkUtils.getVnfBindingObject(relationship) + int vpnCount = vpnBindingUri.size() + execution.setVariable(Prefix + "vpnCount", vpnCount) + msoLogger.debug(Prefix + "vpnCount - " + vpnCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (vpnCount > 0) { + execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) + msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri) + + String routeTargets = "" + // AII loop call using list vpnBindings + for (i in 0..vpnBindingUri.size()-1) { + + int counting = i+1 + + // prepare url using vpnBinding + String queryVpnBindingAAIRequest = "" + String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) + + // Note: By default, the vpnBinding url is found in 'related-link' of the response, + // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. + if (aai_uri == null || aai_uri == "") { + // using value of 'related-link' from response + if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" + } else { + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" + } + + } else { + // using uri value in URN mapping + String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) + if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { + vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) + } + queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" + } + + execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) + msoLogger.debug(Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) + msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) + msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString) + + String routeTarget = "" + String routeRole = "" + if (utils.nodeExists(aaiResponseAsString, "route-targets")) { + String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) + def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) + def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} + for (j in 0..aaiRouteTarget.size()-1) { + routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") + routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") + routeTargets += "" + '\n' + + " " + routeTarget + "" + '\n' + + " " + routeRole + "" + '\n' + + "" + '\n' + } + } + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + execution.setVariable(Prefix + "routeCollection", routeTargets) + msoLogger.debug(Prefix + "routeCollection - " + '\n' + routeTargets) + + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiStubResponse = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "routeCollection", "") + msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkPolicy() of DoCreateNetworkInstance ***** " ) + + try { + // get variables + String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") + String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") + msoLogger.debug(" relationship - " + relationship) + + // Check if Network Policy is present, then build a List of network policy + List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship) + int networkPolicyCount = networkPolicyUriList.size() + execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) + msoLogger.debug(Prefix + "networkPolicyCount - " + networkPolicyCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (networkPolicyCount > 0) { + execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList) + msoLogger.debug(" networkPolicyUri List - " + networkPolicyUriList) + + String networkPolicies = "" + // AII loop call using list vpnBindings + for (i in 0..networkPolicyUriList.size()-1) { + + int counting = i+1 + + // prepare url using vpnBinding + String queryNetworkPolicyAAIRequest = "" + + String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) + + // Note: By default, the network policy url is found in 'related-link' of the response, + // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. + if (aai_uri == null || aai_uri == "") { + // using value of 'related-link' from response + if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" + } else { + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" + } + } else { + // using uri value in URN mapping + String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) + println " networkPolicyId - " + networkPolicyId + if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { + networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) + } + queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" + + } + + + execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) + msoLogger.debug(Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) + + String networkPolicy = "" + if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) { + networkPolicy = utils.getNodeText(aaiResponseAsString, "network-policy-fqdn") + networkPolicies += "" + networkPolicy + "" + '\n' + } + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + execution.setVariable(Prefix + "networkCollection", networkPolicies) + msoLogger.debug(Prefix + "networkCollection - " + '\n' + networkPolicies) + + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiStubResponse = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "networkCollection", "") + msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkTableRef() of DoCreateNetworkInstance ***** " ) + + try { + // get variables + String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") + String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") + msoLogger.debug(" relationship - " + relationship) + + // Check if Network TableREf is present, then build a List of network policy + List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship) + int networkTableRefCount = networkTableRefUriList.size() + execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount) + msoLogger.debug(Prefix + "networkTableRefCount - " + networkTableRefCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (networkTableRefCount > 0) { + execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList) + msoLogger.debug(" networkTableRefUri List - " + networkTableRefUriList) + + // AII loop call using list vpnBindings + String networkTableRefs = "" + for (i in 0..networkTableRefUriList.size()-1) { + + int counting = i+1 + + // prepare url using tableRef + String queryNetworkTableRefAAIRequest = "" + + String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) + + // Note: By default, the network policy url is found in 'related-link' of the response, + // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. + if (aai_uri == null || aai_uri == "") { + // using value of 'related-link' from response + if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" + } else { + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" + } + } else { + // using uri value in URN mapping + String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) + + if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { + networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) + } + queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" + + } + + + execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) + msoLogger.debug(Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString) + + String networkTableRef = "" + if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) { + networkTableRef = utils.getNodeText(aaiResponseAsString, "route-table-reference-fqdn") + networkTableRefs += "" + networkTableRef + "" + '\n' + } + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) + msoLogger.debug(Prefix + "tableRefCollection - " + '\n' + networkTableRefs) + + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiStubResponse = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "tableRefCollection", "") + msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " ) + + try { + // get variables + String networkId = execution.getVariable(Prefix + "networkId") + networkId = UriUtils.encode(networkId,"UTF-8") + String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") + + // Prepare url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + + execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) + msoLogger.debug(Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest) + + //Prepare payload (PUT) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) + String payloadXml = utils.formatXml(payload) + execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml) + msoLogger.debug(" 'payload' to Update Contrail - " + "\n" + payloadXml) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payloadXml) + + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode) + msoLogger.debug(" ***** AAI Update Contrail Response Code : " + returnCode) + String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() + if (returnCode=='200') { + execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString) + msoLogger.debug(" AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString) + // Point-of-no-return is set to false, rollback not needed. + String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled") + if (rollbackEnabled == "true") { + execution.setVariable(Prefix + "isPONR", false) + } else { + execution.setVariable(Prefix + "isPONR", true) + } + msoLogger.debug(Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR")) + } else { + if (returnCode=='404') { + String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiUpdateContrailResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode + msoLogger.debug(errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + } + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareCreateNetworkRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareCreateNetworkRequest() of DoCreateNetworkInstance") + + try { + + // get variables + String requestId = execution.getVariable("msoRequestId") + if (requestId == null) { + requestId = execution.getVariable("mso-request-id") + } + String messageId = execution.getVariable(Prefix + "messageId") + String source = execution.getVariable(Prefix + "source") + + String requestInput = execution.getVariable(Prefix + "networkRequest") + String queryIdResponse = execution.getVariable(Prefix + "queryIdAAIResponse") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") + String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") + + // Prepare Network request + String routeCollection = execution.getVariable(Prefix + "routeCollection") + String policyCollection = execution.getVariable(Prefix + "networkCollection") + String tableCollection = execution.getVariable(Prefix + "tableRefCollection") + String createNetworkRequest = networkUtils.CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) + // Format Response + String buildDeleteNetworkRequestAsString = utils.formatXml(createNetworkRequest) + buildDeleteNetworkRequestAsString = buildDeleteNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") + + execution.setVariable(Prefix + "createNetworkRequest", buildDeleteNetworkRequestAsString) + msoLogger.debug(Prefix + "createNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareCreateNetworkRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareSDNCRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareSDNCRequest() of DoCreateNetworkInstance") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) + msoLogger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRpcSDNCRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance") + + try { + // get variables + + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) + + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) + msoLogger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRpcSDNCActivateRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCActivateRequest() of DoCreateNetworkInstance") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) + + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + execution.setVariable(Prefix + "activateSDNCRequest", sndcTopologyCreateRequesAsString) + msoLogger.debug(Prefix + "activateSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void validateCreateNetworkResponse (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateNetworkResponse() of DoCreateNetworkInstance") + + try { + String returnCode = execution.getVariable(Prefix + "networkReturnCode") + String networkResponse = execution.getVariable(Prefix + "createNetworkResponse") + if (networkResponse==null) { + networkResponse="" // reset + } + + msoLogger.debug(" Network Adapter create responseCode: " + returnCode) + + String errorMessage = "" + if (returnCode == "200") { + execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) + execution.setVariable(Prefix + "createNetworkResponse", networkResponse) + msoLogger.debug(" Network Adapter create Success Response - " + "\n" + networkResponse) + + // prepare rollback data + String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") + rollbackData = rollbackData.replace("rollback>", "networkRollback>") + String rollbackNetwork = + """ + ${rollbackData} + """ + String rollbackNetworkXml = utils.formatXml(rollbackNetwork) + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) + msoLogger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) + + } else { // network error + if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx + if (networkResponse.contains("createNetworkError")) { + networkResponse = networkResponse.replace('', '') + errorMessage = utils.getNodeText(networkResponse, "message") + errorMessage = "Received error from Network Adapter: " + errorMessage + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + + } else { // CatchAll exception + if (returnCode == "500") { + errorMessage = "JBWEB000065: HTTP Status 500." + } else { + errorMessage = "Return code is " + returnCode + } + errorMessage = "Received error from Network Adapter: " + errorMessage + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + + } + + } else { // CatchAll exception + String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. validateCreateNetworkResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + public void validateSDNCResponse (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateSDNCResponse() of DoCreateNetworkInstance") + + String response = execution.getVariable(Prefix + "assignSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "assignSDNCResponse") + assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('', "") + execution.setVariable(Prefix + "assignSDNCResponse", assignSDNCResponseDecodeXml) + + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncRollbackNeeded", true) + msoLogger.debug("Successfully Validated SDNC Response") + + } else { + msoLogger.debug("Did NOT Successfully Validated SDNC Response") + throw new BpmnError("MSOWorkflowException") + } + + } + + public void validateRpcSDNCActivateResponse (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateRpcSDNCActivateResponse() of DoCreateNetworkInstance") + + String response = execution.getVariable(Prefix + "activateSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "activateSDNCResponse") + assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('', "") + execution.setVariable(Prefix + "activateSDNCResponse", assignSDNCResponseDecodeXml) + + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", true) + msoLogger.debug("Successfully Validated Rpc SDNC Activate Response") + + } else { + msoLogger.debug("Did NOT Successfully Validated Rpc SDNC Activate Response") + throw new BpmnError("MSOWorkflowException") + } + + } + + + public void prepareSDNCRollbackRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareSDNCRollbackRequest() of DoCreateNetworkInstance") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") + String networkId = execution.getVariable(Prefix + "networkId") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) + msoLogger.debug(" Preparing request for SDNC Topology 'rollback-NetworkActivateRequest' rollback . . . - " + "\n" + sndcTopologyRollbackRequestAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRpcSDNCRollbackRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCRollbackRequest() of DoCreateNetworkInstance") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") + String networkId = execution.getVariable(Prefix + "networkId") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + msoLogger.debug(" Preparing request for SDNC Topology 'unassign-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRollbackRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRpcSDNCActivateRollback(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCActivateRollback() of DoCreateNetworkInstance") + + try { + + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String activateSDNCResponse = execution.getVariable(Prefix + "activateSDNCResponse") + String networkId = execution.getVariable(Prefix + "networkId") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + msoLogger.debug(" Preparing request for RPC SDNC Topology 'deactivate-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRollbackData() of DoCreateNetworkInstance") + + try { + + Map rollbackData = new HashMap(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") + if (rollbackActivateSDNCRequest != null) { + if (rollbackActivateSDNCRequest != "") { + rollbackData.put("rollbackActivateSDNCRequest", execution.getVariable(Prefix + "rollbackActivateSDNCRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + msoLogger.debug("** rollbackData : " + rollbackData) + + execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) + msoLogger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void postProcessResponse(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside postProcessResponse() of DoCreateNetworkInstance") + + try { + + //Conditions: + // 1. Silent Success: execution.getVariable("CRENWKI_orchestrationStatus") == "ACTIVE" + // 2. Success: execution.getVariable("WorkflowException") == null (NULL) + // 3. WorkflowException: execution.getVariable("WorkflowException") != null (NOT NULL) + + msoLogger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) + // successful flow + if (execution.getVariable(Prefix + "isException") == false) { + // set rollback data + execution.setVariable("orchestrationStatus", "") + execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) + execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) + prepareSuccessRollbackData(execution) // populate rollbackData + execution.setVariable("WorkflowException", null) + execution.setVariable(Prefix + "Success", true) + msoLogger.debug(" ***** postProcessResponse(), GOOD !!!") + } else { + // inside sub-flow logic + execution.setVariable(Prefix + "Success", false) + execution.setVariable("rollbackData", null) + String exceptionMessage = " Exception encountered in MSO Bpmn. " + if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. + msoLogger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) + WorkflowException wfex = execution.getVariable("workflowException") + exceptionMessage = wfex.getErrorMessage() + } else { + if (execution.getVariable(Prefix + "WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } + } + // going to the Main flow: a-la-carte or macro + msoLogger.debug(" ***** postProcessResponse(), BAD !!!") + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } + + } catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + + } + + + + } + + public void prepareSuccessRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareSuccessRollbackData() of DoCreateNetworkInstance") + + try { + + if (execution.getVariable("sdncVersion") != '1610') { + prepareRpcSDNCRollbackRequest(execution) + prepareRpcSDNCActivateRollback(execution) + } else { + prepareSDNCRollbackRequest(execution) + } + + Map rollbackData = new HashMap(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + } + } + String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") + if (rollbackActivateSDNCRequest != null) { + if (rollbackActivateSDNCRequest != "") { + rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) + } + } + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("** 'rollbackData' for Full Rollback : " + rollbackData) + execution.setVariable("WorkflowException", null) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void setExceptionFlag(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside setExceptionFlag() of DoCreateNetworkInstance") + + try { + + execution.setVariable(Prefix + "isException", true) + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + msoLogger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) + + } catch(Exception ex){ + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + + + public void processJavaException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + try{ + msoLogger.debug( "Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.debug( "Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy new file mode 100644 index 0000000000..7e00f05b90 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy @@ -0,0 +1,393 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil + +import groovy.json.* +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.onap.so.logger.MessageEnum + +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils + +/** + * This groovy class supports the DoCreateNetworkInstance.bpmn process. + * + */ +public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateNetworkInstanceRollback.class); + + String Prefix="CRENWKIR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the DoCreateNetworkInstanceRollback.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "rollbackNetworkRequest", null) + execution.setVariable(Prefix + "rollbackSDNCRequest", null) + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", null) + execution.setVariable(Prefix + "WorkflowException", null) + + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + execution.setVariable(Prefix + "rollbackNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") + + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + execution.setVariable(Prefix + "rollbackSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") + + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") + execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") + execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") + + execution.setVariable(Prefix + "Success", false) + execution.setVariable(Prefix + "fullRollback", false) + execution.setVariable(Prefix + "networkId", "") + execution.setVariable(Prefix + "urlRollbackPoNetwork", "") + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the DoCreateNetworkInstanceRollback.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request/variables + String rollbackNetworkRequest = null + String rollbackSDNCRequest = null + String rollbackActivateSDNCRequest = null + + // Partial Rollback + Map rollbackData = execution.getVariable("rollbackData") + if (rollbackData != null && rollbackData instanceof Map) { + + if(rollbackData.containsKey("rollbackSDNCRequest")) { + rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] + } + + if(rollbackData.containsKey("rollbackNetworkRequest")) { + rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] + } + + if(rollbackData.containsKey("rollbackActivateSDNCRequest")) { + rollbackActivateSDNCRequest = rollbackData["rollbackActivateSDNCRequest"] + } + + } + + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) + msoLogger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion? : " + sdncVersion) + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + msoLogger.debug(dataErrorMessage ) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + msoLogger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) + if(execution.getVariable(Prefix + "WorkflowException") != null) { + // called by: DoCreateNetworkInstance, partial rollback + execution.setVariable(Prefix + "fullRollback", false) + + } else { + // called by: Macro - Full Rollback, WorkflowException = null + execution.setVariable(Prefix + "fullRollback", true) + + } + msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callPONetworkAdapter (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside callPONetworkAdapter() of " + className + "") + + try { + String poUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution) + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + String networkId = utils.getNodeText(rollbackSDNCRequest, "network-id") + + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + + String urlRollbackPoNetwork = poUrl+ "/" + networkId + "/rollback" + msoLogger.debug("'urlRollbackPoNetwork': " + urlRollbackPoNetwork) + execution.setVariable(Prefix + "urlRollbackPoNetwork", urlRollbackPoNetwork) + + RESTConfig config = new RESTConfig(urlRollbackPoNetwork) + RESTClient client = new RESTClient(config). + addHeader("Content-Type", "application/xml"). + addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO")); + + APIResponse response = client.httpDelete(rollbackNetworkRequest) + String responseCode = response.getStatusCode() + String responseBody = response.getResponseBodyAsString() + + execution.setVariable(Prefix + "rollbackNetworkReturnCode", responseCode) + execution.setVariable(Prefix + "rollbackNetworkResponse", responseBody) + + msoLogger.debug(" Network Adapter rollback responseCode: " + responseCode) + msoLogger.debug(" Network Adapter rollback responseBody: " + responseBody) + + + } catch (Exception ex) { + String exceptionMessage = "Exception Encountered in callPONetworkAdapter() of DoCreateNetworkInstanceRollback flow - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + public void validateRollbackResponses (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateRollbackResponses() of DoCreateNetworkInstanceRollback") + + try { + // validate PO network rollback response + String rollbackNetworkErrorMessages = "" + String rollbackNetworkReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { + rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") + String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse") + msoLogger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) + msoLogger.debug(" NetworkRollback Response - " + rollbackNetworkResponse) + if (rollbackNetworkReturnCode != "200") { + rollbackNetworkErrorMessages = " + PO Network rollback failed. " + } else { + rollbackNetworkErrorMessages = " + PO Network rollback completed." + } + } + + // validate SDNC rollback response + String rollbackSdncErrorMessages = "" + String rollbackSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { + rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") + String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") + String rollbackSDNCReturnInnerCode = "" + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + rollbackSDNCResponse = rollbackSDNCResponse + rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('', "") + if (rollbackSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { + rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") + if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { + rollbackSdncErrorMessages = " + SNDC assign rollback completed." + } else { + rollbackSdncErrorMessages = " + SDNC assign rollback failed. " + } + } else { + rollbackSdncErrorMessages = " + SNDC assign rollback completed." + } + } else { + rollbackSdncErrorMessages = " + SDNC assign rollback failed. " + } + msoLogger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode) + msoLogger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse) + } + + // validate SDNC activate rollback response + String rollbackActivateSdncErrorMessages = "" + String rollbackActivateSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackActivateSDNCRequest") != null) { + rollbackActivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackActivateSDNCReturnCode") + String rollbackActivateSDNCResponse = execution.getVariable(Prefix + "rollbackActivateSDNCResponse") + String rollbackActivateSDNCReturnInnerCode = "" + rollbackActivateSDNCResponse = rollbackActivateSDNCResponse + rollbackActivateSDNCResponse = rollbackActivateSDNCResponse.replace('$', '').replace('', "") + if (rollbackActivateSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackActivateSDNCResponse, "response-code")) { + rollbackActivateSDNCReturnInnerCode = utils.getNodeText(rollbackActivateSDNCResponse, "response-code") + if (rollbackActivateSDNCReturnInnerCode == "200" || rollbackActivateSDNCReturnInnerCode == "" || rollbackActivateSDNCReturnInnerCode == "0") { + rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed." + } else { + rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. " + } + } else { + rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed." + } + } else { + rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. " + } + msoLogger.debug(" SDNC activate rollback Code - " + rollbackActivateSDNCReturnCode) + msoLogger.debug(" SDNC activate rollback Response - " + rollbackActivateSDNCResponse) + } + + + String statusMessage = "" + int errorCode = 7000 + msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + if (execution.getVariable(Prefix + "fullRollback") == false) { + // original WorkflowException, + WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") + if (wfe != null) { + // rollback due to failure in DoCreate - Partial rollback + statusMessage = wfe.getErrorMessage() + errorCode = wfe.getErrorCode() + } else { + statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + errorCode = '7000' + } + + // set if all rolledbacks are successful + if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") { + execution.setVariable("rolledBack", true) + execution.setVariable("wasDeleted", true) + + } else { + execution.setVariable("rolledBack", false) + execution.setVariable("wasDeleted", true) + } + + statusMessage = statusMessage + rollbackActivateSdncErrorMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages + msoLogger.debug("Final DoCreateNetworkInstanceRollback status message: " + statusMessage) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); + execution.setVariable("workflowException", exception); + + } else { + // rollback due to failures in Main flow (Macro) - Full rollback + // WorkflowException = null + if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") { + execution.setVariable("rollbackSuccessful", true) + execution.setVariable("rollbackError", false) + } else { + String exceptionMessage = "Network Create Rollback was not Successful. " + msoLogger.debug(exceptionMessage) + execution.setVariable("rollbackSuccessful", false) + execution.setVariable("rollbackError", true) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } + + } + + + } catch (Exception ex) { + String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ******************************* + // Build Error Section + // ******************************* + + + + public void processJavaException(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + try{ + msoLogger.debug("Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.debug("Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy new file mode 100644 index 0000000000..f7c5c1b83d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy @@ -0,0 +1,279 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.codehaus.jackson.map.ObjectMapper +import org.onap.so.bpmn.infrastructure.properties.BPMNProperties + +import java.util.ArrayList +import java.util.Iterator +import java.util.List +import org.apache.commons.lang3.StringUtils +import org.apache.http.HttpResponse +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.codehaus.groovy.runtime.ArrayUtil +import org.codehaus.groovy.runtime.ScriptBytecodeAdapter +import org.codehaus.groovy.runtime.callsite.CallSite +import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation +import org.codehaus.groovy.runtime.typehandling.ShortTypeHandling +import org.json.JSONArray +import org.json.JSONObject +import org.onap.so.bpmn.common.recipe.BpmnRestClient +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.AllottedResource +import org.onap.so.bpmn.core.domain.NetworkResource +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + + + +/** + * This groovy class supports the DoCreateResources.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion + * + * @param - addResourceList + * + * Outputs: + * @param - WorkflowException + + */ +public class DoCreateResources extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateResources.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() + + public void preProcessRequest(DelegateExecution execution) + { + msoLogger.trace("preProcessRequest ") + String msg = "" + + List addResourceList = execution.getVariable("addResourceList") + if (addResourceList == null) + { + msg = "Input addResourceList is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else if (addResourceList.size() == 0) + { + msg = "No resource in addResourceList" + msoLogger.info(msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void sequenceResoure(DelegateExecution execution) + { + msoLogger.trace("Start sequenceResoure Process ") + + String serviceModelUUID = execution.getVariable("modelUuid") + + List addResourceList = execution.getVariable("addResourceList") + + List networkResourceList = new ArrayList() + + List sequencedResourceList = new ArrayList() + + String serviceDecompose = execution.getVariable("serviceDecomposition") + String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") + def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName) + + if(resourceSequence != null) { + // sequence is defined in config file + for (resourceType in resourceSequence) { + for (resource in addResourceList) { + if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { + sequencedResourceList.add(resource) + + if (resource instanceof NetworkResource) { + networkResourceList.add(resource) + } + } + } + } + } else { + + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List vnfResourceList = new ArrayList() + List arResourceList = new ArrayList() + + for (Resource rc : addResourceList){ + if (rc instanceof VnfResource) { + vnfResourceList.add(rc) + } else if (rc instanceof NetworkResource) { + networkResourceList.add(rc) + } else if (rc instanceof AllottedResource) { + arResourceList.add(rc) + } + } + sequencedResourceList.addAll(vnfResourceList) + sequencedResourceList.addAll(networkResourceList) + sequencedResourceList.addAll(arResourceList) + } + + String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("sequencedResourceList", sequencedResourceList) + msoLogger.info("sequencedResourceList: " + sequencedResourceList) + msoLogger.trace("COMPLETED sequenceResoure Process ") + } + + public prepareServiceTopologyRequest(DelegateExecution execution) { + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start prepareServiceTopologyRequest Process ======== ", isDebugEnabled) + + String serviceDecompose = execution.getVariable("serviceDecomposition") + + execution.setVariable("operationType", "create") + execution.setVariable("resourceType", "") + + String serviceInvariantUuid = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelInvariantUuid") + String serviceUuid = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelUuid") + String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") + + execution.setVariable("modelInvariantUuid", serviceInvariantUuid) + execution.setVariable("modelUuid", serviceUuid) + execution.setVariable("serviceModelName", serviceModelName) + + utils.log("INFO", "======== End prepareServiceTopologyRequest Process ======== ", isDebugEnabled) + } + + public void getCurrentResoure(DelegateExecution execution){ + msoLogger.trace("Start getCurrentResoure Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + List sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + execution.setVariable("resourceType", currentResource.getModelInfo().getModelName()) + msoLogger.info("Now we deal with resouce:" + currentResource.getModelInfo().getModelName()) + msoLogger.trace("COMPLETED getCurrentResoure Process ") + } + + public void parseNextResource(DelegateExecution execution){ + msoLogger.trace("Start parseNextResource Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List sequencedResourceList = execution.getVariable("sequencedResourceList") + if(nextIndex >= sequencedResourceList.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + msoLogger.trace("COMPLETED parseNextResource Process ") + } + + public void prepareResourceRecipeRequest(DelegateExecution execution){ + msoLogger.trace("Start prepareResourceRecipeRequest Process ") + ResourceInput resourceInput = new ResourceInput() + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String resourceType = execution.getVariable("resourceType") + String resourceInstanceName = resourceType + "_" + serviceInstanceName + resourceInput.setResourceInstanceName(resourceInstanceName) + msoLogger.info("Prepare Resource Request resourceInstanceName:" + resourceInstanceName) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = "createInstance" + resourceInput.setGlobalSubscriberId(globalSubscriberId) + resourceInput.setServiceType(serviceType) + resourceInput.setServiceInstanceId(serviceInstanceId) + resourceInput.setOperationId(operationId) + resourceInput.setOperationType(operationType); + def currentIndex = execution.getVariable("currentResourceIndex") + List sequencedResourceList = execution.getVariable("sequencedResourceList") + Resource currentResource = sequencedResourceList.get(currentIndex) + resourceInput.setResourceModelInfo(currentResource.getModelInfo()); + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); + + String incomingRequest = execution.getVariable("uuiRequest") + //set the requestInputs from tempalte To Be Done + String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") + String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") + String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters) + resourceInput.setResourceParameters(resourceParameters) + execution.setVariable("resourceInput", resourceInput) + msoLogger.trace("COMPLETED prepareResourceRecipeRequest Process ") + } + + public void executeResourceRecipe(DelegateExecution execution){ + msoLogger.trace("Start executeResourceRecipe Process ") + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceType = execution.getVariable("serviceType") + ResourceInput resourceInput = execution.getVariable("resourceInput") + + // requestAction is action, not opertiontype + //String requestAction = resourceInput.getOperationType() + String requestAction = "createInstance" + JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceModelInfo().getModelUuid(), requestAction) + + if (resourceRecipe != null) { + String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + resourceRecipe.getString("orchestrationUri") + int recipeTimeOut = resourceRecipe.getInt("recipeTimeout") + String recipeParamXsd = resourceRecipe.get("paramXSD") + HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) + } else { + String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + + resourceInput.getResourceModelInfo().getModelUuid() + utils.log("ERROR", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage) + } + + msoLogger.trace("======== end executeResourceRecipe Process ======== ") + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug("Error occured within DoCreateResources executeResourceRecipe method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured during DoCreateResources executeResourceRecipe Catalog") + } + } + + public void postConfigRequest(DelegateExecution execution){ + //now do noting + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy new file mode 100644 index 0000000000..93a260a544 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -0,0 +1,795 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.OwningEntity +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInstance +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +import groovy.json.* + +/** + * This groovy class supports the DoCreateServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId + * @param - subscriptionServiceType + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceModelInfo + * @param - productFamilyId + * @param - disableRollback + * @param - failExists - 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) + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * @param - WorkflowException + * @param - serviceInstanceName - (GET from AAI if null in input) + * + * This BB processes Macros(except TRANSPORT all sent to sdnc) and Alacartes(sdncSvcs && nonSdncSvcs) + */ +public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateServiceInstance.class); + String Prefix="DCRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + msoLogger.trace("preProcessRequest") + + try { + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("prefix", Prefix) + + setBasicDBAuthHeader(execution, isDebugEnabled) + //Inputs + //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology + String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //requestDetails.requestParameters. for SDNC assignTopology + String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId + + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (productFamilyId == null) { + execution.setVariable("productFamilyId", "") + } + + String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (isBlank(sdncCallbackUrl)) { + msg = "mso.workflow.sdncadapter.callback is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + + //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 = "" + + ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") + if (serviceDecomp != null) + { + serviceType = serviceDecomp.getServiceType() ?: "" + msoLogger.debug("serviceType:" + serviceType) + serviceRole = serviceDecomp.getServiceRole() ?: "" + + 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" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + 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" + msoLogger.debug(msg) + 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) + execution.setVariable("serviceInstanceName", serviceInstanceName) + + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + execution.setVariable("modelVersion", modelVersion) + execution.setVariable("modelUuid", modelUuid) + execution.setVariable("modelName", modelName) + + //alacarte SIs are NOT sent to sdnc. exceptions are listed in config variable + String svcTypes = UrnPropertiesReader.getVariable("sdnc.si.svc.types",execution) ?: "" + msoLogger.debug("SDNC SI serviceTypes:" + svcTypes) + List svcList = Arrays.asList(svcTypes.split("\\s*,\\s*")); + boolean isSdncService= false + for (String listEntry : svcList){ + if (listEntry.equalsIgnoreCase(serviceType)){ + isSdncService = true + break; + } + } + + //All Macros are sent to SDNC, TRANSPORT(Macro) is sent to SDNW + //Alacartes are sent to SDNC if they are listed in config variable above + execution.setVariable("sendToSDNC", true) + if(execution.getVariable("sdncVersion").equals("1610")) //alacarte + { + if(!isSdncService){ + execution.setVariable("sendToSDNC", false) + //alacarte non-sdnc svcs must provide name (sdnc provides name for rest) + if (isBlank(execution.getVariable("serviceInstanceName" ))) + { + msg = "Input serviceInstanceName must be provided for alacarte" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + } + + msoLogger.debug("isSdncService: " + isSdncService) + msoLogger.debug("Send To SDNC: " + execution.getVariable("sendToSDNC")) + msoLogger.debug("Service Type: " + execution.getVariable("serviceType")) + + //macro may provide name and alacarte-portm may provide name + execution.setVariable("checkAAI", false) + if (!isBlank(execution.getVariable("serviceInstanceName" ))) + { + execution.setVariable("checkAAI", true) + } + + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + + 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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(paramValue)} + + """ + sbParams.append(paramsXml) + } + sbParams.append("") + } + String siParamsXml = sbParams.toString() + if (siParamsXml == null) + siParamsXml = "" + execution.setVariable("siParamsXml", siParamsXml) + + //AAI PUT + String oStatus = execution.getVariable("initialStatus") ?: "Active" + if ("TRANSPORT".equalsIgnoreCase(serviceType)) + { + oStatus = "Created" + } + + String statusLine = isBlank(oStatus) ? "" : "${MsoUtils.xmlEscape(oStatus)}" + String serviceTypeLine = isBlank(serviceType) ? "" : "${MsoUtils.xmlEscape(serviceType)}" + String serviceRoleLine = isBlank(serviceRole) ? "" : "${MsoUtils.xmlEscape(serviceRole)}" + + //QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT + String environmentContext = "" + String workloadContext ="" + + try{ + String json = cutils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + + msoLogger.debug("JSON IS: "+json) + + environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" + workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" + msoLogger.debug("Env Context is: "+ environmentContext) + msoLogger.debug("Workload Context is: "+ workloadContext) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + //Create AAI Payload + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String serviceInstanceData = + """ + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${serviceTypeLine} + ${serviceRoleLine} + ${statusLine} + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(environmentContext)} + ${MsoUtils.xmlEscape(workloadContext)} + """.trim() + + execution.setVariable("serviceInstanceData", serviceInstanceData) + msoLogger.debug(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest") + } + + //TODO: Will be able to replace with call to GenericGetService + public void getAAICustomerById (DelegateExecution execution) { + // https://{aaiEP}/aai/v8/business/customers/customer/{globalCustomerId} + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + try { + + String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map + msoLogger.debug(" ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + if (isBlank(aai_endpoint) || isBlank(aai_uri)) + { + msg = "AAI URL is invalid. Endpoint:" + aai_endpoint + aai_uri + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + String getAAICustomerUrl = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + + msoLogger.debug("getAAICustomerById Url:" + getAAICustomerUrl) + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getAAICustomerUrl) + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msg = "getAAICustomerById ResponseCode:" + returnCode + " ResponseString:" + aaiResponseAsString + msoLogger.debug(msg) + + if (returnCode=='200') { + // Customer found by ID. FLow to proceed. + msoLogger.debug(msg) + + //TODO Deferred + //we might verify that service-subscription with matching name exists + //and throw error if not. If not checked, we will get exception in subsequent step on Create call + //in 1610 we assume both customer & service subscription were pre-created + + } else { + if (returnCode=='404') { + msg = "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, aaiResponseAsString, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", workflowException) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + msg = "Error in getAAICustomerById ResponseCode:" + returnCode + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in getAAICustomerById. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit getAAICustomerById") + + } + + public void postProcessAAIGET(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("postProcessAAIGET") + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.debug("Error getting Service-instance from AAI", + serviceInstanceName) + WorkflowException workflowException = execution.getVariable("WorkflowException") + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + msoLogger.debug("Found Service-instance in AAI") + msg = "ServiceInstance already exists in AAI:" + serviceInstanceName + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET") + } + + public void postProcessAAIPUT(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("postProcessAAIPUT") + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") + if(!succInAAI){ + msoLogger.debug("Error putting Service-instance in AAI", + serviceInstanceId) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + } + else + { + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIPUT") + } + + public void preProcessSDNCAssignRequest(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + msoLogger.trace("preProcessSDNCAssignRequest") + + try { + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def serviceInstanceName = execution.getVariable("serviceInstanceName") + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("productFamilyId") + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") + def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + def msoAction = "" + + 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() + + def siParamsXml = execution.getVariable("siParamsXml") + + // special URL for SDNW, msoAction helps set diff url in SDNCA + if("TRANSPORT".equalsIgnoreCase(execution.getVariable("serviceType"))) + { + msoAction = "TRANSPORT" + } + + String sdncAssignRequest = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + assign + service-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + ${MsoUtils.xmlEscape(msoAction)} + + + + ${MsoUtils.xmlEscape(requestId)} + MSO + + + + CreateServiceInstance + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${siParamsXml} + + + """ + + msoLogger.debug("sdncAssignRequest:\n" + sdncAssignRequest) + sdncAssignRequest = utils.formatXml(sdncAssignRequest) + execution.setVariable("sdncAssignRequest", sdncAssignRequest) + msoLogger.debug("sdncAssignRequest: " + sdncAssignRequest) + + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncDelete = sdncAssignRequest.replace(">assign<", ">delete<").replace(">CreateServiceInstance<", ">DeleteServiceInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def sdncRequestId3 = UUID.randomUUID().toString() + String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId2}<", ">${sdncRequestId3}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate) + rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCAssignRequest. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessSDNCAssignRequest") + } + + public void postProcessSDNCAssign (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("postProcessSDNCAssign") + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + String response = execution.getVariable("sdncAdapterResponse") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Good response from SDNC Adapter for service-instance topology assign: \n" + response) + + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put("SERVICEINSTANCE", "rollbackSDNC", "true") + execution.setVariable("rollbackData", rollbackData) + + }else{ + msoLogger.debug("Bad Response from SDNC Adapter for service-instance assign") + throw new BpmnError("MSOWorkflowException") + } + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in postProcessSDNCAssign. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessSDNCAssign") + } + + public void postProcessAAIGET2(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("postProcessAAIGET2") + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.debug("Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + String aaiService = execution.getVariable("GENGS_service") + if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) { + execution.setVariable("serviceInstanceName", utils.getNodeText(aaiService, "service-instance-name")) + msoLogger.debug("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName")) + } + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET2") + } + + public void preProcessRollback (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("preProcessRollback") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit preProcessRollback") + } + + public void postProcessRollback (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("postProcessRollback") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit postProcessRollback") + } + + public void createProject(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("createProject") + + String bpmnRequest = execution.getVariable("requestJson") + String projectName = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.project.projectName") + String serviceInstance = execution.getVariable("serviceInstanceId") + + msoLogger.debug("BPMN REQUEST IS: "+ bpmnRequest) + msoLogger.debug("PROJECT NAME: " + projectName) + msoLogger.debug("Service Instance: " + serviceInstance) + + if(projectName == null||projectName.equals("")){ + msoLogger.debug("Project Name was not found in input. Skipping task...") + }else{ + try{ + AAICreateResources aaiCR = new AAICreateResources() + aaiCR.createAAIProject(projectName, serviceInstance) + }catch(Exception ex){ + String msg = "Exception in createProject. " + ex.getMessage(); + msoLogger.debug(msg) + msoLogger.error(ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + msoLogger.trace("Exit createProject") + } + + public void createOwningEntity(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + msoLogger.trace("createOwningEntity") + String msg = ""; + String bpmnRequest = execution.getVariable("requestJson") + String owningEntityId = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.owningEntity.owningEntityId") + String owningEntityName = jsonUtil.getJsonValue(bpmnRequest,"requestDetails.owningEntity.owningEntityName"); + String serviceInstance = execution.getVariable("serviceInstanceId") + + msoLogger.debug("owningEntity: " + owningEntityId) + msoLogger.debug("OwningEntityName: "+ owningEntityName) + msoLogger.debug("Service Instance: " + serviceInstance) + + try{ + AAICreateResources aaiCR = new AAICreateResources() + if(owningEntityId==null||owningEntityId.equals("")){ + msg = "Exception in createOwningEntity. OwningEntityId is null in input."; + throw new IllegalStateException(); + }else{ + if(aaiCR.existsOwningEntity(owningEntityId)){ + aaiCR.connectOwningEntityandServiceInstance(owningEntityId,serviceInstance) + }else{ + if(owningEntityName==null||owningEntityName.equals("")){ + msg = "Exception in createOwningEntity. Can't create an owningEntity without an owningEntityName in input."; + throw new IllegalStateException(); + }else{ + Optional owningEntity = aaiCR.getOwningEntityNames(owningEntityName); + if(owningEntity.isPresent()){ + msg = "Exception in createOwningEntity. Can't create OwningEntity as name already exists in AAI associated with a different owning-entity-id (name must be unique)."; + throw new IllegalStateException(); + } else { + aaiCR.createAAIOwningEntity(owningEntityId, owningEntityName, serviceInstance) + } + } + } + } + }catch(Exception ex){ + msoLogger.debug(msg) + msoLogger.error(ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit createOwningEntity") + } + + // ******************************* + // Build Error Section + // ******************************* + + public void processJavaException(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try{ + msoLogger.debug("Caught a Java Exception in DoCreateServiceInstance") + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception in DoCreateServiceInstance") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception in DoCreateServiceInstance") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") + } + msoLogger.trace("Completed processJavaException Method in DoCreateServiceInstance") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy new file mode 100644 index 0000000000..dd56b8f2cc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.onap.so.logger.MsoLogger +import org.onap.so.logger.MessageEnum + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; +/** + * This groovy class supports the DoCreateServiceInstanceRollback.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - rollbackData with + * globalCustomerId + * subscriptionServiceType + * serviceInstanceId + * disableRollback + * rollbackAAI + * rollbackSDNC + * sdncRollbackRequest + * + * + * Outputs: + * @param - rollbackError + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * + */ +public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateServiceInstanceRollback.class); + + + String Prefix="DCRESIRB_" + + public void preProcessRequest(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + msoLogger.trace("preProcessRequest") + execution.setVariable("rollbackAAI",false) + execution.setVariable("rollbackSDNC",false) + + try { + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("RollbackData:" + rollbackData) + + if (rollbackData != null) { + if (rollbackData.hasType("SERVICEINSTANCE")) { + + def serviceInstanceId = rollbackData.get("SERVICEINSTANCE", "serviceInstanceId") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + def subscriptionServiceType = rollbackData.get("SERVICEINSTANCE", "subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + + def globalSubscriberId = rollbackData.get("SERVICEINSTANCE", "globalSubscriberId") + execution.setVariable("globalSubscriberId", globalSubscriberId) + + def rollbackAAI = rollbackData.get("SERVICEINSTANCE", "rollbackAAI") + if ("true".equals(rollbackAAI)) + { + execution.setVariable("rollbackAAI",true) + } + + def rollbackSDNC = rollbackData.get("SERVICEINSTANCE", "rollbackSDNC") + if ("true".equals(rollbackSDNC)) + { + execution.setVariable("rollbackSDNC", true) + } + + if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true) + { + execution.setVariable("skipRollback", true) + } + + def sdncDelete = rollbackData.get("SERVICEINSTANCE", "sdncDelete") + execution.setVariable("sdncDelete", sdncDelete) + def sdncDeactivate = rollbackData.get("SERVICEINSTANCE", "sdncDeactivate") + execution.setVariable("sdncDeactivate", sdncDeactivate) + msoLogger.debug("sdncDeactivate:\n" + sdncDeactivate) + msoLogger.debug("sdncDelete:\n" + sdncDelete) + } + else { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in Create ServiceInstance Rollback preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest") + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method) { + + msoLogger.trace("validateSDNCResponse") + String msg = "" + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msg = "SDNC Adapter service-instance rollback successful for " + method + msoLogger.debug(msg) + }else{ + execution.setVariable("rolledBack", false) + msg = "Error Response from SDNC Adapter service-instance rollback for " + method + execution.setVariable("rollbackError", msg) + msoLogger.debug(msg) + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in Create ServiceInstance rollback for " + method + " Exception:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit validateSDNCResponse") + } + + public void postProcessRequest(DelegateExecution execution) { + + msoLogger.trace("postProcessRequest") + String msg = "" + try { + execution.setVariable("rollbackData", null) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean rollbackAAI = execution.getVariable("rollbackAAI") + boolean rollbackSDNC = execution.getVariable("rollbackSDNC") + if (rollbackAAI || rollbackSDNC) + { + execution.setVariable("rolledBack", true) + } + if (rollbackAAI) + { + boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") + if(!succInAAI){ + execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful + execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback") + msoLogger.debug("Error deleting service-instance in AAI for rollback", + serviceInstanceId) + } + } + msoLogger.trace("Exit postProcessRequest") + + } catch (BpmnError e) { + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage() + msoLogger.debug(msg) + } catch (Exception ex) { + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() + msoLogger.debug(msg) + } + + } + + public void processRollbackException(DelegateExecution execution){ + + msoLogger.trace("processRollbackException") + try{ + msoLogger.debug("Caught an Exception in DoCreateServiceInstanceRollback") + execution.setVariable("rollbackData", null) + execution.setVariable("rollbackError", "Caught exception in ServiceInstance Create Rollback") + execution.setVariable("WorkflowException", null) + + }catch(BpmnError b){ + msoLogger.debug("BPMN Error during processRollbackExceptions Method: ") + }catch(Exception e){ + msoLogger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage()) + } + + msoLogger.debug("Exit processRollbackException") + } + + public void processRollbackJavaException(DelegateExecution execution){ + + msoLogger.trace("processRollbackJavaException") + try{ + execution.setVariable("rollbackData", null) + execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Create Rollback") + msoLogger.debug("Caught Exception in processRollbackJavaException") + + }catch(Exception e){ + msoLogger.debug("Caught Exception in processRollbackJavaException " + e.getMessage()) + } + msoLogger.trace("Exit processRollbackJavaException") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy new file mode 100644 index 0000000000..6e1a5dcb55 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.camunda.bpm.engine.runtime.Execution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.client.orchestration.AAIServiceInstanceResources +import org.onap.so.logger.MsoLogger + + +public class DoCreateServiceInstanceRollbackV2 extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateServiceInstanceRollbackV2.class); + + @Override + public void preProcessRequest(DelegateExecution execution) { + + } + + public void aaiServiceInstanceRollback (DelegateExecution execution) { + def aaiServiceInstanceRollback = execution.getVariable("aaiServiceInstanceRollback") + if(aaiServiceInstanceRollback){ + msoLogger.trace("Started aaiServiceInstanceRollback") + try{ + ServiceDecomposition serviceDecomp = execution.getVariable("ServiceDecomposition") + AAIServiceInstanceResources aaiO = new AAIServiceInstanceResources() + aaiO.deleteServiceInstance(serviceDecomp) + }catch (Exception ex) { + String msg = "Error Response from AAI for aaiServiceInstanceRollback" + execution.setVariable("rollbackError", msg) + msoLogger.debug(msg) + throw new BpmnError("MSOWorkflowException") + } + msoLogger.trace("Completed aaiServiceInstanceRollback") + }else{ + msoLogger.trace("SKIPPING A&AI ROLLBACK") + } + } + + public void rollbackError (DelegateExecution execution) { + msoLogger.trace("rollbackError") + try{ + msoLogger.debug("Caught an Exception in DoCreateServiceInstanceRollbackV2") + }catch(BpmnError b){ + msoLogger.debug("BPMN Error during rollbackError: " + b.getMessage()) + }catch(Exception e){ + msoLogger.debug("Caught Exception during rollbackError: " + e.getMessage()) + } + msoLogger.debug(" Exit processRollbackException") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy new file mode 100644 index 0000000000..8af8e6ba1b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.client.orchestration.AAIServiceInstanceResources +import org.onap.so.client.orchestration.SDNCServiceInstanceResources +import org.onap.so.logger.MsoLogger +import org.onap.so.logger.MessageEnum + +import groovy.json.* + +/** + * This groovy class supports the DoCreateServiceInstanceV2.bpmn process. + * +*/ + +public class DoCreateServiceInstanceV2 extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateServiceInstanceV2.class); + AAIServiceInstanceResources aaiO = new AAIServiceInstanceResources() + SDNCServiceInstanceResources sdncO = new SDNCServiceInstanceResources() + + @Override + public void preProcessRequest(DelegateExecution execution) { + } + + public void createServiceInstance(DelegateExecution execution) { + execution.setVariable("callSDNC",true) + if(execution.getVariable("serviceType").equalsIgnoreCase("PORT-MIRROR")== false){ + if(execution.getVariable("sdncVersion").equals("1610")){ + execution.setVariable("callSDNC",false); + } + } + ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") + try{ + aaiO.createServiceInstance(serviceDecomp) + } catch (BpmnError e) { + throw e + } + } + + public void createProject(DelegateExecution execution) { + ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") + if (serviceDecomp.getServiceInstance() != null && serviceDecomp.getProject() != null) { + try{ + aaiO.createProjectandConnectServiceInstance(serviceDecomp) + } catch (BpmnError e) { + throw e + } + } + } + + public void createOwningEntity(DelegateExecution execution) { + ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") + if (serviceDecomp.getServiceInstance() != null && serviceDecomp.getOwningEntity() != null) { + try{ + aaiO.createOwningEntityandConnectServiceInstance(serviceDecomp) + } catch (BpmnError e) { + throw e + } + } + } + + public void sdncAssignRequest(DelegateExecution execution) { + ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") + if (serviceDecomp != null) { + try { + sdncO.sendSyncResponse(serviceDecomp) + } catch (BpmnError e) { + throw e + } + } + + } + + public void rollback(DelegateExecution execution) { + //TODO + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy new file mode 100644 index 0000000000..10f6acd403 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -0,0 +1,282 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import groovy.json.* + +/** + * This groovy class supports the DoCreateVFCNetworkServiceInstance.bpmn process. + * flow for VFC Network Service Create + */ +public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVFCNetworkServiceInstance.class); + + String vfcUrl = "/vfc/rest/v1/vfcadapter" + + String host = "http://mso.mso.testlab.openecomp.org:8080" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + public void preProcessRequest (DelegateExecution execution) { + String msg = "" + msoLogger.trace("preProcessRequest()") + try { + //deal with nsName and Description + String nsServiceName = execution.getVariable("nsServiceName") + String nsServiceDescription = execution.getVariable("nsServiceDescription") + msoLogger.debug("nsServiceName:" + nsServiceName + " nsServiceDescription:" + nsServiceDescription) + //deal with operation key + String globalSubscriberId = execution.getVariable("globalSubscriberId") + msoLogger.debug("globalSubscriberId:" + globalSubscriberId) + String serviceType = execution.getVariable("serviceType") + msoLogger.debug("serviceType:" + serviceType) + String serviceId = execution.getVariable("serviceId") + msoLogger.debug("serviceId:" + serviceId) + String operationId = execution.getVariable("operationId") + msoLogger.debug("serviceType:" + serviceType) + String nodeTemplateUUID = execution.getVariable("resourceUUID") + msoLogger.debug("nodeTemplateUUID:" + nodeTemplateUUID) + /* + * segmentInformation needed as a object of segment + * { + * "domain":"", + * "nodeTemplateName":"", + * "nodeType":"", + * "nsParameters":{ + * //this is the nsParameters sent to VF-C + * } + * } + */ + String nsParameters = execution.getVariable("resourceParameters") + msoLogger.debug("nsParameters:" + nsParameters) + String nsOperationKey = """{ + "globalSubscriberId":"${globalSubscriberId}", + "serviceType":"${serviceType}", + "serviceId":"${serviceId}", + "operationId":"${operationId}", + "nodeTemplateUUID":"${nodeTemplateUUID}" + }""" + execution.setVariable("nsOperationKey", nsOperationKey); + execution.setVariable("nsParameters", nsParameters) + + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest") + } + + /** + * create NS task + */ + public void createNetworkService(DelegateExecution execution) { + msoLogger.trace("createNetworkService") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String nsParameters = execution.getVariable("nsParameters"); + String nsServiceName = execution.getVariable("nsServiceName") + String nsServiceDescription = execution.getVariable("nsServiceDescription") + String reqBody ="""{ + "nsServiceName":"${nsServiceName}", + "nsServiceDescription":"${nsServiceDescription}", + "nsOperationKey":${nsOperationKey}, + "nsParameters":${nsParameters} + }""" + APIResponse apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String nsInstanceId = ""; + if(returnCode== "200" || returnCode == "201"){ + nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId") + } + execution.setVariable("nsInstanceId", nsInstanceId) + msoLogger.trace("Exit createNetworkService") + } + + /** + * instantiate NS task + */ + public void instantiateNetworkService(DelegateExecution execution) { + msoLogger.trace("instantiateNetworkService") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String nsParameters = execution.getVariable("nsParameters"); + String nsServiceName = execution.getVariable("nsServiceName") + String nsServiceDescription = execution.getVariable("nsServiceDescription") + String reqBody ="""{ + "nsServiceName":"${nsServiceName}", + "nsServiceDescription":"${nsServiceDescription}", + "nsOperationKey":${nsOperationKey}, + "nsParameters":${nsParameters} + }""" + String nsInstanceId = execution.getVariable("nsInstanceId") + String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate" + APIResponse apiResponse = postRequest(execution, url, reqBody) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String jobId = ""; + if(returnCode== "200"|| returnCode == "201"){ + jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") + } + execution.setVariable("jobId", jobId) + msoLogger.trace("Exit instantiateNetworkService") + } + + /** + * query NS task + */ + public void queryNSProgress(DelegateExecution execution) { + msoLogger.trace("queryNSProgress") + String jobId = execution.getVariable("jobId") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String url = host + vfcUrl + "/jobs/" + jobId + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String operationStatus = "error" + if(returnCode== "200"|| returnCode == "201"){ + operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status") + } + execution.setVariable("operationStatus", operationStatus) + msoLogger.trace("Exit queryNSProgress") + } + + /** + * delay 5 sec + */ + public void timeDelay(DelegateExecution execution) { + try { + Thread.sleep(5000); + } catch(InterruptedException e) { + msoLogger.debug("Time Delay exception" + e ) + } + } + + /** + * finish NS task + */ + public void addNSRelationship(DelegateExecution execution) { + msoLogger.trace("addNSRelationship") + String nsInstanceId = execution.getVariable("nsInstanceId") + if(nsInstanceId == null || nsInstanceId == ""){ + msoLogger.debug(" create NS failed, so do not need to add relationship") + return + } + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceId = execution.getVariable("serviceId") + String addRelationPayload = """ + service-instance + /aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId} + + customer.global-customer-id + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + service-subscription.service-type + ${MsoUtils.xmlEscape(serviceType)} + + + service-instance.service-instance-id + ${MsoUtils.xmlEscape(nsInstanceId)} + + """ + String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + msoLogger.debug("Add Relationship req:\n" + addRelationPayload) + String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship" + APIResponse aaiRsp = executeAAIPutCall(execution, url, addRelationPayload) + msoLogger.debug("aai response status code:" + aaiRsp.getStatusCode()) + msoLogger.debug("aai response content:" + aaiRsp.getResponseBodyAsString()) + msoLogger.trace("Exit addNSRelationship") + } + + public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){ + msoLogger.trace("Started Execute AAI Put Process") + APIResponse apiResponse = null + try{ + String uuid = utils.getRequestID() + msoLogger.debug("Generated uuid is: " + uuid) + msoLogger.debug("URL to be used is: " + url) + String userName = UrnPropertiesReader.getVariable("aai.auth", execution) + String password = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuthCred = utils.getBasicAuth(userName,password) + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + apiResponse = client.httpPut(payload) + msoLogger.trace("Completed Execute AAI Put Process") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + + /** + * post request + * url: the url of the request + * requestBody: the body of the request + */ + private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){ + msoLogger.trace("Started Execute VFC adapter Post Process") + msoLogger.debug("url:"+url +"\nrequestBody:"+ requestBody) + APIResponse apiResponse = null + try{ + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); + apiResponse = client.httpPost(requestBody) + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.trace("Completed Execute VF-C adapter Post Process") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy new file mode 100644 index 0000000000..59d38bfe86 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -0,0 +1,2133 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.CloudFlavor +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.DecomposeJsonUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.springframework.web.util.UriUtils +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.NamedNodeMap +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + +import com.fasterxml.jackson.databind.ObjectMapper + + + +public class DoCreateVfModule extends VfModuleBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModule.class); + + String Prefix="DCVFM_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + CatalogDbUtils catalog = new CatalogDbUtils() + DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil() + + /** + * Validates the request message and sets up the workflow. + * @param execution the execution + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + execution.setVariable('prefix', Prefix) + try{ + def rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + execution.setVariable("DCVFM_vnfParamsExistFlag", false) + execution.setVariable("DCVFM_oamManagementV4Address", "") + execution.setVariable("DCVFM_oamManagementV6Address", "") + + String request = execution.getVariable("DoCreateVfModuleRequest") + + if (request == null || request.isEmpty()) { + // Building Block-type request + + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + + def serviceModelInfo = execution.getVariable("serviceModelInfo") + msoLogger.debug("serviceModelInfo: " + serviceModelInfo) + String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") + msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid) + + def vnfModelInfo = execution.getVariable("vnfModelInfo") + + //tenantId + def tenantId = execution.getVariable("tenantId") + execution.setVariable("DCVFM_tenantId", tenantId) + rollbackData.put("VFMODULE", "tenantid", tenantId) + //volumeGroupId + def volumeGroupId = execution.getVariable("volumeGroupId") + execution.setVariable("DCVFM_volumeGroupId", volumeGroupId) + //volumeGroupName + def volumeGroupName = execution.getVariable("volumeGroupName") + execution.setVariable("DCVFM_volumeGroupName", volumeGroupName) + //cloudSiteId + def cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DCVFM_cloudSiteId", cloudSiteId) + rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId) + msoLogger.debug("cloudSiteId: " + cloudSiteId) + //vnfType + def vnfType = execution.getVariable("vnfType") + execution.setVariable("DCVFM_vnfType", vnfType) + rollbackData.put("VFMODULE", "vnftype", vnfType) + msoLogger.debug("vnfType: " + vnfType) + //vnfName + def vnfName = execution.getVariable("vnfName") + execution.setVariable("DCVFM_vnfName", vnfName) + rollbackData.put("VFMODULE", "vnfname", vnfName) + msoLogger.debug("vnfName: " + vnfName) + //vnfId + def vnfId = execution.getVariable("vnfId") + execution.setVariable("DCVFM_vnfId", vnfId) + rollbackData.put("VFMODULE", "vnfid", vnfId) + msoLogger.debug("vnfId: " + vnfId) + //vfModuleName + def vfModuleName = execution.getVariable("vfModuleName") + execution.setVariable("DCVFM_vfModuleName", vfModuleName) + rollbackData.put("VFMODULE", "vfmodulename", vfModuleName) + msoLogger.debug("vfModuleName: " + vfModuleName) + //vfModuleModelName + def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") + execution.setVariable("DCVFM_vfModuleModelName", vfModuleModelName) + rollbackData.put("VFMODULE", "vfmodulemodelname", vfModuleModelName) + msoLogger.debug("vfModuleModelName: " + vfModuleModelName) + //modelCustomizationUuid + def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") + execution.setVariable("DCVFM_modelCustomizationUuid", modelCustomizationUuid) + rollbackData.put("VFMODULE", "modelcustomizationuuid", modelCustomizationUuid) + msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid) + //vfModuleId + def vfModuleId = execution.getVariable("vfModuleId") + execution.setVariable("DCVFM_vfModuleId", vfModuleId) + msoLogger.debug("vfModuleId: " + vfModuleId) + def requestId = execution.getVariable("msoRequestId") + execution.setVariable("DCVFM_requestId", requestId) + msoLogger.debug("requestId: " + requestId) + rollbackData.put("VFMODULE", "msorequestid", requestId) + // Set mso-request-id to request-id for VNF Adapter interface + execution.setVariable("mso-request-id", requestId) + //serviceId + def serviceId = execution.getVariable("serviceId") + execution.setVariable("DCVFM_serviceId", serviceId) + msoLogger.debug("serviceId: " + serviceId) + //serviceInstanceId + def serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId) + rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId) + msoLogger.debug("serviceInstanceId: " + serviceInstanceId) + //flavorList + ArrayList flavorList = execution.getVariable(cloudSiteId + "_flavorList") + if (flavorList != null) { + execution.setVariable("DCVFM_flavorList", flavorList) + logDebug("flavorList is: " + flavorList, isDebugLogEnabled) + } + //source - HARDCODED + def source = "VID" + execution.setVariable("DCVFM_source", source) + rollbackData.put("VFMODULE", "source", source) + msoLogger.debug("source: " + source) + //backoutOnFailure + def disableRollback = execution.getVariable("disableRollback") + def backoutOnFailure = true + if (disableRollback != null && disableRollback == true) { + backoutOnFailure = false + } + execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure) + msoLogger.debug("backoutOnFailure: " + backoutOnFailure) + //isBaseVfModule + def isBaseVfModule = execution.getVariable("isBaseVfModule") + execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule) + msoLogger.debug("isBaseVfModule: " + isBaseVfModule) + //asdcServiceModelVersion + def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") + execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion) + msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion) + //personaModelId + execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid")) + //personaModelVersion + execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelUuid")) + //vfModuleLabel + def vfModuleLabel = execution.getVariable("vfModuleLabel") + if (vfModuleLabel != null) { + execution.setVariable("DCVFM_vfModuleLabel", vfModuleLabel) + msoLogger.debug("vfModuleLabel: " + vfModuleLabel) + } + //Get or Generate UUID + String uuid = execution.getVariable("DCVFM_uuid") + if(uuid == null){ + uuid = UUID.randomUUID() + msoLogger.debug("Generated messageId (UUID) is: " + uuid) + }else{ + msoLogger.debug("Found messageId (UUID) is: " + uuid) + } + //isVidRequest + String isVidRequest = execution.getVariable("isVidRequest") + // default to true + if (isVidRequest == null || isVidRequest.isEmpty()) { + execution.setVariable("isVidRequest", "true") + } + //globalSubscriberId + String globalSubscriberId = execution.getVariable("globalSubscriberId") + execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId) + msoLogger.debug("globalSubsrciberId: " + globalSubscriberId) + Map vfModuleInputParams = execution.getVariable("vfModuleInputParams") + if (vfModuleInputParams != null) { + execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams) + execution.setVariable("DCVFM_vnfParamsExistFlag", true) + } + //usePreload + def usePreload = execution.getVariable("usePreload") + execution.setVariable("DCVFM_usePreload", usePreload) + msoLogger.debug("usePreload: " + usePreload) + //aLaCarte + def aLaCarte = execution.getVariable("aLaCarte") + execution.setVariable("DCVFM_aLaCarte", aLaCarte) + msoLogger.debug("aLaCarte: " + aLaCarte) + + //get workload and environment context from parent SI + String environmentContext = "" + String workloadContext ="" + String serviceType ="" + + try{ + String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + try{ + AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) + AAIResourcesClient aaiRC = new AAIResourcesClient() + AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI) + Map aaiJson = aaiRW.asMap() + environmentContext = aaiJson.getOrDefault("environment-context","") + workloadContext = aaiJson.getOrDefault("workload-context","") + + }catch (Exception ex) { + msoLogger.debug("Error retreiving parent service instance information") + } + + execution.setVariable("DCVFM_environmentContext",environmentContext) + execution.setVariable("DCVFM_workloadContext",workloadContext) + + } + else { + // The info is inside the request - DEAD CODE + msoLogger.debug("DoCreateVfModule request: " + request) + + //tenantId + def tenantId = "" + if (utils.nodeExists(request, "tenant-id")) { + tenantId = utils.getNodeText(request, "tenant-id") + } + execution.setVariable("DCVFM_tenantId", tenantId) + rollbackData.put("VFMODULE", "tenantid", tenantId) + //volumeGroupId + def volumeGroupId = "" + if (utils.nodeExists(request, "volume-group-id")) { + volumeGroupId = utils.getNodeText(request, "volume-group-id") + } + execution.setVariable("DCVFM_volumeGroupId", volumeGroupId) + //volumeGroupId + def volumeGroupName = "" + if (utils.nodeExists(request, "volume-group-name")) { + volumeGroupName = utils.getNodeText(request, "volume-group-name") + } + execution.setVariable("DCVFM_volumeGroupName", volumeGroupName) + //cloudSiteId + def cloudSiteId = "" + if (utils.nodeExists(request, "aic-cloud-region")) { + cloudSiteId = utils.getNodeText(request, "aic-cloud-region") + } + execution.setVariable("DCVFM_cloudSiteId", cloudSiteId) + rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId) + msoLogger.debug("cloudSiteId: " + cloudSiteId) + //vnfType + def vnfType = "" + if (utils.nodeExists(request, "vnf-type")) { + vnfType = utils.getNodeText(request, "vnf-type") + } + execution.setVariable("DCVFM_vnfType", vnfType) + rollbackData.put("VFMODULE", "vnftype", vnfType) + msoLogger.debug("vnfType: " + vnfType) + //vnfName + def vnfName = "" + if (utils.nodeExists(request, "vnf-name")) { + vnfName = utils.getNodeText(request, "vnf-name") + } + execution.setVariable("DCVFM_vnfName", vnfName) + rollbackData.put("VFMODULE", "vnfname", vnfName) + msoLogger.debug("vnfName: " + vnfName) + //vnfId + def vnfId = "" + if (utils.nodeExists(request, "vnf-id")) { + vnfId = utils.getNodeText(request, "vnf-id") + } + execution.setVariable("DCVFM_vnfId", vnfId) + rollbackData.put("VFMODULE", "vnfid", vnfId) + msoLogger.debug("vnfId: " + vnfId) + //vfModuleName + def vfModuleName = "" + if (utils.nodeExists(request, "vf-module-name")) { + vfModuleName = utils.getNodeText(request, "vf-module-name") + } + execution.setVariable("DCVFM_vfModuleName", vfModuleName) + rollbackData.put("VFMODULE", "vfmodulename", vfModuleName) + msoLogger.debug("vfModuleName: " + vfModuleName) + //vfModuleModelName + def vfModuleModelName = "" + if (utils.nodeExists(request, "vf-module-model-name")) { + vfModuleModelName = utils.getNodeText(request, "vf-module-model-name") + } + execution.setVariable("DCVFM_vfModuleModelName", vfModuleModelName) + rollbackData.put("VFMODULE", "vfmodulemodelname", vfModuleModelName) + msoLogger.debug("vfModuleModelName: " + vfModuleModelName) + //modelCustomizationUuid + def modelCustomizationUuid = "" + if (utils.nodeExists(request, "model-customization-id")) { + modelCustomizationUuid = utils.getNodeText(request, "model-customization-id") + } + execution.setVariable("DCVFM_modelCustomizationUuid", modelCustomizationUuid) + rollbackData.put("VFMODULE", "modelcustomizationuuid", modelCustomizationUuid) + msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid) + //vfModuleId + def vfModuleId = "" + if (utils.nodeExists(request, "vf-module-id")) { + vfModuleId = utils.getNodeText(request, "vf-module-id") + } + execution.setVariable("DCVFM_vfModuleId", vfModuleId) + msoLogger.debug("vfModuleId: " + vfModuleId) + def requestId = "" + if (utils.nodeExists(request, "request-id")) { + requestId = utils.getNodeText(request, "request-id") + } + execution.setVariable("DCVFM_requestId", requestId) + msoLogger.debug("requestId: " + requestId) + //serviceId + def serviceId = "" + if (utils.nodeExists(request, "service-id")) { + serviceId = utils.getNodeText(request, "service-id") + } + execution.setVariable("DCVFM_serviceId", serviceId) + msoLogger.debug("serviceId: " + serviceId) + //serviceInstanceId + def serviceInstanceId = "" + if (utils.nodeExists(request, "service-instance-id")) { + serviceInstanceId = utils.getNodeText(request, "service-instance-id") + } + execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId) + rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId) + msoLogger.debug("serviceInstanceId: " + serviceInstanceId) + //source + def source = "" + if (utils.nodeExists(request, "source")) { + source = utils.getNodeText(request, "source") + } + execution.setVariable("DCVFM_source", source) + rollbackData.put("VFMODULE", "source", source) + msoLogger.debug("source: " + source) + //backoutOnFailure + NetworkUtils networkUtils = new NetworkUtils() + def backoutOnFailure = networkUtils.isRollbackEnabled(execution,request) + execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure) + msoLogger.debug("backoutOnFailure: " + backoutOnFailure) + //isBaseVfModule + def isBaseVfModule = "false" + if (utils.nodeExists(request, "is-base-vf-module")) { + isBaseVfModule = utils.getNodeText(request, "is-base-vf-module") + } + execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule) + msoLogger.debug("isBaseVfModule: " + isBaseVfModule) + //asdcServiceModelVersion + def asdcServiceModelVersion = "" + if (utils.nodeExists(request, "asdc-service-model-version")) { + asdcServiceModelVersion = utils.getNodeText(request, "asdc-service-model-version") + } + execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion) + msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion) + + //personaModelId + def personaModelId = "" + if (utils.nodeExists(request, "persona-model-id")) { + personaModelId = utils.getNodeText(request, "persona-model-id") + } + execution.setVariable("DCVFM_personaModelId", personaModelId) + msoLogger.debug("personaModelId: " + personaModelId) + + //personaModelVersion + def personaModelVersion = "" + if (utils.nodeExists(request, "persona-model-version")) { + personaModelVersion = utils.getNodeText(request, "persona-model-version") + } + execution.setVariable("DCVFM_personaModelVersion", personaModelVersion) + msoLogger.debug("personaModelVersion: " + personaModelVersion) + + // Process the parameters + + String vnfParamsChildNodes = utils.getChildNodes(request, "vnf-params") + if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ + msoLogger.debug("Request contains NO VNF Params") + }else{ + msoLogger.debug("Request does contain VNF Params") + execution.setVariable("DCVFM_vnfParamsExistFlag", true) + + InputSource xmlSource = new InputSource(new StringReader(request)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document xml = docBuilder.parse(xmlSource) + //Get params, build map + Map paramsMap = new HashMap() + NodeList paramsList = xml.getElementsByTagNameNS("*", "param") + + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + String paramValue = node.getTextContent() + NamedNodeMap e = node.getAttributes() + String paramName = e.getNamedItem("name").getTextContent() + paramsMap.put(paramName, paramValue) + } + execution.setVariable("DCVFM_vnfParamsMap", paramsMap) + } + } + + //Get or Generate UUID + String uuid = execution.getVariable("DCVFM_uuid") + if(uuid == null){ + uuid = UUID.randomUUID() + msoLogger.debug("Generated messageId (UUID) is: " + uuid) + }else{ + msoLogger.debug("Found messageId (UUID) is: " + uuid) + } + // Get sdncVersion, default to empty + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "" + } + msoLogger.debug("sdncVersion: " + sdncVersion) + execution.setVariable("DCVFM_sdncVersion", sdncVersion) + + execution.setVariable("DCVFM_uuid", uuid) + execution.setVariable("DCVFM_baseVfModuleId", "") + execution.setVariable("DCVFM_baseVfModuleHeatStackId", "") + execution.setVariable("DCVFM_heatStackId", "") + execution.setVariable("DCVFM_contrailServiceInstanceFqdn", "") + execution.setVariable("DCVFM_volumeGroupStackId", "") + execution.setVariable("DCVFM_cloudRegionForVolume", "") + execution.setVariable("DCVFM_contrailNetworkPolicyFqdnList", "") + execution.setVariable("DCVFM_vnfTypeToQuery", "generic-vnf") + rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "false") + rollbackData.put("VFMODULE", "rollbackUpdateAAIVfModule", "false") + rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "false") + rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "false") + rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "false") + rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "false") + rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "false") + rollbackData.put("VFMODULE", "rollbackUpdateVnfAAI", "false") + rollbackData.put("VFMODULE", "heatstackid", "") + + String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, msg); + + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("DCVFM_sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl) + + + execution.setVariable("rollbackData", rollbackData) + }catch(BpmnError b){ + throw b + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") + } + + msoLogger.trace('Exited ' + method) + } + + /** + * Validates a workflow response. + * @param execution the execution + * @param responseVar the execution variable in which the response is stored + * @param responseCodeVar the execution variable in which the response code is stored + * @param errorResponseVar the execution variable in which the error response is stored + */ + public void validateWorkflowResponse(DelegateExecution execution, String responseVar, + String responseCodeVar, String errorResponseVar) { + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar) + } + + + /** + * Sends the empty, synchronous response back to the API Handler. + * @param execution the execution + */ + public void sendResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + sendWorkflowResponse(execution, 200, "") + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Internal Error') + } + } + + /** + * 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 + * and existing VNF's name for add-on modules + * + * @param execution The flow's execution instance. + */ + public void postProcessCreateAAIVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.getVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def createResponse = execution.getVariable('DCVFM_createVfModuleResponse') + msoLogger.debug("createVfModule Response: " + createResponse) + + def rollbackData = execution.getVariable("rollbackData") + String vnfName = utils.getNodeText(createResponse, 'vnf-name') + if (vnfName != null) { + execution.setVariable('DCVFM_vnfName', vnfName) + msoLogger.debug("vnfName retrieved from AAI is: " + vnfName) + rollbackData.put("VFMODULE", "vnfname", vnfName) + } + String vnfId = utils.getNodeText(createResponse, 'vnf-id') + execution.setVariable('DCVFM_vnfId', vnfId) + msoLogger.debug("vnfId is: " + vnfId) + String vfModuleId = utils.getNodeText(createResponse, 'vf-module-id') + execution.setVariable('DCVFM_vfModuleId', vfModuleId) + msoLogger.debug("vfModuleId is: " + vfModuleId) + String vfModuleIndex= utils.getNodeText(createResponse, 'vf-module-index') + execution.setVariable('DCVFM_vfModuleIndex', vfModuleIndex) + msoLogger.debug("vfModuleIndex is: " + vfModuleIndex) + rollbackData.put("VFMODULE", "vnfid", vnfId) + rollbackData.put("VFMODULE", "vfmoduleid", vfModuleId) + rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "true") + rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "true") + execution.setVariable("rollbackData", rollbackData) + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while postProcessing CreateAAIVfModule request:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Bad response from CreateAAIVfModule' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } + + + /** + * 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(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.getVfModule(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DCVFM_vnfId') + def vfModuleId = execution.getVariable('DCVFM_vfModuleId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + + 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'); + msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') + APIResponse response = client.httpGet() + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received generic VNF data: " + responseData) + + } + + execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + msoLogger.debug('Parsing the VNF data to find base module info') + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + def xmlVfModules= new XmlSlurper().parseText(vfModulesText) + def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} + int vfModulesSize = 0 + for (i in 0..vfModules.size()-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") + + if (isBaseVfModule == "true") { + String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id") + execution.setVariable("DCVFM_baseVfModuleId", baseModuleId) + msoLogger.debug('Received baseVfModuleId: ' + baseModuleId) + String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id") + execution.setVariable("DCVFM_baseVfModuleHeatStackId", baseModuleHeatStackId) + msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId) + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + /** + * Using the vnfId and vfModuleName provided in the inputs, + * query AAI to get the corresponding VF Module info. + * A 200 response is expected with the VF Module info in the response body, + * or a 404 response if the module does not exist yet. Will determine VF Module's + * orchestration status if one exists + * + * @param execution The flow's execution instance. + */ + public void queryAAIVfModuleForStatus(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + execution.setVariable('DCVFM_orchestrationStatus', '') + + try { + def vnfId = execution.getVariable('DCVFM_vnfId') + def vfModuleName = execution.getVariable('DCVFM_vfModuleName') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + + "/vf-modules/vf-module?vf-module-name=" + UriUtils.encode(vfModuleName, "UTF-8") + msoLogger.debug("AAI endPoint: " + endPoint) + + 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'); + msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') + APIResponse response = client.httpGet() + msoLogger.debug("createVfModule - invoking httpGet() to AAI") + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received generic VNF data: " + responseData) + + } + + execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponseCode', response.getStatusCode()) + execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponse', responseData) + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + // Retrieve VF Module info and its orchestration status; if not found, do nothing + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + msoLogger.debug('Parsing the VNF data to find orchestration status') + if (responseData != null) { + def vfModuleText = utils.getNodeXml(responseData, "vf-module") + //def xmlVfModule= new XmlSlurper().parseText(vfModuleText) + def orchestrationStatus = utils.getNodeText(vfModuleText, "orchestration-status") + execution.setVariable("DCVFM_orchestrationStatus", orchestrationStatus) + // Also retrieve vfModuleId + def vfModuleId = utils.getNodeText(vfModuleText, "vf-module-id") + execution.setVariable("DCVFM_vfModuleId", vfModuleId) + msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus) + + } + } + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) + } + } + + + public void preProcessSDNCAssignRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCAssignRequest") + def vnfId = execution.getVariable("DCVFM_vnfId") + def vfModuleId = execution.getVariable("DCVFM_vfModuleId") + def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId") + msoLogger.debug("NEW VNF ID: " + vnfId) + + try{ + + //Build SDNC Request + + def svcInstId = "" + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + svcInstId = vfModuleId + } + else { + svcInstId = serviceInstanceId + } + + String assignSDNCRequest = buildSDNCRequest(execution, svcInstId, "assign") + + assignSDNCRequest = utils.formatXml(assignSDNCRequest) + execution.setVariable("DCVFM_assignSDNCRequest", assignSDNCRequest) + msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCAssignRequest") + } + + public void preProcessSDNCGetRequest(DelegateExecution execution, String element){ + + String sdncVersion = execution.getVariable("DCVFM_sdncVersion") + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCGetRequest Process") + try{ + def serviceInstanceId = execution.getVariable('DCVFM_serviceInstanceId') + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + } + + def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") + msoLogger.debug("callbackUrl:" + callbackUrl) + + def vfModuleId = execution.getVariable('DCVFM_vfModuleId') + + def svcInstId = "" + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + svcInstId = vfModuleId + } + else { + svcInstId = serviceInstanceId + } + + def msoAction = "" + if (!sdncVersion.equals("1707")) { + msoAction = "mobility" + } + else { + msoAction = "vfmodule" + } + // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element + // in the response from GenericGetVnf + // For VF Module, in 1707 serviceOperation will be retrieved from "object-path" element + // in SDNC Assign Response + // For VF Module for older versions, serviceOperation is constructed using vfModuleId + + String serviceOperation = "" + if (element.equals("vnf")) { + def vnfQueryResponse = execution.getVariable("DCVFM_vnfQueryResponse") + serviceOperation = utils.getNodeText(vnfQueryResponse, "selflink") + msoLogger.debug("VNF - service operation: " + serviceOperation) + } + else if (element.equals("vfmodule")) { + String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") + msoLogger.debug("DCVFM_assignSDNCAdapterResponse is: \n" + response) + + if (!sdncVersion.equals("1707")) { + serviceOperation = "/VNF-API:vnfs/vnf-list/" + vfModuleId + msoLogger.debug("VF Module with sdncVersion before 1707 - service operation: " + serviceOperation) + } + else { + String data = utils.getNodeXml(response, "response-data") + msoLogger.debug("responseData: " + data) + serviceOperation = utils.getNodeText(data, "object-path") + msoLogger.debug("VF Module with sdncVersion of 1707 - service operation: " + serviceOperation) + } + } + + //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE + sleep(5000) + + String SDNCGetRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + query + ${MsoUtils.xmlEscape(serviceOperation)} + ${MsoUtils.xmlEscape(callbackUrl)} + ${MsoUtils.xmlEscape(msoAction)} + + + """ + + execution.setVariable("DCVFM_getSDNCRequest", SDNCGetRequest) + msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process") + } + + + public void preProcessVNFAdapterRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.VNFAdapterCreateVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + //def xml = execution.getVariable("DoCreateVfModuleRequest") + //msoLogger.debug('VNF REQUEST is: ' + xml) + + //Get variables + //cloudSiteId + def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId") + //tenantId + def tenantId = execution.getVariable("DCVFM_tenantId") + //vnfType + def vnfType = execution.getVariable("DCVFM_vnfType") + //vnfName + def vnfName = execution.getVariable("DCVFM_vnfName") + //vnfId + def vnfId = execution.getVariable("DCVFM_vnfId") + //vfModuleName + def vfModuleName = execution.getVariable("DCVFM_vfModuleName") + //vfModuleModelName + def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") + //vfModuleId + def vfModuleId = execution.getVariable("DCVFM_vfModuleId") + //vfModuleIndex + def vfModuleIndex = execution.getVariable("DCVFM_vfModuleIndex") + //requestId + def requestId = execution.getVariable("DCVFM_requestId") + //serviceId + def serviceId = execution.getVariable("DCVFM_serviceId") + //serviceInstanceId + def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId") + //flavorList + ArrayList flavorList = execution.getVariable("DCVFM_flavorList") + //backoutOnFailure + def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure") + //volumeGroupId + def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId") + // baseVfModuleId + def baseVfModuleId = execution.getVariable("DCVFM_baseVfModuleId") + // baseVfModuleStackId + def baseVfModuleStackId = execution.getVariable("DCVFM_baseVfModuleHeatStackId") + // asdcServiceModelVersion + def asdcServiceModelVersion = execution.getVariable("DCVFM_asdcServiceModelVersion") + //volumeGroupStackId + def volumeGroupStackId = execution.getVariable("DCVFM_volumeGroupStackId") + //modelCustomizationUuid + def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid") + //environmentContext + String environmentContext = execution.getVariable("DCVFM_environmentContext") + //workloadContext + String workloadContext = execution.getVariable("DCVFM_workloadContext") + msoLogger.debug("workloadContext: " + workloadContext) + msoLogger.debug("environmentContext: " + environmentContext) + + def messageId = execution.getVariable('mso-request-id') + '-' + + System.currentTimeMillis() + + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + + msoLogger.debug("notificationUrl: " + notificationUrl) + msoLogger.debug("QualifiedHostName: " + useQualifiedHostName) + + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + Map vnfParamsMap = execution.getVariable("DCVFM_vnfParamsMap") + // Add flavorLabel List to vnfParamsMap + flavorList.each { cloudFlavor -> + vnfParamsMap.put("label_" + cloudFlavor.getFlavorLabel(), cloudFlavor.getFlavor()) + } + String vfModuleParams = "" + //Get SDNC Response Data for VF Module Topology + String vfModuleSdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse') + msoLogger.debug("sdncGetResponse: " + vfModuleSdncGetResponse) + def sdncVersion = execution.getVariable("sdncVersion") + + if (!sdncVersion.equals("1707")) { + + vfModuleParams = buildVfModuleParams(vnfParamsMap, vfModuleSdncGetResponse, vnfId, vnfName, + vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) + } + else { + //Get SDNC Response Data for Vnf Topology + String vnfSdncGetResponse = execution.getVariable('DCVFM_getVnfSDNCAdapterResponse') + msoLogger.debug("vnfSdncGetResponse: " + vnfSdncGetResponse) + + vfModuleParams = buildVfModuleParamsFromCombinedTopologies(vnfParamsMap, vnfSdncGetResponse, vfModuleSdncGetResponse, vnfId, vnfName, + vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) + } + + def svcInstId = "" + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + svcInstId = serviceId + } + else { + svcInstId = serviceInstanceId + } + + def createVnfARequest = """ + + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(asdcServiceModelVersion)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupStackId)} + ${MsoUtils.xmlEscape(baseVfModuleId)} + ${MsoUtils.xmlEscape(baseVfModuleStackId)} + true + ${MsoUtils.xmlEscape(backoutOnFailure)} + true + + ${vfModuleParams} + + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(svcInstId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + """ + + msoLogger.debug("Create VfModule Request to VNF Adapter: " + createVnfARequest) + execution.setVariable("DCVFM_createVnfARequest", createVnfARequest) + } + + /** + * Validates the request, request id and service instance id. If a problem is found, + * a WorkflowException is generated and an MSOWorkflowException event is thrown. This + * method also sets up the log context for the workflow. + * @param execution the execution + * @return the validated request + */ + public String validateInfraRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateInfraRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + String processKey = getProcessKey(execution); + def prefix = execution.getVariable("prefix") + + if (prefix == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null") + } + + try { + def request = execution.getVariable(prefix + 'Request') + + if (request == null) { + request = execution.getVariable(processKey + 'Request') + + if (request == null) { + request = execution.getVariable('bpmnRequest') + } + + setVariable(execution, processKey + 'Request', null); + setVariable(execution, 'bpmnRequest', null); + setVariable(execution, prefix + 'Request', request); + } + + if (request == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null") + } + msoLogger.debug("DoCreateVfModule Request: " + request) + + /* + + def requestId = execution.getVariable("mso-request-id") + + if (requestId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") + } + + def serviceInstanceId = execution.getVariable("mso-service-instance-id") + + if (serviceInstanceId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") + } + + utils.logContext(requestId, serviceInstanceId) + */ + msoLogger.debug('Incoming message: ' + System.lineSeparator() + request) + msoLogger.trace('Exited ' + method) + return request + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") + } + } + + public boolean isVolumeGroupIdPresent(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.isVolumeGroupIdPresent(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def request = execution.getVariable('DoCreateVfModuleRequest') + String volumeGroupId = utils.getNodeText(request, "volume-group-id") + if (volumeGroupId == null || volumeGroupId.isEmpty()) { + msoLogger.debug('No volume group id is present') + return false + } + else { + msoLogger.debug('Volume group id is present') + return true + } + + } + + public boolean isVolumeGroupNamePresent(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.isVolumeGroupNamePresent(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def request = execution.getVariable('DoCreateVfModuleRequest') + String volumeGroupName = utils.getNodeText(request, "volume-group-name") + if (volumeGroupName == null || volumeGroupName.isEmpty()) { + msoLogger.debug('No volume group name is present') + return false + } + else { + msoLogger.debug('Volume group name is present') + return true + } + + } + + public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("DCVFM_sdncCallbackUrl") + def requestId = execution.getVariable("DCVFM_requestId") + def serviceId = execution.getVariable("DCVFM_serviceId") + def vnfType = execution.getVariable("DCVFM_vnfType") + def vnfName = execution.getVariable("DCVFM_vnfName") + def tenantId = execution.getVariable("DCVFM_tenantId") + def source = execution.getVariable("DCVFM_source") + def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure") + def vfModuleId = execution.getVariable("DCVFM_vfModuleId") + def vfModuleName = execution.getVariable("DCVFM_vfModuleName") + def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") + def vnfId = execution.getVariable("DCVFM_vnfId") + def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId") + def sdncVersion = execution.getVariable("DCVFM_sdncVersion") + def serviceModelInfo = execution.getVariable("serviceModelInfo") + def vnfModelInfo = execution.getVariable("vnfModelInfo") + def vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) + String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) + String vfModuleEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vfModuleModelInfo) + def globalSubscriberId = execution.getVariable("DCVFM_globalSubscriberId") + boolean usePreload = execution.getVariable("DCVFM_usePreload") + String usePreloadToSDNC = usePreload ? "Y" : "N" + def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid") + def modelCustomizationUuidString = "" + if (!usePreload) { + modelCustomizationUuidString = "" + modelCustomizationUuid + "" + } + + String sdncVNFParamsXml = "" + + if(execution.getVariable("DCVFM_vnfParamsExistFlag") == true){ + if (!sdncVersion.equals("1707")) { + sdncVNFParamsXml = buildSDNCParamsXml(execution) + } + else { + sdncVNFParamsXml = buildCompleteSDNCParamsXml(execution) + } + }else{ + sdncVNFParamsXml = "" + } + + String sdncRequest = "" + + if (!sdncVersion.equals("1707")) { + + sdncRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + + + + ${MsoUtils.xmlEscape(requestId)} + VNFActivateRequest + ${MsoUtils.xmlEscape(source)} + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(svcInstId)} + notsurewecare + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + ${modelCustomizationUuidString} + ${MsoUtils.xmlEscape(usePreloadToSDNC)} + ${sdncVNFParamsXml} + + + """ + + } + else { + + sdncRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vf-module-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + generic-resource + + + + ${MsoUtils.xmlEscape(requestId)} + CreateVfModuleInstance + ${MsoUtils.xmlEscape(source)} + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${serviceEcompModelInformation} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfType)} + ${vnfEcompModelInformation} + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${vfModuleEcompModelInformation} + + + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(cloudSiteId)} + ${sdncVNFParamsXml} + + + """ + + + /* + sdncRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + + + + ${MsoUtils.xmlEscape(requestId)} + CreateVfModuleInstance + ${MsoUtils.xmlEscape(source)} + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${serviceEcompModelInformation} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfType)} + ${vnfEcompModelInformation} + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${vfModuleEcompModelInformation} + + + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(cloudSiteId)} + ${sdncVNFParamsXml} + + + """ + */ + + } + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + + } + + public void preProcessSDNCActivateRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCActivateRequest Process") + try{ + String vnfId = execution.getVariable("DCVFM_vnfId") + String vfModuleId = execution.getVariable("DCVFM_vfModuleId") + String serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId") + + def svcInstId = "" + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + svcInstId = vfModuleId + } + else { + svcInstId = serviceInstanceId + } + String activateSDNCRequest = buildSDNCRequest(execution, svcInstId, "activate") + + execution.setVariable("DCVFM_activateSDNCRequest", activateSDNCRequest) + msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) + + }catch(Exception e){ + msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process") + } + + public void postProcessVNFAdapterRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("STARTED postProcessVNFAdapterRequest Process") + + String vnfResponse = execution.getVariable("DCVFM_createVnfAResponse") + msoLogger.debug("VNF Adapter Response is: " + vnfResponse) + + RollbackData rollbackData = execution.getVariable("rollbackData") + if(vnfResponse != null){ + + if(vnfResponse.contains("createVfModuleResponse")){ + msoLogger.debug("Received a Good Response from VNF Adapter for CREATE_VF_MODULE Call.") + execution.setVariable("DCVFM_vnfVfModuleCreateCompleted", true) + String heatStackId = utils.getNodeText(vnfResponse, "vfModuleStackId") + execution.setVariable("DCVFM_heatStackId", heatStackId) + msoLogger.debug("Received heat stack id from VNF Adapter: " + heatStackId) + rollbackData.put("VFMODULE", "heatstackid", heatStackId) + // Parse vnfOutputs for network_fqdn + 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.equals("contrail-service-instance-fqdn")) { + String contrailServiceInstanceFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + msoLogger.debug("Obtained contrailServiceInstanceFqdn: " + contrailServiceInstanceFqdn) + execution.setVariable("DCVFM_contrailServiceInstanceFqdn", contrailServiceInstanceFqdn) + } + else if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) + execution.setVariable("DCVFM_oamManagementV4Address", oamManagementV4Address) + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) + execution.setVariable("DCVFM_oamManagementV6Address", oamManagementV6Address) + } + + } + } + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + execution.setVariable("DCVFM_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) + } + } + }else{ + msoLogger.debug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + }else{ + msoLogger.debug("Response from VNF Adapter is Null for CREATE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") + } + + rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "true") + execution.setVariable("rollbackData", rollbackData) + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + msoLogger.debug("Internal Error Occured in PostProcess Method") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") + } + msoLogger.trace("COMPLETED postProcessVnfAdapterResponse Process") + } + + + public void preProcessUpdateAAIVfModuleRequestOrch(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestOrch(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestOrch") + + try{ + + //Build UpdateAAIVfModule Request + boolean setContrailServiceInstanceFqdn = false + def contrailServiceInstanceFqdn = execution.getVariable("DCVFM_contrailServiceInstanceFqdn") + if (!contrailServiceInstanceFqdn.equals("")) { + setContrailServiceInstanceFqdn = true + } + + execution.setVariable("DCVFM_orchestrationStatus", "Created") + + String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, true, setContrailServiceInstanceFqdn) + + updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) + execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest) + msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestOrch Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestOrch") + + } + + public void preProcessUpdateAAIVfModuleRequestStatus(DelegateExecution execution, String status) { + def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleStatus(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessUpdateAAIVfModuleStatus") + + try{ + + //Build UpdateAAIVfModule Request + execution.setVariable("DCVFM_orchestrationStatus", status) + + String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, false, false) + + updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) + execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest) + msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleStatus", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleStatus") + + } + + + public void preProcessUpdateAAIVfModuleRequestGroup(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestGroup(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestGroup") + + try{ + + //Build UpdateAAIVfModule Request + + String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, true, false, false, false) + + updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) + execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest) + msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestGroup Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestGroup") + + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + + execution.setVariable("prefix",Prefix) + msoLogger.debug("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + RollbackData rollbackData = execution.getVariable("rollbackData") + + if(method.equals("assign")){ + rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "true") + execution.setVariable("CRTGVNF_sdncAssignCompleted", true) + } + else if (method.equals("activate")) { + rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "true") + } + execution.setVariable("rollbackData", rollbackData) + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.trace("COMPLETED ValidateSDNCResponse Process") + } + + public void preProcessUpdateAfterCreateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessRequest Process") + try{ + String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") + msoLogger.debug("DCVFM_assignSDNCAdapterResponse: " + response) + + String data = utils.getNodeXml(response, "response-data") + String vnfId = utils.getNodeText(data, "vnf-id") + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + } + + String serviceOperation = "/VNF-API:vnfs/vnf-list/" + vnfId + def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") + msoLogger.debug("callbackUrl: " + callbackUrl) + + String SDNCGetRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + query + ${MsoUtils.xmlEscape(serviceOperation)} + ${MsoUtils.xmlEscape(callbackUrl)} + mobility + + + """ + + execution.setVariable("DCVFM_getSDNCRequest", SDNCGetRequest) + msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process") + } + + public String buildUpdateAAIVfModuleRequest(DelegateExecution execution, boolean updateVolumeGroupId, + boolean updateOrchestrationStatus, boolean updateHeatStackId, boolean updateContrailFqdn){ + + def vnfId = execution.getVariable("DCVFM_vnfId") + def vfModuleId = execution.getVariable("DCVFM_vfModuleId") + def volumeGroupIdString = "" + if (updateVolumeGroupId) { + volumeGroupIdString = "" + execution.getVariable("DCVFM_volumeGroupId") + + "" + } + def orchestrationStatusString = "" + if (updateOrchestrationStatus) { + orchestrationStatusString = "" + execution.getVariable("DCVFM_orchestrationStatus") + "" + } + def heatStackIdString = "" + if (updateHeatStackId) { + heatStackIdString = "" + execution.getVariable("DCVFM_heatStackId") + "" + } + def contrailFqdnString = "" + if (updateContrailFqdn) { + contrailFqdnString = "" + execution.getVariable("DCVFM_contrailServiceInstanceFqdn") + + "" + } + + String updateAAIVfModuleRequest = + """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${heatStackIdString} + ${orchestrationStatusString} + ${volumeGroupIdString} + ${contrailFqdnString} + """ + + msoLogger.trace("updateAAIVfModule Request: " + updateAAIVfModuleRequest) + return updateAAIVfModuleRequest + + } + + public String buildSDNCParamsXml(DelegateExecution execution){ + + String params = "" + StringBuilder sb = new StringBuilder() + Map paramsMap = execution.getVariable("DCVFM_vnfParamsMap") + + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String key = entry.getKey(); + if(key.endsWith("_network")){ + String requestKey = key.substring(0, key.indexOf("_network")) + String requestValue = entry.getValue() + paramsXml = +""" + { functx:substring-before-match(data($param/@name), '_network') } + { $param/text() } +""" + }else{ + paramsXml = "" + } + params = sb.append(paramsXml) + } + return params + } + + public String buildCompleteSDNCParamsXml(DelegateExecution execution){ + + String params = "" + StringBuilder sb = new StringBuilder() + Map paramsMap = execution.getVariable("DCVFM_vnfParamsMap") + + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String key = entry.getKey(); + String value = entry.getValue() + paramsXml = """<${key}>$value""" + params = sb.append(paramsXml) + } + return params + } + + public void queryCloudRegion (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED queryCloudRegion") + + try { + String cloudRegion = execution.getVariable("DCVFM_cloudSiteId") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + execution.setVariable("DCVFM_queryCloudRegionRequest", queryCloudRegionRequest) + msoLogger.debug("DCVFM_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) + + cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + + if ((cloudRegion != "ERROR")) { + if(execution.getVariable("DCVFM_queryCloudRegionReturnCode") == "404"){ + execution.setVariable("DCVFM_cloudRegionForVolume", "AAIAIC25") + }else{ + execution.setVariable("DCVFM_cloudRegionForVolume", cloudRegion) + } + execution.setVariable("DCVFM_isCloudRegionGood", true) + } else { + String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable("DCVFM_queryCloudRegionReturnCode") + msoLogger.debug(errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + execution.setVariable("DCVFM_isCloudRegionGood", false) + } + msoLogger.debug(" is Cloud Region Good: " + execution.getVariable("DCVFM_isCloudRegionGood")) + + } catch(BpmnError b){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + b.getMessage()); + throw b + }catch (Exception ex) { + // try error + String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + ex.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI Query Cloud Region Failed "+errorMessage, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during queryCloudRegion method") + } + } + + /** + * + *This method occurs when an MSOWorkflowException is caught. It logs the + *variables and ensures that the "WorkflowException" Variable is set. + * + */ + public void processBPMNException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a BPMN Exception") + msoLogger.debug("Started processBPMNException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + if(execution.getVariable("WorkflowException") == null){ + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during DoCreateVfModule Sub Process") + } + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processBPMNException Method: " + e) + } + msoLogger.debug("Completed processBPMNException Method") + } + + public void prepareCreateAAIVfModuleVolumeGroupRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepareCreateAAIVfModuleVolumeGroupRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED prepareCreateAAIVfModuleVolumeGroupRequest") + + try{ + + //Build CreateAAIVfModuleVolumeGroup Request + + def vnfId = execution.getVariable("DCVFM_vnfId") + def vfModuleId = execution.getVariable("DCVFM_vfModuleId") + def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId") + //def aicCloudRegion = execution.getVariable("DCVFM_cloudSiteId") + def aicCloudRegion = execution.getVariable("DCVFM_cloudRegionForVolume") + String createAAIVfModuleVolumeGroupRequest = + """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(aicCloudRegion)} + """ + + createAAIVfModuleVolumeGroupRequest = utils.formatXml(createAAIVfModuleVolumeGroupRequest) + execution.setVariable("DCVFM_createAAIVfModuleVolumeGroupRequest", createAAIVfModuleVolumeGroupRequest) + msoLogger.debug("Outgoing CreateAAIVfModuleVolumeGroupRequest is: \n" + createAAIVfModuleVolumeGroupRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Exception Occured Processing prepareCreateAAIVfModuleVolumeGroupRequest', "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareCreateAAIVfModuleVolumeGroupRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED prepareCreateAAIVfModuleVolumeGroupRequest") + + } + + public void createNetworkPoliciesInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.createNetworkPoliciesInAAI(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED createNetworkPoliciesInAAI") + + try { + // get variables + List fqdnList = execution.getVariable("DCVFM_contrailNetworkPolicyFqdnList") + int fqdnCount = fqdnList.size() + def rollbackData = execution.getVariable("rollbackData") + + execution.setVariable("DCVFM_networkPolicyFqdnCount", fqdnCount) + msoLogger.debug("DCVFM_networkPolicyFqdnCount - " + fqdnCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) + + if (fqdnCount > 0) { + + // AII loop call over contrail network policy fqdn list + for (i in 0..fqdnCount-1) { + + int counting = i+1 + String fqdn = fqdnList[i] + + // Query AAI for this network policy FQDN + + String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") + + def aaiRequestId = UUID.randomUUID().toString() + RESTConfig config = new RESTConfig(queryNetworkPolicyByFqdnAAIRequest); + RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId) + .addHeader("X-FromAppId", "MSO") + .addHeader("Content-Type", "application/xml") + .addHeader("Accept","application/xml"); + APIResponse response = client.get() + int returnCode = response.getStatusCode() + execution.setVariable("DCVFM_aaiQqueryNetworkPolicyByFqdnReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (isOneOf(returnCode, 200, 201)) { + msoLogger.debug("The return code is: " + returnCode) + // This network policy FQDN already exists in AAI + execution.setVariable("DCVFM_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) + + } else { + if (returnCode == 404) { + // This network policy FQDN is not in AAI yet. Add it now + msoLogger.debug("The return code is: " + returnCode) + msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn) + // Add the network policy with this FQDN to AAI + def networkPolicyId = UUID.randomUUID().toString() + msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId) + + String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + msoLogger.debug('AAI namespace is: ' + aaiNamespace) + String payload = """ + ${MsoUtils.xmlEscape(networkPolicyId)} + ${MsoUtils.xmlEscape(fqdn)} + ${MsoUtils.xmlEscape(execution.getVariable("DCVFM_heatStackId"))} + """ as String + + execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload) + + String addNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest) + + def aaiRequestIdPut = UUID.randomUUID().toString() + RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest); + RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut) + .addHeader("X-FromAppId", "MSO") + .addHeader("Content-Type", "application/xml") + .addHeader("Accept","application/xml"); + msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) + APIResponse responsePut = clientPut.httpPut(payload) + int returnCodePut = responsePut.getStatusCode() + execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut) + msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut) + + String aaiResponseAsStringPut = responsePut.getResponseBodyAsString() + if (isOneOf(returnCodePut, 200, 201)) { + msoLogger.debug("The return code from adding network policy is: " + returnCodePut) + // This network policy was created in AAI successfully + execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut) + msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut) + rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") + rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) + execution.setVariable("rollbackData", rollbackData) + + } else { + // aai all errors + String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut + msoLogger.debug(putErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage) + } + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from createNetworkPoliciesInAAI - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + + } else { + msoLogger.debug("No contrail network policies to query/create") + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateVfModule flow. createNetworkPoliciesInAAI() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def rollbackData = execution.getVariable("rollbackData") + def vnfId = execution.getVariable('DCVFM_vnfId') + def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address") + def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address") + def ipv4OamAddressElement = '' + def managementV6AddressElement = '' + + if (oamManagementV4Address != null && !oamManagementV4Address.isEmpty()) { + ipv4OamAddressElement = '' + oamManagementV4Address + '' + } + + if (oamManagementV6Address != null && !oamManagementV6Address.isEmpty()) { + managementV6AddressElement = '' + oamManagementV6Address + '' + } + + rollbackData.put("VFMODULE", "oamManagementV4Address", oamManagementV4Address) + + + String updateAAIGenericVnfRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${ipv4OamAddressElement} + ${managementV6AddressElement} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DCVM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered in " + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Post process a result from invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void postProcessUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def rollbackData = execution.getVariable("rollbackData") + + rollbackData.put("VFMODULE", "rollbackUpdateVnfAAI", "true") + + def vnfId = execution.getVariable('DCVFM_vnfId') + def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address") + def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address") + def ipv4OamAddressElement = '' + def managementV6AddressElement = '' + + if (oamManagementV4Address != null && !oamManagementV4Address.isEmpty()) { + rollbackData.put("VFMODULE", "oamManagementV4Address", oamManagementV4Address) + } + + if (oamManagementV6Address != null && !oamManagementV6Address.isEmpty()) { + rollbackData.put("VFMODULE", "oamManagementV6Address", oamManagementV6Address) + } + + execution.setVariable("rollbackData", rollbackData) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + public void queryCatalogDB (DelegateExecution execution) { + + String msg = "" + msoLogger.trace("queryCatalogDB ") + + try { + boolean twoPhaseDesign = false + // check for input + + String vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") + msoLogger.debug("vfModuleModelName: " + vfModuleModelName) + def vnfModelInfo = execution.getVariable("vnfModelInfo") + def vnfModelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") + + msoLogger.debug("vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) + + JSONArray vnfs = catalog.getAllVnfsByVnfModelCustomizationUuid(execution, vnfModelCustomizationUuid, "v2") + + msoLogger.debug("Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid) + // Only one match here + if (vnfs != null) { + JSONObject vnfObject = vnfs.get(0) + if (vnfObject != null) { + String vnfJson = vnfObject.toString() + // + ObjectMapper om = new ObjectMapper(); + VnfResource vnf = om.readValue(vnfJson, VnfResource.class); + + // Get multiStageDesign flag + + String multiStageDesignValue = vnf.getMultiStageDesign() + msoLogger.debug("multiStageDesign value from Catalog DB is: " + multiStageDesignValue) + if (multiStageDesignValue != null) { + if (multiStageDesignValue.equalsIgnoreCase("true")) { + twoPhaseDesign = true + } + } + } + } + + msoLogger.debug("setting twoPhaseDesign flag to: " + twoPhaseDesign) + + execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in queryCatalogDB', "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryCatalogDB(): ' + e.getMessage()) + } + } + + + public void preProcessRollback (DelegateExecution execution) { + + msoLogger.trace("preProcessRollback") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit preProcessRollback") + } + + public void postProcessRollback (DelegateExecution execution) { + + msoLogger.trace("postProcessRollback") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit postProcessRollback") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy new file mode 100644 index 0000000000..a0b7dabb32 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -0,0 +1,666 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + + + +public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleRollback.class); + + def Prefix="DCVFMR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + } + + // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids + // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest + public void preProcessRequest(DelegateExecution execution) { + + + initProcessVariables(execution) + + try { + + execution.setVariable("rolledBack", null) + execution.setVariable("rollbackError", null) + + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("RollbackData:" + rollbackData) + + 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) + msoLogger.debug("got fqdn # " + i + ": " + fqdn) + 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 = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + pending-delete + """ as String + msoLogger.debug("PrepareUpdateAAIVfModuleRequest :" + 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() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + // build a SDNC vnf-topology-operation request for the specified action + // (note: the action passed is expected to be 'changedelete' or 'delete') + public void prepSDNCAdapterRequest(DelegateExecution execution) { + + 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 = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + + String source = execution.getVariable("DCVFMR_source") + String serviceId = execution.getVariable("DCVFMR_serviceId") + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vnfType = execution.getVariable("DCVFMR_vnfType") + String vnfName = execution.getVariable("DCVFMR_vnfName") + String tenantId = execution.getVariable("DCVFMR_tenantId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + String vfModuleName = execution.getVariable("DCVFMR_vfModuleName") + String vfModuleModelName = execution.getVariable("DCVFMR_vfModuleModelName") + String cloudSiteId = execution.getVariable("DCVFMR_cloudSiteId") + String requestId = execution.getVariable("DCVFMR_requestId") + + String serviceInstanceIdToSdnc = "" + if (srvInstId != null && !srvInstId.isEmpty()) { + serviceInstanceIdToSdnc = srvInstId + } else { + serviceInstanceIdToSdnc = vfModuleId + } + + def doSDNCActivateRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestActivate") + def doSDNCAssignRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") + + def action = "" + def requestAction = "" + + if (doSDNCActivateRollback.equals("true")) { + action = "delete" + requestAction = "DisconnectVNFRequest" + } + else if (doSDNCAssignRollback.equals("true")) { + action = "rollback" + requestAction = "VNFActivateRequest" + } + else + return + + + String request = """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(requestAction)} + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceInstanceIdToSdnc)} + notsurewecare + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + + + """ + + msoLogger.debug("sdncAdapterWorkflowRequest: " + request) + execution.setVariable("sdncAdapterWorkflowRequest", request) + } + + public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCDeactivateRequest") + + 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) + msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCDeactivateRequest") + } + + public void preProcessSDNCUnassignRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process") + try{ + String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest) + msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCUnassignRequest Process") + } + + public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() + } + def callbackURL = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + 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 = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vf-module-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + generic-resource + + + + ${MsoUtils.xmlEscape(requestId)} + DeleteVfModuleInstance + ${MsoUtils.xmlEscape(source)} + + + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + + + ${MsoUtils.xmlEscape(vnfId)} + + + + ${MsoUtils.xmlEscape(vfModuleId)} + + + + """ + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(DelegateExecution execution) { + + String requestId = UUID.randomUUID().toString() + String origRequestId = execution.getVariable("DCVFMR_requestId") + String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") + String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId") + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId") + String tenantId = execution.getVariable("DCVFMR_tenantId") + def messageId = execution.getVariable('mso-request-id') + '-' + + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ + + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleStackId)} + true + + ${MsoUtils.xmlEscape(origRequestId)} + ${MsoUtils.xmlEscape(srvInstId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ as String + + msoLogger.debug("vnfAdapterRestV1Request: " + request) + execution.setVariable("vnfAdapterRestV1Request", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing UpdateAAIVfModuleRequest request + public void prepUpdateAAIVfModule(DelegateExecution execution) { + + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + DELETE + deleted + """ as String + msoLogger.debug("UpdateAAIVfModuleRequest :" + request) + execution.setVariable("UpdateAAIVfModuleRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing UpdateAAIVfModuleRequest request + public void prepUpdateAAIVfModuleToAssigned(DelegateExecution execution) { + + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + + Assigned + """ as String + msoLogger.debug("UpdateAAIVfModuleRequest :" + request) + execution.setVariable("UpdateAAIVfModuleRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(DelegateExecution execution) { + + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + """ as String + msoLogger.debug("DeleteAAIVfModuleRequest :" + request) + execution.setVariable("DeleteAAIVfModuleRequest", request) + } + + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf"+ execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError); + String processKey = getProcessKey(execution); + exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule") + + } + + public void sdncValidateResponse(DelegateExecution execution, String response){ + + execution.setVariable("prefix",Prefix) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Successfully Validated SDNC Response") + }else{ + throw new BpmnError("MSOWorkflowException") + } + } + + public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED deleteNetworkPoliciesFromAAI") + + try { + // get variables + List fqdnList = execution.getVariable(Prefix + "createdNetworkPolicyFqdnList") + if (fqdnList == null) { + msoLogger.debug("No network policies to delete") + return + } + int fqdnCount = fqdnList.size() + + execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount) + msoLogger.debug("networkPolicyFqdnCount - " + fqdnCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) + + if (fqdnCount > 0) { + // AII loop call over contrail network policy fqdn list + 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") + msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) + + def aaiRequestId = UUID.randomUUID().toString() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) + int returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) + msoLogger.debug("AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (isOneOf(returnCode, 200, 201)) { + msoLogger.debug("The return code is: " + returnCode) + // This network policy FQDN exists in AAI - need to delete it now + execution.setVariable(Prefix + "queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) + msoLogger.debug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) + // Retrieve the network policy id for this FQDN + def networkPolicyId = utils.getNodeText(aaiResponseAsString, "network-policy-id") + msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId) + + // Retrieve the resource version for this network policy + def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") + msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) + + String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) + + def aaiRequestIdDel = UUID.randomUUID().toString() + msoLogger.debug("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest) + + APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest) + + int returnCodeDel = responseDel.getStatusCode() + execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", returnCodeDel) + msoLogger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel) + + if (isOneOf(returnCodeDel, 200, 201, 204)) { + msoLogger.debug("The return code from deleting network policy is: " + returnCodeDel) + // This network policy was deleted from AAI successfully + msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ") + + } else { + // aai all errors + String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel + msoLogger.debug(delErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) + } + } else if (returnCode == 404) { + // This network policy FQDN is not in AAI. No need to delete. + msoLogger.debug("The return code is: " + returnCode) + msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn) + } 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 + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + + + + } // end loop + + + } else { + msoLogger.debug("No contrail network policies to query/create") + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateVfModuleRollback flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void preProcessUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessUpdateAAIGenericVnf((' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DCVFMR_vnfId') + def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') + def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') + def ipv4OamAddressElement = '' + def managementV6AddressElement = '' + + if (oamManagementV4Address != null) { + ipv4OamAddressElement = '' + 'DELETE' + '' + } + + if (oamManagementV6Address != null) { + managementV6AddressElement = '' + 'DELETE' + '' + } + + + String updateAAIGenericVnfRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${ipv4OamAddressElement} + ${managementV6AddressElement} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage()) + } + } + + public void setSuccessfulRollbackStatus (DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED setSuccessfulRollbackStatus") + + try{ + // Set rolledBack to true, rollbackError to null + execution.setVariable("rolledBack", true) + execution.setVariable("rollbackError", null) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setSuccessfulRollbackStatus.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED setSuccessfulRollbackStatus") + } + + public void setFailedRollbackStatus (DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED setFailedRollbackStatus") + + 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){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setFailedRollbackStatus.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED setFailedRollbackStatus") + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy new file mode 100644 index 0000000000..5995b6b099 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy @@ -0,0 +1,242 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils +import org.onap.so.logger.MsoLogger +import org.onap.so.logger.MessageEnum + + +public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeRollback.class); + + String Prefix="DCVFMODVOLRBK_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the DoCreateVfModuleVolumeRollback.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution 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 (DelegateExecution 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(DelegateExecution execution, isDebugEnabled) { + + def volumeGroupName = execution.getVariable('DCVFMODVOLRBK_volumeGroupName') + def cloudRegion = execution.getVariable('DCVFMODVOLRBK_lcpCloudRegionId') + + // This is for stub testing + def testVolumeGroupName = execution.getVariable('test-volume-group-name') + if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) { + volumeGroupName = testVolumeGroupName + } + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8') + + msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query volume group by name return code: " + returnCode) + msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString) + + 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) + msoLogger.debug("Volume Group Name $volumeGroupName exists in AAI.") + } else { + if (returnCode=='404') { + msoLogger.debug("Volume Group Name $volumeGroupName does not exist in AAI.") + 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(DelegateExecution execution, isDebugEnabled) { + + callRESTQueryAAIVolGrpName(execution, isDebugEnabled) + + def queryAaiVolumeGroupResponse = execution.getVariable(prefix+'queryAAIVolGrpNameResponse') + + def volumeGroupId = utils.getNodeText(queryAaiVolumeGroupResponse, "volume-group-id") + def resourceVersion = utils.getNodeText(queryAaiVolumeGroupResponse, "resource-version") + + def cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId") + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group" + '/' + volumeGroupId + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + + msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) + + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI delete volume group return code: " + returnCode) + msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + def volumeGroupNameFound = prefix+'volumeGroupNameFound' + if (returnCode=='200' || returnCode=='204' ) { + msoLogger.debug("Volume group $volumeGroupId deleted.") + } 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(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + try{ + msoLogger.debug("Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.debug("Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy new file mode 100644 index 0000000000..f734ffb3ff --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy @@ -0,0 +1,616 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.VfModuleBase; +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +class DoCreateVfModuleVolumeV2 extends VfModuleBase { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeV2.class); + String prefix='DCVFMODVOLV2_' + JsonUtils jsonUtil = new JsonUtils() + + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * * @param execution + */ + public void preProcessRequest(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + public void preProcessRequest(DelegateExecution 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) + msoLogger.debug("modelCustomizationId: " + modelCustomizationUuid) + + //modelName + def modelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") + execution.setVariable("modelName", modelName) + msoLogger.debug("modelName: " + modelName) + + // 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(DelegateExecution 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'] + + msoLogger.debug('Begin input: ') + input.each { + msoLogger.debug(it + ': ' + execution.getVariable(it)) + } + msoLogger.debug('End input.') + } + + + /** + * Define and set rollbackdata object + * @param execution + * @param isDebugEnabled + */ + public void setRollbackData(DelegateExecution 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(DelegateExecution execution, isDebugEnabled) { + def found = execution.getVariable('GENGS_FoundIndicator') + def success = execution.getVariable('GENGS_SuccessIndicator') + def serviceInstanceId = execution.getVariable('serviceInstanceId') + msoLogger.debug("getServiceInstance success: " + success) + msoLogger.debug("getServiceInstance found: " + found) + if(!found || !success) { + String errorMessage = "Service instance id not found in AAI: ${serviceInstanceId}." + msoLogger.debug(errorMessage) + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + + } + + /** + * Get cloud region + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) { + + def cloudRegion = execution.getVariable("lcpCloudRegionId") + msoLogger.debug('Request cloud region is: ' + cloudRegion) + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion + + msoLogger.debug(queryCloudRegionRequest) + + cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + + def aaiCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion) + if ((aaiCloudRegion != "ERROR")) { + execution.setVariable("lcpCloudRegionId", aaiCloudRegion) + msoLogger.debug("AIC Cloud Region for AAI: " + aaiCloudRegion) + } else { + String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode") + msoLogger.debug(errorMessage) + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + + def poCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + if ((poCloudRegion != "ERROR")) { + execution.setVariable("poLcpCloudRegionId", poCloudRegion) + msoLogger.debug("AIC Cloud Region for PO: " + poCloudRegion) + } else { + String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode") + msoLogger.debug(errorMessage) + (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(DelegateExecution 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') + + msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query volume group by name return code: " + returnCode) + msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString) + execution.setVariable(prefix+'AaiReturnCode', returnCode) + + if (returnCode=='200') { + execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString) + msoLogger.debug("Volume Group Name $volumeGroupName exists in AAI.") + } else { + if (returnCode=='404') { + msoLogger.debug("Volume Group Name $volumeGroupName does not exist in AAI.") + 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(DelegateExecution execution, int errorCode, errorMessage, isDebugEnabled) { + msoLogger.debug(errorMessage) + (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) + } + + + /** + * Create a WorkflowException + * @param execution + * @param isDebugEnabled + */ + public void handleError(DelegateExecution 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(DelegateExecution 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') + + msoLogger.debug("volumeGroupId: " + volumeGroupId) + + def testGroupId = execution.getVariable('test-volume-group-id') + if (testGroupId != null && testGroupId.trim() != '') { + msoLogger.debug("test volumeGroupId is present: " + testGroupId) + volumeGroupId = testGroupId + execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0") + } + + msoLogger.debug("volumeGroupId to be used: " + volumeGroupId) + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution)) + msoLogger.debug("AAI namespace is: " + namespace) + + msoLogger.debug("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest) + + NetworkUtils networkUtils = new NetworkUtils() + String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) + String payloadXml = utils.formatXml(payload) + msoLogger.debug("Request payload for PUT: " + payloadXml) + + APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI create volume group return code: " + returnCode) + msoLogger.debug("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) + msoLogger.debug(" AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + /** + * Prepare VNF adapter create request XML + * @param execution + */ + public void prepareVnfAdapterCreateRequest(DelegateExecution execution, isDebugEnabled) { + + def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse') + def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id') + def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name') + def vnfType = utils.getNodeText(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 + msoLogger.debug("volumeGroupId: " + volumeGroupId) + def testGroupId = execution.getVariable('test-volume-group-id') + if (testGroupId != null && testGroupId.trim() != '') { + msoLogger.debug("test volumeGroupId is present: " + testGroupId) + volumeGroupId = testGroupId + execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0") + } + msoLogger.debug("volumeGroupId to be used: " + volumeGroupId) + + // 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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(paramValue)} + + """ + sbParams.append(paramsXml) + } + + volumeGroupParams = sbParams.toString() + msoLogger.debug("volumeGroupParams: "+ volumeGroupParams) + + def backoutOnFailure = execution.getVariable(prefix+"backoutOnFailure") + msoLogger.debug("backoutOnFailure: "+ backoutOnFailure) + + def failIfExists = execution.getVariable("failIfExists") + if(failIfExists == null) { + failIfExists = 'true' + } + + String messageId = UUID.randomUUID() + msoLogger.debug("messageId to be used is generated: " + messageId) + + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + msoLogger.debug("CreateVfModuleVolume - notificationUrl: "+ notificationUrl) + + // build request + String vnfSubCreateWorkflowRequest = + """ + + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupnName)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(vnfVersion)} + ${MsoUtils.xmlEscape(vnfModuleType)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + + + vnf_id + ${MsoUtils.xmlEscape(vnfId)} + + + vnf_name + ${MsoUtils.xmlEscape(vnfName)} + + + vf_module_id + ${MsoUtils.xmlEscape(volumeGroupId)} + + + vf_module_name + ${MsoUtils.xmlEscape(volumeGroupnName)} + + ${volumeGroupParams} + + true + ${MsoUtils.xmlEscape(backoutOnFailure)} + ${MsoUtils.xmlEscape(failIfExists)} + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + + String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest) + msoLogger.debug(vnfSubCreateWorkflowRequestAsString) + msoLogger.debug(vnfSubCreateWorkflowRequestAsString) + execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString) + + // build rollback request for use later if needed + String vnfSubRollbackWorkflowRequest = buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl) + + msoLogger.debug("Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest) + + String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest) + execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString) + } + + public String buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl) { + + def request = """ + + + ${MsoUtils.xmlEscape(volumeGroupId)} + {{VOLUMEGROUPSTACKID}} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(cloudSiteId)} + true + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceId)} + + ${MsoUtils.xmlEscape(messageId)} + + true + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + + return request + } + + public String updateRollbackVolumeGroupRequestXml(String rollabackRequest, String heatStackId) { + String newRequest = rollabackRequest.replace("{{VOLUMEGROUPSTACKID}}", heatStackId) + return newRequest + } + + /** + * Validate VNF adapter response + * @param execution + */ + public void validateVnfResponse(DelegateExecution execution, isDebugEnabled) { + def vnfSuccess = execution.getVariable('VNFREST_SuccessIndicator') + msoLogger.debug("vnfAdapterSuccessIndicator: "+ vnfSuccess) + if(vnfSuccess==true) { + String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse") + String heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId") + String vnfRollbackRequest = execution.getVariable(prefix+"rollbackVnfARequest") + String updatedVnfRollbackRequest = updateRollbackVolumeGroupRequestXml(vnfRollbackRequest, heatStackID) + msoLogger.debug("vnfAdapter rollback request: "+ updatedVnfRollbackRequest) + RollbackData rollbackData = execution.getVariable("rollbackData") + rollbackData.put("DCVFMODULEVOL", "rollbackVnfARequest", updatedVnfRollbackRequest) + 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(DelegateExecution execution, isDebugEnabled) { + + String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse") + String volumeGroupId = utils.getNodeText(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)) + + msoLogger.debug("updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest) + + String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse") + def heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId") + + execution.setVariable(prefix+"heatStackId", heatStackID) + + NetworkUtils networkUtils = new NetworkUtils() + String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackID, namespace, modelCustomizationId) + String payloadXml = utils.formatXml(payload) + + msoLogger.debug("Payload to Update Created VolumeGroupName - " + "\n" + payloadXml) + + APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI create volume group return code: " + returnCode) + msoLogger.debug("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) + msoLogger.debug(" AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException) + throw new BpmnError("MSOWorkflowException") + } + } + } + + + /** + * Query AAI Generic VNF + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) { + + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) + def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") + + msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query generic vnf return code: " + returnCode) + msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode=='200') { + msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.') + execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString) + } else { + if (returnCode=='404') { + def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.' + msoLogger.debug(message) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy new file mode 100644 index 0000000000..46a502e124 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -0,0 +1,618 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.springframework.web.util.UriUtils + + +/** + * This class supports the DoCreateVnf building block subflow + * with the creation of a generic vnf for + * infrastructure. + * + */ +class DoCreateVnf extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnf.class); + String Prefix="DoCVNF_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + msoLogger.debug("STARTED DoCreateVnf PreProcessRequest Process") + + // DISABLE SDNC INTERACTION FOR NOW + execution.setVariable("SDNCInteractionEnabled", false) + + + /*******************/ + try{ + // Get Variables + + def rollbackData = execution.getVariable("rollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + String serviceModelInfo = execution.getVariable("serviceModelInfo") + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("DoCVNF_requestId", requestId) + execution.setVariable("mso-request-id", requestId) + msoLogger.debug("Incoming Request Id is: " + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId) + rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId) + msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + + String vnfType = execution.getVariable("vnfType") + execution.setVariable("DoCVNF_vnfType", vnfType) + msoLogger.debug("Incoming Vnf Type is: " + vnfType) + + String vnfName = execution.getVariable("vnfName") + if (vnfName.equals("") || vnfName.equals("null")) { + vnfName = null + } + execution.setVariable("DoCVNF_vnfName", vnfName) + msoLogger.debug("Incoming Vnf Name is: " + vnfName) + + String serviceId = execution.getVariable("productFamilyId") + execution.setVariable("DoCVNF_serviceId", serviceId) + msoLogger.debug("Incoming Service Id is: " + serviceId) + + String source = "VID" + execution.setVariable("DoCVNF_source", source) + rollbackData.put("VNF", "source", source) + msoLogger.debug("Incoming Source is: " + source) + + String suppressRollback = execution.getVariable("disableRollback") + execution.setVariable("DoCVNF_suppressRollback", suppressRollback) + msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback) + + String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid") + execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) + msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId) + + String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid") + if (modelVersionId == null) { + modelVersionId = "" + } + execution.setVariable("DoCVNF_modelVersionId", modelVersionId) + msoLogger.debug("Incoming Version Id is: " + modelVersionId) + + String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") + execution.setVariable("DoCVNF_modelVersion", modelVersion) + msoLogger.debug("Incoming Model Version is: " + modelVersion) + + String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") + execution.setVariable("DoCVNF_modelName", modelName) + msoLogger.debug("Incoming Model Name is: " + modelName) + + String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") + if (modelCustomizationId == null) { + modelCustomizationId = "" + } + execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId) + msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId) + + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId) + rollbackData.put("VNF", "cloudSiteId", cloudSiteId) + msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DoCVNF_tenantId", tenantId) + rollbackData.put("VNF", "tenantId", tenantId) + msoLogger.debug("Incoming Tenant Id is: " + tenantId) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if (globalSubscriberId == null) { + globalSubscriberId = "" + } + execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId) + msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DoCVNF_sdncVersion", sdncVersion) + msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("DoCVNF_requestInfo", requestInfo) + //TODO: Orch Status - TBD, will come from SDN-C Response in 1702 + String orchStatus = "Created" + execution.setVariable("DoCVNF_orchStatus", orchStatus) + + //TODO: Equipment Role - Should come from SDN-C Response in 1702 + String equipmentRole = " " + execution.setVariable("DoCVNF_equipmentRole", equipmentRole) + String vnfId = execution.getVariable("testVnfId") // for junits + if(isBlank(vnfId)){ + vnfId = execution.getVariable("vnfId") + if (isBlank(vnfId)) { + vnfId = UUID.randomUUID().toString() + msoLogger.debug("Generated Vnf Id is: " + vnfId) + } + } + execution.setVariable("DoCVNF_vnfId", vnfId) + + // Setting for Sub Flow Calls + execution.setVariable("DoCVNF_type", "generic-vnf") + execution.setVariable("GENGS_type", "service-instance") + + String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl) + rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl) + + VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition") + String nfRole = vnfResource.getNfRole() + + execution.setVariable("DoCVNF_nfRole", nfRole) + msoLogger.debug("NF Role is: " + nfRole) + + String nfNamingCode = vnfResource.getNfNamingCode() + execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode) + msoLogger.debug("NF Naming Code is: " + nfNamingCode) + + String nfType = vnfResource.getNfType() + execution.setVariable("DoCVNF_nfType", nfType) + msoLogger.debug("NF Type is: " + nfType) + + String nfFunction = vnfResource.getNfFunction() + execution.setVariable("DoCVNF_nfFunction", nfFunction) + msoLogger.debug("NF Function is: " + nfFunction) + + rollbackData.put("VNF", "rollbackSDNCAssign", "false") + rollbackData.put("VNF", "rollbackSDNCActivate", "false") + rollbackData.put("VNF", "rollbackVnfCreate", "false") + + execution.setVariable("rollbackData", rollbackData) + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") + + } + msoLogger.trace("COMPLETED DoCreateVnf PreProcessRequest Process") + } + + private Object getVariableEnforced(DelegateExecution execution, String name){ + Object enforced = execution.getVariable(name) + if(!enforced){ + return ""; + } + return enforced; + } + + public void createGenericVnf (DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DoCreateVnf CreateGenericVnf Process") + try { + //Get Vnf Info + String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId") + String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName") + if (vnfName == null) { + vnfName = "sdncGenerated" + msoLogger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName) + } + String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType") + String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId") + String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus") + String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId") + String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId") + String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId") + String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole") + String nfType = getVariableEnforced(execution, "DoCVNF_nfType") + String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole") + String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction") + String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode") + + //Get Service Instance Info + String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId") + String siRelatedLink = getVariableEnforced(execution, "GENGS_siResourceLink") + + int custStart = siRelatedLink.indexOf("customer/") + int custEnd = siRelatedLink.indexOf("/service-subscriptions") + String globalCustId = siRelatedLink.substring(custStart + 9, custEnd) + int serviceStart = siRelatedLink.indexOf("service-subscription/") + int serviceEnd = siRelatedLink.indexOf("/service-instances/") + String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd) + + Map payload = new LinkedHashMap<>(); + payload.put("vnf-id", vnfId); + payload.put("vnf-name", vnfName); + payload.put("service-id", serviceId); + payload.put("vnf-type", vnfType); + payload.put("prov-status", "PREPROV"); + payload.put("orchestration-status", orchStatus); + payload.put("model-invariant-id", modelInvariantId); + payload.put("model-version-id", modelVersionId); + payload.put("model-customization-id", modelCustomizationId); + payload.put("nf-type", nfType); + payload.put("nf-role", nfRole); + payload.put("nf-function", nfFunction); + payload.put("nf-naming-code", nfNamingCode); + + AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + resourceClient.create(uri, payload) + + AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + resourceClient.connect(uri, siUri) + + }catch(Exception ex) { + msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process") + } + msoLogger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process") + } + + public void postProcessCreateGenericVnf (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process") + try { + //Get Vnf Info + String vnfId = execution.getVariable("DoCVNF_vnfId") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put("VNF", "vnfId", vnfId) + rollbackData.put("VNF", "rollbackVnfCreate", "true") + execution.setVariable("rollbackData", rollbackData) + }catch(Exception ex) { + msoLogger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process") + } + msoLogger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process") + } + + + public void preProcessSDNCAssignRequest(DelegateExecution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCAssignRequest") + def vnfId = execution.getVariable("DoCVNF_vnfId") + def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") + msoLogger.debug("NEW VNF ID: " + vnfId) + + try{ + //Build SDNC Request + + String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign") + + assignSDNCRequest = utils.formatXml(assignSDNCRequest) + execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest) + msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCAssignRequest" , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCAssignRequest") + } + + public void preProcessSDNCActivateRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCActivateRequest Process") + try{ + String vnfId = execution.getVariable("DoCVNF_vnfId") + String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") + + String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate") + + execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest) + msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) + + }catch(Exception e){ + msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process") + } + + public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl") + def requestId = execution.getVariable("DoCVNF_requestId") + def serviceId = execution.getVariable("DoCVNF_serviceId") + def vnfType = execution.getVariable("DoCVNF_vnfType") + def vnfName = execution.getVariable("DoCVNF_vnfName") + // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign + String vnfNameString = "" + if (vnfName != null) { + vnfNameString = """${MsoUtils.xmlEscape(vnfName)}""" + } + def tenantId = execution.getVariable("DoCVNF_tenantId") + def source = execution.getVariable("DoCVNF_source") + def vnfId = execution.getVariable("DoCVNF_vnfId") + def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId") + def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") + def serviceModelInfo = execution.getVariable("serviceModelInfo") + def vnfModelInfo = execution.getVariable("vnfModelInfo") + String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) + String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) + def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId") + def sdncVersion = execution.getVariable("DoCVNF_sdncVersion") + + String sdncVNFParamsXml = "" + + if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){ + sdncVNFParamsXml = buildSDNCParamsXml(execution) + }else{ + sdncVNFParamsXml = "" + } + + String sdncRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + generic-resource + + + + ${MsoUtils.xmlEscape(requestId)} + CreateVnfInstance + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${serviceEcompModelInformation} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfType)} + ${vnfEcompModelInformation} + + + ${vnfNameString} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(cloudSiteId)} + ${sdncVNFParamsXml} + + + """ + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + msoLogger.debug("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + msoLogger.debug("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + if(method.equals("get")){ + String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse") + String data = utils.getNodeXml(topologyGetResponse, "response-data") + msoLogger.debug("topologyGetResponseData: " + data) + String vnfName = utils.getNodeText(data, "vnf-name") + msoLogger.debug("vnfName received from SDNC: " + vnfName) + 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{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.debug("COMPLETED ValidateSDNCResponse Process") + } + + public void preProcessSDNCGetRequest(DelegateExecution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCGetRequest Process") + try{ + def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId') + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + } + + def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl") + msoLogger.debug("callbackUrl:" + callbackUrl) + + def vnfId = execution.getVariable('DCVFM_vnfId') + + def svcInstId = "" + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + svcInstId = vnfId + } + else { + svcInstId = serviceInstanceId + } + // serviceOperation will be retrieved from "object-path" element + // in SDNC Assign Response for VNF + String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse") + msoLogger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response) + + String serviceOperation = "" + + String data = utils.getNodeXml(response, "response-data") + msoLogger.debug("responseData: " + data) + serviceOperation = utils.getNodeText(data, "object-path") + msoLogger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation) + + + //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE + sleep(5000) + + String SDNCGetRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + query + ${MsoUtils.xmlEscape(serviceOperation)} + ${MsoUtils.xmlEscape(callbackUrl)} + vfmodule + + + """ + + + execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest) + msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process") + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DoCVNF_vnfId') + msoLogger.debug("VNF ID: " + vnfId) + + String updateAAIGenericVnfRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + Active + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy new file mode 100644 index 0000000000..d3dbd9107e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -0,0 +1,467 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import java.util.UUID; + +import java.util.List + +import org.json.JSONObject; +import org.json.JSONArray; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ModuleResource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.DecomposeJsonUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources; +import org.onap.so.logger.MsoLogger +import org.onap.so.logger.MessageEnum + +import static org.apache.commons.lang3.StringUtils.*; + + + +/** +* This class supports the macro VID Flow +* with the creation of a generic vnf and related VF modules. +*/ +class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnfAndModules.class); + String Prefix="DCVAM_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + CatalogDbUtils cutils = new CatalogDbUtils() + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DoCreateVnfAndModules PreProcessRequest Process") + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + + setBasicDBAuthHeader(execution, isDebugLogEnabled) + try{ + // Get Variables + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("requestId", requestId) + execution.setVariable("mso-request-id", requestId) + msoLogger.debug("Incoming Request Id is: " + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + + String vnfName = execution.getVariable("vnfName") + execution.setVariable("CREVI_vnfName", vnfName) + msoLogger.debug("Incoming Vnf Name is: " + vnfName) + + String productFamilyId = execution.getVariable("productFamilyId") + msoLogger.debug("Incoming Product Family Id is: " + productFamilyId) + + String source = "VID" + execution.setVariable("source", source) + msoLogger.debug("Incoming Source is: " + source) + + String lcpCloudRegionId = execution.getVariable("lcpCloudRegionId") + msoLogger.debug("Incoming LCP Cloud Region Id is: " + lcpCloudRegionId) + + String tenantId = execution.getVariable("tenantId") + msoLogger.debug("Incoming Tenant Id is: " + tenantId) + + String disableRollback = execution.getVariable("disableRollback") + msoLogger.debug("Incoming Disable Rollback is: " + disableRollback) + + String asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") + msoLogger.debug("Incoming asdcServiceModelVersion: " + asdcServiceModelVersion) + + String vnfId = execution.getVariable("testVnfId") // for junits + if(isBlank(vnfId)){ + vnfId = execution.getVariable("vnfId") + if (isBlank(vnfId)) { + vnfId = UUID.randomUUID().toString() + msoLogger.debug("Generated Vnf Id is: " + vnfId) + } + } + execution.setVariable("vnfId", vnfId) + + // Set aLaCarte to false + execution.setVariable("aLaCarte", false) + + 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) + + sleep (20000) + + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") + + } + msoLogger.trace("COMPLETED DoCreateVnfAndModules PreProcessRequest Process") + } + + + public void queryCatalogDB (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("STARTED DoCreateVnfAndModules QueryCatalogDB Process") + try { + VnfResource vnf = null + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + // if serviceDecomposition is specified, get info from serviceDecomposition + if (serviceDecomposition != null) { + msoLogger.debug("Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString()) + List vnfs = serviceDecomposition.getVnfResources() + msoLogger.debug("Read vnfs") + if (vnfs == null) { + msoLogger.debug("Error - vnfs are empty in serviceDecomposition object") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnfs are empty") + } + vnf = vnfs[0] + String serviceModelName = serviceDecomposition.getModelInfo().getModelName() + vnf.constructVnfType(serviceModelName) + String vnfType = vnf.getVnfType() + msoLogger.debug("Incoming Vnf Type is: " + vnfType) + execution.setVariable("vnfType", vnfType) + } + else { + //Get Vnf Info + String vnfModelInfo = execution.getVariable("vnfModelInfo") + msoLogger.debug("vnfModelInfo: " + vnfModelInfo) + String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") + if (vnfModelCustomizationUuid == null) { + vnfModelCustomizationUuid = "" + } + msoLogger.debug("querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) + + JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(execution, + vnfModelCustomizationUuid) + msoLogger.debug("obtained VNF list") + // Only one match here + JSONObject vnfObject = vnfs[0] + vnf = DecomposeJsonUtil.jsonToVnfResource(vnfObject.toString()) + } + msoLogger.debug("Read vnfResource") + if (vnf == null) { + msoLogger.debug("Error - vnf is empty in serviceDecomposition object") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnf is null") + } + execution.setVariable("vnfResourceDecomposition", vnf) + + List vfModules = vnf.getAllVfModuleObjects() + msoLogger.debug("Read vfModules") + if (vfModules == null) { + msoLogger.debug("Error - vfModules are empty in serviceDecomposition object") + 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++) { + msoLogger.debug("handling VF Module ") + 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.getModelInvariantUuid() + execution.setVariable("basePersonaModelId", basePersonaModelId) + baseVfModule = vfModule + break + } + + } + + ListaddOnModules = vfModules - baseVfModule + + int addOnModulesToDeploy = 0 + if (addOnModules != null) { + addOnModulesToDeploy = addOnModules.size + } + + + execution.setVariable("addOnModules", addOnModules) + execution.setVariable("addOnModulesToDeploy", addOnModulesToDeploy) + execution.setVariable("addOnModulesDeployed", 0) + + }catch(Exception ex) { + msoLogger.debug("Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnfAndModules QueryCatalogDB Process") + } + + // Generate vfModuleId for base VF Module + def baseVfModuleId = UUID.randomUUID().toString() + execution.setVariable("baseVfModuleId", baseVfModuleId) + // For JUnits + String requestId = execution.getVariable("requestId") + if (requestId.equals("testRequestId123")) { + execution.setVariable("vnfId", "skask") + } + + msoLogger.trace("COMPLETED DoCreateVnfAndModules QueryCatalogDB Process") + } + + public void preProcessAddOnModule(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.debug("STARTED preProcessAddOnModule") + + try { + ListaddOnModules = execution.getVariable("addOnModules") + int addOnIndex = (int) execution.getVariable("addOnModulesDeployed") + + ModuleResource addOnModule = addOnModules[addOnIndex] + + msoLogger.debug("Got addon module") + + def newVfModuleId = UUID.randomUUID().toString() + execution.setVariable("addOnVfModuleId", newVfModuleId) + execution.setVariable("isBaseVfModule", "false") + + execution.setVariable("instancesOfThisModuleDeployed", 0) + + ModelInfo addOnVfModuleModelInfoObject = addOnModule.getModelInfo() + String addOnVfModuleModelInfoWithRoot = addOnVfModuleModelInfoObject.toString() + String addOnVfModuleModelInfo = jsonUtil.getJsonValue(addOnVfModuleModelInfoWithRoot, "modelInfo") + execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) + String addOnVfModuleLabel = addOnModule.getVfModuleLabel() + execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) + String addOnPersonaModelId = addOnVfModuleModelInfoObject.getModelInvariantUuid() + execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) + int addOnInitialCount = addOnModule.getInitialCount() + execution.setVariable("initialCount", addOnInitialCount) + + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessAddOnModule") + } + + public void postProcessAddOnModule(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED postProcessAddOnModule") + + try { + int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") + execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing postProcessAddOnModule ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessAddOnModule Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED postProcessAddOnModule") + } + + public void validateBaseModule(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED validateBaseModule") + + try { + def baseRollbackData = execution.getVariable("DCVAM_baseRollbackData") + def rollbackData = execution.getVariable("rollbackData") + + def baseModuleMap = baseRollbackData.get("VFMODULE") + baseModuleMap.each{ k, v -> rollbackData.put("VFMODULE_BASE", "${k}","${v}") } + execution.setVariable("rollbackData", rollbackData) + msoLogger.debug("addOnModulesDeployed: " + execution.getVariable("addOnModulesDeployed")) + msoLogger.debug("addOnModulesToDeploy: " + execution.getVariable("addOnModulesToDeploy")) + if (execution.getVariable("addOnModulesDeployed") < execution.getVariable("addOnModulesToDeploy")) { + msoLogger.debug("More add on modules to deploy") + } + else { + msoLogger.debug("No more add on modules to deploy") + } + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing validateBaseModule ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during validateBaseModule Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED validateBaseModule") + } + + public void validateAddOnModule(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED validateAddOnModule") + + try { + int instancesOfThisModuleDeployed = execution.getVariable("instancesOfThisModuleDeployed") + int numOfCreatedAddOnModules = execution.getVariable("numOfCreatedAddOnModules") + def addOnRollbackData = execution.getVariable("DCVAM_addOnRollbackData") + def rollbackData = execution.getVariable("rollbackData") + + def addOnModuleMap = addOnRollbackData.get("VFMODULE") + numOfCreatedAddOnModules = numOfCreatedAddOnModules + 1 + addOnModuleMap.each{ k, v -> rollbackData.put("VFMODULE_ADDON_" + numOfCreatedAddOnModules, "${k}","${v}") } + + execution.setVariable("DCVAM_addOnRollbackData", null) + + execution.setVariable("instancesOfThisModuleDeployed", instancesOfThisModuleDeployed + 1) + + execution.setVariable("numOfCreatedAddOnModules", numOfCreatedAddOnModules) + rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "${numOfCreatedAddOnModules}") + execution.setVariable("rollbackData", rollbackData) + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED validateAddOnModule") + } + + public void preProcessRollback (DelegateExecution execution) { + + msoLogger.trace("preProcessRollback") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit preProcessRollback") + } + + public void postProcessRollback (DelegateExecution execution) { + + msoLogger.trace("postProcessRollback") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit postProcessRollback") + } + + public void createPlatform (DelegateExecution execution) { + + msoLogger.trace("START createPlatform") + + String platformName = execution.getVariable("platformName") + String vnfId = execution.getVariable("vnfId") + + msoLogger.debug("Platform NAME: " + platformName) + msoLogger.debug("VnfID: " + vnfId) + + if(isBlank(platformName)){ + msoLogger.debug("platformName was not found. Continuing on with flow...") + }else{ + msoLogger.debug("platformName was found.") + try{ + AAICreateResources aaiCR = new AAICreateResources() + aaiCR.createAAIPlatform(platformName, vnfId) + }catch(Exception ex){ + String msg = "Exception in createPlatform. " + ex.getMessage(); + msoLogger.debug(msg) + } + } + msoLogger.trace("Exit createPlatform") + } + + public void createLineOfBusiness (DelegateExecution execution) { + + msoLogger.trace("START createLineOfBusiness") + + String lineOfBusiness = execution.getVariable("lineOfBusiness") + String vnfId = execution.getVariable("vnfId") + + msoLogger.debug("LineOfBusiness NAME: " + lineOfBusiness) + msoLogger.debug("VnfID: " + vnfId) + + if(isBlank(lineOfBusiness)){ + msoLogger.debug("LineOfBusiness was not found. Continuing on with flow...") + }else{ + msoLogger.debug("LineOfBusiness was found.") + try{ + AAICreateResources aaiCR = new AAICreateResources() + aaiCR.createAAILineOfBusiness(lineOfBusiness, vnfId) + }catch(Exception ex){ + String msg = "Exception in LineOfBusiness. " + ex.getMessage(); + msoLogger.debug(msg) + } + } + msoLogger.trace("Exit createLineOfBusiness") + } + + +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy new file mode 100644 index 0000000000..eafc39b1dd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy @@ -0,0 +1,360 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This class supports the macro VID Flow + * with the rollback of a creation of a generic vnf and related VF modules. + */ +class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnfAndModulesRollback.class); + String Prefix="DCVAMR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + msoLogger.debug("STARTED DoCreateVnfAndModulesRollback PreProcessRequest Process") + + try{ + // Get Rollback Variables + + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("Incoming RollbackData is: " + rollbackData.toString()) + execution.setVariable("rolledBack", null) + execution.setVariable("rollbackError", null) + + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + + String vnfId = rollbackData.get("VNF", "vnfId") + msoLogger.debug("Rollback vnfId is: " + vnfId) + 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") + msoLogger.debug("Rollback sdncCallbackUrl is: " + sdncCallbackUrl) + execution.setVariable("DCVAMR_sdncCallbackUrl", sdncCallbackUrl) + + String tenantId= rollbackData.get("VNF", "tenantId") + msoLogger.debug("Rollback tenantId is: " + tenantId) + execution.setVariable("DCVAMR_tenantId", tenantId) + + String source= rollbackData.get("VNF", "source") + msoLogger.debug("Rollback source is: " + source) + execution.setVariable("DCVAMR_source", source) + + String serviceInstanceId = rollbackData.get("VNF", "serviceInstanceId") + msoLogger.debug("Rollback serviceInstanceId is: " + serviceInstanceId) + execution.setVariable("DCVAMR_serviceInstanceId", serviceInstanceId) + + String cloudSiteId = rollbackData.get("VNF", "cloudSiteId") + msoLogger.debug("Rollback cloudSiteId is: " + cloudSiteId) + execution.setVariable("DCVAMR_cloudSiteId", cloudSiteId) + + def numOfAddOnModulesString = rollbackData.get("VNFANDMODULES", "numOfCreatedAddOnModules") + int numOfAddOnModules = 0 + if (numOfAddOnModulesString != null) { + numOfAddOnModules = Integer.parseInt(numOfAddOnModulesString) + } + execution.setVariable("DCVAMR_numOfAddOnModules", numOfAddOnModules) + + def baseVfModuleRollbackMap = rollbackData.get("VFMODULE_BASE") + if (baseVfModuleRollbackMap == null) { + // there are no VF Modules to delete + execution.setVariable("DCVAMR_numOfModulesToDelete", 0) + } + else { + execution.setVariable("DCVAMR_numOfModulesToDelete", numOfAddOnModules + 1) + } + + // Set aLaCarte to false + execution.setVariable("DCVAMR_aLaCarte", false) + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DoCreateVnfAndModulesRollback PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnfAndModulesRollback PreProcessRequest") + + } + msoLogger.trace("COMPLETED DoCreateVnfAndModulesRollback PreProcessRequest Process") + } + + + + public void preProcessCreateVfModuleRollback(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessCreateVfModuleRollback") + + try { + + def rollbackData = execution.getVariable("rollbackData") + + def vfModuleRollbackData = new RollbackData() + + def numOfModulesToDelete = execution.getVariable("DCVAMR_numOfModulesToDelete") + msoLogger.debug("numOfModulesToDelete: " + numOfModulesToDelete) + def moduleMap = null + + if (numOfModulesToDelete > 1) { + int addOnModuleIndex = numOfModulesToDelete - 1 + moduleMap = rollbackData.get("VFMODULE_ADDON_" + addOnModuleIndex) + msoLogger.debug("Removing ADDON VF module # " + addOnModuleIndex) + } + else { + moduleMap = rollbackData.get("VFMODULE_BASE") + msoLogger.debug("Removing BASE VF module") + } + moduleMap.each{ k, v -> vfModuleRollbackData.put("VFMODULE", "${k}","${v}") } + execution.setVariable("DCVAMR_RollbackData", vfModuleRollbackData) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessCreateVfModuleRollback ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessCreateVfModuleRollback Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessCreateVfModuleRollback") + } + + + public void postProcessCreateVfModuleRollback(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED postProcessCreateVfModuleRollback") + def rolledBack = false + + try { + rolledBack = execution.getVariable("DCVM_rolledBack") + def numOfModulesToDelete = execution.getVariable("DCVAMR_numOfModulesToDelete") + execution.setVariable("DCVAMR_numOfModulesToDelete", numOfModulesToDelete - 1) + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing postProcessCreateVfModuleRollback ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessCreateVfModuleRollback Method:\n" + e.getMessage()) + } + if (rolledBack == false) { + msoLogger.debug("Failure on DoCreateVfModuleRollback") + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Unsuccessful rollback of DoCreateVfModule ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during rollback of DoCreateVfModule") + } + msoLogger.trace("COMPLETED postProcessCreateVfModuleRollback") + } + + + public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCDeactivateRequest") + 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) + msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCDeactivateRequest") + } + + public void preProcessSDNCUnassignRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process") + try{ + String vnfId = execution.getVariable("vnfId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable(Prefix + "unassignSDNCRequest", unassignSDNCRequest) + msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCUnassignRequest Process") + } + + public String buildSDNCRequest(DelegateExecution 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 = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + generic-resource + + + + ${MsoUtils.xmlEscape(requestId)} + DeleteVnfInstance + ${MsoUtils.xmlEscape(source)} + + + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + + + ${MsoUtils.xmlEscape(vnfId)} + + + + + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(cloudSiteId)} + + + """ + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + + execution.setVariable("prefix",Prefix) + msoLogger.debug("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.debug("COMPLETED ValidateSDNCResponse Process") + } + + public void setSuccessfulRollbackStatus (DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED setSuccessfulRollbackStatus") + + try{ + // Set rolledBack to true, rollbackError to null + execution.setVariable("rolledBack", true) + execution.setVariable("rollbackError", null) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setSuccessfulRollbackStatus ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED setSuccessfulRollbackStatus") + } + + public void setFailedRollbackStatus (DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED setFailedRollbackStatus") + + 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){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setFailedRollbackStatus. ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED setFailedRollbackStatus") + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy new file mode 100644 index 0000000000..238ac82c01 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -0,0 +1,640 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils; +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient + +import groovy.json.* + + + +/** + * This groovy class supports the DoDeleteE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion + * @param - failNotFound - TODO + * @param - serviceInputParams - TODO + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCustomDeleteE2EServiceInstance.class); + + + String Prefix="DDELSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + msoLogger.trace("preProcessRequest ") + String msg = "" + + 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 + if (globalSubscriberId == null) + { + execution.setVariable("globalSubscriberId", "") + } + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + execution.setVariable("serviceType", "") + } + + //Generated in parent for AAI PUT + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution) + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.info("SDNC Callback URL: " + sdncCallbackUrl) + + 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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(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){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + + public void preProcessVFCDelete (DelegateExecution execution) { + } + + public void postProcessVFCDelete(DelegateExecution execution, String response, String method) { + } + + public void preProcessSDNCDelete (DelegateExecution execution) { + msoLogger.trace("preProcessSDNCDelete ") + String msg = "" + + try { + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def serviceInstanceName = execution.getVariable("serviceInstanceName") + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("productFamilyId") + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") + def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + + String serviceModelInfo = execution.getVariable("serviceModelInfo") + def modelInvariantUuid = "" + def modelVersion = "" + def modelUuid = "" + def modelName = "" + if (!isBlank(serviceModelInfo)) + { + modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + + if (modelInvariantUuid == null) { + modelInvariantUuid = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUuid == null) { + modelUuid = "" + } + if (modelName == null) { + modelName = "" + } + } + if (serviceInstanceName == null) { + serviceInstanceName = "" + } + 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 = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + delete + service-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + ${MsoUtils.xmlEscape(serviceType)} + + + + ${MsoUtils.xmlEscape(requestId)} + MSO + + + + DeleteServiceInstance + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${siParamsXml} + + + """ + + sdncDelete = utils.formatXml(sdncDelete) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + execution.setVariable("sdncDelete", sdncDelete) + execution.setVariable("sdncDeactivate", sdncDeactivate) + msoLogger.info("sdncDeactivate:\n" + sdncDeactivate) + msoLogger.info("sdncDelete:\n" + sdncDelete) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) + } + msoLogger.info(" *****Exit preProcessSDNCDelete *****") + } + + public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) { + + msoLogger.trace("postProcessSDNC " + method + " ") + String msg = "" + + /*try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.info("SDNCResponse: " + response) + msoLogger.info("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){ + msoLogger.info("Good response from SDNC Adapter for service-instance " + method + "response:\n" + response) + + }else{ + msg = "Bad Response from SDNC Adapter for service-instance " + method + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + }*/ + msoLogger.trace("Exit postProcessSDNC " + method + " ") + } + + public void postProcessAAIGET(DelegateExecution execution) { + msoLogger.trace("postProcessAAIGET ") + String msg = "" + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + String serviceType = "" + + if(foundInAAI){ + msoLogger.info("Found Service-instance in AAI") + + String siData = execution.getVariable("GENGS_service") + msoLogger.info("SI Data") + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + msoLogger.info("SI Data" + siData) + //Confirm there are no related service instances (vnf/network or volume) + if (utils.nodeExists(siData, "relationship-list")) { + msoLogger.info("SI Data relationship-list exists:") + InputSource source = new InputSource(new StringReader(siData)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document serviceXml = docBuilder.parse(source) + serviceXml.getDocumentElement().normalize() + //test(siData) + NodeList nodeList = serviceXml.getElementsByTagName("relationship") + JSONArray jArray = new JSONArray() + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns + if(e.equals("service-instance")){ + def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() + msoLogger.info("ServiceInstance Related NS :" + relatedObject) + NodeList dataList = node.getChildNodes() + if(null != dataList) { + JSONObject jObj = new JSONObject() + for (int i = 0; i < dataList.getLength(); i++) { + Node dNode = dataList.item(i) + if(dNode.getNodeName() == "relationship-data") { + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() + if(eKey.equals("service-instance.service-instance-id")){ + jObj.put("resourceInstanceId", eValue) + } + } + else if(dNode.getNodeName() == "related-to-property"){ + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() + if(eKey.equals("service-instance.service-instance-name")){ + jObj.put("resourceType", eValue) + } + } + } + msoLogger.info("Relationship related to Resource:" + jObj.toString()) + jArray.put(jObj) + } + //for overlay/underlay + }else if (e.equals("configuration")){ + def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() + msoLogger.info("ServiceInstance Related Configuration :" + relatedObject) + NodeList dataList = node.getChildNodes() + if(null != dataList) { + JSONObject jObj = new JSONObject() + for (int i = 0; i < dataList.getLength(); i++) { + Node dNode = dataList.item(i) + if(dNode.getNodeName() == "relationship-data") { + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() + if(eKey.equals("configuration.configuration-id")){ + jObj.put("resourceInstanceId", eValue) + } + } + else if(dNode.getNodeName() == "related-to-property"){ + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() + if(eKey.equals("configuration.configuration-type")){ + jObj.put("resourceType", eValue) + } + } + } + msoLogger.info("Relationship related to Resource:" + jObj.toString()) + jArray.put(jObj) + } + } + } + } + execution.setVariable("serviceRelationShip", jArray.toString()) + } + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error getting Service-instance from AAI", + serviceInstanceId) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + msoLogger.info("Service-instance NOT found in AAI. Silent Success") + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET ") + } + + /** + * Deletes the service instance in aai + */ + public void deleteServiceInstance(DelegateExecution execution) { + msoLogger.trace("Entered deleteServiceInstance") + try { + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + resourceClient.delete(serviceInstanceUri) + + msoLogger.trace("Exited deleteServiceInstance") + }catch(Exception e){ + msoLogger.debug("Error occured within deleteServiceInstance method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteServiceInstance from aai") + } + } + + public void preInitResourcesOperStatus(DelegateExecution execution){ + msoLogger.trace("STARTED preInitResourcesOperStatus Process ") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + // we use resource instance ids for delete flow as resourceTemplateUUIDs + /*[ + { + "resourceInstanceId":"1111", + "resourceType":"vIMS" + }, + { + "resourceInstanceId":"222", + "resourceType":"vEPC" + }, + { + "resourceInstanceId":"3333", + "resourceType":"overlay" + }, + { + "resourceInstanceId":"4444", + "resourceType":"underlay" + } + ]*/ + String serviceRelationShip = execution.getVariable("serviceRelationShip") + + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":" + } + } + execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(resourceTemplateUUIDs)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload) + msoLogger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ") + } + + /** + * prepare delete parameters + */ + public void preResourceDelete(execution, resourceName){ + // we use resource instance ids for delete flow as resourceTemplateUUIDs + /*[ + { + "resourceInstanceId":"1111", + "resourceType":"vIMS" + }, + { + "resourceInstanceId":"222", + "resourceType":"vEPC" + }, + { + "resourceInstanceId":"3333", + "resourceType":"overlay" + }, + { + "resourceInstanceId":"4444", + "resourceType":"underlay" + } + ]*/ + msoLogger.trace("STARTED preResourceDelete Process ") + String serviceRelationShip = execution.getVariable("serviceRelationShip") + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) { + String resourceInstanceUUID = it.resourceInstanceId + String resourceTemplateUUID = it.resourceInstanceId + execution.setVariable("resourceTemplateId", resourceTemplateUUID) + execution.setVariable("resourceInstanceId", resourceInstanceUUID) + execution.setVariable("resourceType", resourceName) + msoLogger.info("Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName) + } + } + } + msoLogger.trace("END preResourceDelete Process ") + } + + public void sequenceResource(execution){ + msoLogger.trace("STARTED sequenceResource Process ") + List nsResources = new ArrayList() + List wanResources = new ArrayList() + List resourceSequence = new ArrayList() + + String serviceRelationShip = execution.getVariable("serviceRelationShip") + + + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, "overlay") || StringUtils.containsIgnoreCase(it.resourceType, "underlay")){ + wanResources.add(it.resourceType) + }else{ + nsResources.add(it.resourceType) + } + } + } + resourceSequence.addAll(wanResources) + resourceSequence.addAll(nsResources) + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("resourceSequence", resourceSequence) + msoLogger.info("resourceSequence: " + resourceSequence) + execution.setVariable("wanResources", wanResources) + msoLogger.trace("END sequenceResource Process ") + } + + public void getCurrentResource(execution){ + msoLogger.trace("Start getCurrentResoure Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + List resourceSequence = execution.getVariable("resourceSequence") + List wanResources = execution.getVariable("wanResources") + String resourceName = resourceSequence.get(currentIndex) + execution.setVariable("resourceType",resourceName) + if(wanResources.contains(resourceName)){ + execution.setVariable("controllerInfo", "SDN-C") + }else{ + execution.setVariable("controllerInfo", "VF-C") + } + msoLogger.trace("COMPLETED getCurrentResoure Process ") + } + + public void parseNextResource(execution){ + msoLogger.trace("Start parseNextResource Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List resourceSequence = execution.getVariable("resourceSequence") + if(nextIndex >= resourceSequence.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + msoLogger.trace("COMPLETED parseNextResource Process ") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy new file mode 100644 index 0000000000..20a7f43de7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy @@ -0,0 +1,1132 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse; +import org.springframework.web.util.UriUtils; + +import groovy.json.* + + + +/** + * This groovy class supports the DoDeleteE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion + * @param - failNotFound - TODO + * @param - serviceInputParams - TODO + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCustomDeleteE2EServiceInstanceV2.class); + + + String Prefix="DDELSI_" + private static final String DebugFlag = "isDebugEnabled" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.buildAPPCRequest(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + msoLogger.trace("preProcessRequest ") + String msg = "" + + 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 + if (globalSubscriberId == null) + { + execution.setVariable("globalSubscriberId", "") + } + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + execution.setVariable("serviceType", "") + } + + //Generated in parent for AAI PUT + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.info("SDNC Callback URL: " + sdncCallbackUrl) + + 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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(paramValue)} + + """ + sbParams.append(paramsXml) + } + sbParams.append("") + } + String siParamsXml = sbParams.toString() + if (siParamsXml == null) + siParamsXml = "" + execution.setVariable("siParamsXml", siParamsXml) + execution.setVariable("operationStatus", "Waiting delete resource...") + execution.setVariable("progress", "0") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.info("Exited " + method) + } + + + + public void postProcessAAIGET(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessAAIGET(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + String msg = "" + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + msoLogger.info("serviceInstanceId: "+serviceInstanceId) + + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + msoLogger.info("foundInAAI: "+foundInAAI) + + String serviceType = "" + + + if(foundInAAI){ + msoLogger.info("Found Service-instance in AAI") + + String siData = execution.getVariable("GENGS_service") + msoLogger.info("SI Data") + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error getting Service-instance from AAI", + serviceInstanceId) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + msoLogger.info("Service-instance NOT found in AAI. Silent Success") + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Bpmn error encountered in " + method + "--" + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.info("Exited " + method) + } + + private void loadResourcesProperties(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + msoLogger.info("Entered " + method) + String loadFilePath = "/etc/mso/config.d/reources.json" + try{ + def jsonPayload = new File(loadFilePath).text + msoLogger.info("jsonPayload: " + jsonPayload) + + String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString()) + msoLogger.info("resourcesProperties: " + resourcesProperties) + + String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort") + msoLogger.info("createResourceSort: " + createResourceSort) + execution.setVariable("createResourceSort", createResourceSort) + + String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort") + msoLogger.info("deleteResourceSort: " + deleteResourceSort) + execution.setVariable("deleteResourceSort", deleteResourceSort) + + + String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType") + msoLogger.info("resourceControllerType: " + resourceControllerType) + execution.setVariable("resourceControllerType", resourceControllerType) + + + }catch(Exception ex){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.info("Exited " + method) + } + private void sortDeleteResource(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sortDeleteResource(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + msoLogger.info("Entered " + method) + String deleteResourceSortDef = """[ + { + "resourceType":"GRE_SAR" + }, + { + "resourceType":"VPN_SAR" + }, + { + "resourceType":"APN_AAR" + }, + { + "resourceType":"GRE_AAR" + }, + { + "resourceType":"Overlay" + }, + { + "resourceType":"Underlay" + }, + { + "resourceType":"vIMS" + }, + { + "resourceType":"vCPE" + }, + { + "resourceType":"vFW" + }, + { + "resourceType":"vEPC" + } + + + ]""".trim() + + try{ + loadResourcesProperties(execution) + String deleteResourceSort = execution.getVariable("deleteResourceSort") + if (isBlank(deleteResourceSort)) { + deleteResourceSort = deleteResourceSortDef; + } + + List sortResourceList = jsonUtil.StringArrayToList(execution, deleteResourceSort) + msoLogger.info("sortResourceList : " + sortResourceList) + + JSONArray newResourceList = new JSONArray() + int resSortCount = sortResourceList.size() + + for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) { + String currentSortResource = sortResourceList[currentResource] + String sortResourceType = jsonUtil.getJsonValue(currentSortResource, "resourceType") + List resourceList = execution.getVariable(Prefix+"resourceList") + + for (String resource : resourceList) { + msoLogger.info("resource : " + resource) + String resourceType = jsonUtil.getJsonValue(resource, "resourceType") + + if (StringUtils.containsIgnoreCase(resourceType, sortResourceType)) { + JSONObject jsonObj = new JSONObject(resource) + newResourceList.put(jsonObj) + } + msoLogger.info("Get next sort type " ) + } + } + + String newResourceStr = newResourceList.toString() + List newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr) + + execution.setVariable(Prefix+"resourceList", newResourceListStr) + msoLogger.info("newResourceList : " + newResourceListStr) + + }catch(Exception ex){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.info("Exited " + method) + + } + public void prepareServiceDeleteResource(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepareServiceDeleteResource(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // confirm if ServiceInstance was found + if ( !execution.getVariable("GENGS_FoundIndicator") ) + { + String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + execution.setVariable(Prefix+"resourceList", "") + execution.setVariable(Prefix+"resourceCount", 0) + execution.setVariable(Prefix+"nextResource", 0) + execution.setVariable(Prefix+"resourceFinish", true) + + // get SI extracted by GenericGetService + String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); + msoLogger.info("serviceInstanceAaiRecord: " +serviceInstanceAaiRecord) + + String aaiJsonRecord = jsonUtil.xml2json(serviceInstanceAaiRecord) + + msoLogger.info("aaiJsonRecord: " +aaiJsonRecord) + def serviceInstanceName = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-instance-name") + execution.setVariable("serviceInstanceName",serviceInstanceName) + + def serviceType = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-type") + execution.setVariable("serviceType",serviceType) + + + String relationshipList = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.relationship-list") + msoLogger.info("relationship-list:" + relationshipList) + if (! isBlank(relationshipList)){ + msoLogger.info("relationship-list exists" ) + String relationShip = jsonUtil.getJsonValue(relationshipList, "relationship") + msoLogger.info("relationship: " + relationShip) + JSONArray allResources = new JSONArray() + JSONArray serviceResources = new JSONArray() + JSONArray networkResources = new JSONArray() + JSONArray allottedResources = new JSONArray() + + + if (! isBlank(relationShip)){ + JSONArray jsonArray = new JSONArray(); + if (relationShip.startsWith("{") && relationShip.endsWith("}")) { + JSONObject jsonObject = new JSONObject(relationShip); + jsonArray.put(jsonObject); + } else if (relationShip.startsWith("[") && relationShip.endsWith("]")) { + jsonArray = new JSONArray(relationShip); + } else { + msoLogger.info("The relationShip fomart is error" ) + } + + List relationList = jsonUtil.StringArrayToList(execution, jsonArray.toString()) + + msoLogger.info("relationList: " + relationList) + + int relationNum =relationList.size() + msoLogger.info("**************relationList size: " + relationNum) + + for ( int currentRelation = 0 ; currentRelation < relationNum ; currentRelation++ ) { + msoLogger.info("current Relation num: " + currentRelation) + String relation = relationList[currentRelation] + msoLogger.info("relation: " + relation) + + String relatedTo = jsonUtil.getJsonValue(relation, "related-to") + msoLogger.info("relatedTo: " + relatedTo) + + String relatedLink = jsonUtil.getJsonValue(relation, "related-link") + msoLogger.info("relatedLink: " + relatedLink) + + if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) { + msoLogger.info("allotted-resource exists ") + + String aaiArRsp = getAaiAr(execution, relatedLink) + msoLogger.info("aaiArRsp: " + aaiArRsp) + if (! isBlank(aaiArRsp)) { + def type = utils.getNodeText(aaiArRsp, "type") + def id = utils.getNodeText(aaiArRsp, "id") + def role = utils.getNodeText(aaiArRsp, "role") + def resourceVersion = utils.getNodeText(aaiArRsp, "resource-version") + + JSONObject jObject = new JSONObject() + jObject.put("resourceType", type) + jObject.put("resourceInstanceId", id) + jObject.put("resourceRole", role) + jObject.put("resourceVersion", resourceVersion) + + allResources.put(jObject) + msoLogger.info("allResources: " + allResources) + allottedResources.put(jObject) + msoLogger.info("allottedResources: " + allottedResources) + } + } + else if (StringUtils.equalsIgnoreCase(relatedTo, "service-instance")){ + msoLogger.info("service-instance exists ") + JSONObject jObject = new JSONObject() + + //relationship-data + String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data") + msoLogger.info("rsDataStr: " + rsDataStr) + List rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr) + msoLogger.info("rsDataList: " + rsDataList) + for(String rsData : rsDataList){ + msoLogger.info("rsData: " + rsData) + def eKey = jsonUtil.getJsonValue(rsData, "relationship-key") + def eValue = jsonUtil.getJsonValue(rsData, "relationship-value") + if(eKey.equals("service-instance.service-instance-id")){ + jObject.put("resourceInstanceId", eValue) + } + if(eKey.equals("service-subscription.service-type")){ + jObject.put("resourceType", eValue) + } + } + + //related-to-property + String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property") + msoLogger.info("related-to-property: " + rPropertyStr) + if (rPropertyStr instanceof JSONArray){ + List rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr) + for (String rProperty : rPropertyList) { + msoLogger.info("rProperty: " + rProperty) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if(eKey.equals("service-instance.service-instance-name")){ + jObject.put("resourceName", eValue) + } + } + } + else { + String rProperty = rPropertyStr + msoLogger.info("rProperty: " + rProperty) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if (eKey.equals("service-instance.service-instance-name")) { + jObject.put("resourceName", eValue) + } + } + + allResources.put(jObject) + msoLogger.info("allResources: " + allResources) + + serviceResources.put(jObject) + msoLogger.info("serviceResources: " + serviceResources) + } + else if (StringUtils.equalsIgnoreCase(relatedTo, "configuration")) { + msoLogger.info("configuration ") + JSONObject jObject = new JSONObject() + + //relationship-data + String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data") + msoLogger.info("rsDataStr: " + rsDataStr) + List rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr) + msoLogger.info("rsDataList: " + rsDataList) + for (String rsData : rsDataList) { + msoLogger.info("rsData: " + rsData) + def eKey = jsonUtil.getJsonValue(rsData, "relationship-key") + def eValue = jsonUtil.getJsonValue(rsData, "relationship-value") + if(eKey.equals("configuration.configuration-id")){ + jObject.put("resourceInstanceId", eValue) + } + } + + + //related-to-property + String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property") + msoLogger.info("related-to-property: " + rPropertyStr) + if (rPropertyStr instanceof JSONArray){ + List rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr) + for(String rProperty : rPropertyList){ + msoLogger.info("rProperty: " + rProperty) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if(eKey.equals("configuration.configuration-type")){ + jObject.put("resourceType", eValue) + } + } + } + else { + String rProperty = rPropertyStr + msoLogger.info("rProperty: " + rProperty) + def eKey = jsonUtil.getJsonValue(rProperty, "property-key") + def eValue = jsonUtil.getJsonValue(rProperty, "property-value") + if(eKey.equals("configuration.configuration-type")){ + jObject.put("resourceType", eValue) + } + } + allResources.put(jObject) + msoLogger.info("allResources: " + allResources) + + networkResources.put(jObject) + msoLogger.info("networkResources: " + networkResources) + } + msoLogger.info("Get Next releation resource " ) + + } + msoLogger.info("Get releation finished. " ) + } + + execution.setVariable("serviceRelationShip", allResources.toString()) + msoLogger.info("allResources: " + allResources.toString()) + String serviceRelationShip = execution.getVariable("serviceRelationShip") + msoLogger.info("serviceRelationShip: " + serviceRelationShip) + if ((! isBlank(serviceRelationShip)) && (! serviceRelationShip.isEmpty())) { + + List relationShipList = jsonUtil.StringArrayToList(execution, serviceRelationShip) + msoLogger.info("relationShipList: " + relationShipList) + execution.setVariable(Prefix+"resourceList", relationShipList) + + int resourceCount = relationShipList.size() + msoLogger.info("resourceCount: " + resourceCount) + execution.setVariable(Prefix+"resourceCount",resourceCount ) + + int resourceNum = 0 + execution.setVariable(Prefix+"nextResource", resourceNum) + msoLogger.info("start sort delete resource: ") + sortDeleteResource(execution) + + + if (resourceNum < resourceCount) { + execution.setVariable(Prefix+"resourceFinish", false) + } + else { + execution.setVariable(Prefix+"resourceFinish", true) + } + msoLogger.info("Resource list set end : " + resourceCount) + } + + execution.setVariable("serviceResources", serviceResources.toString()) + msoLogger.info("serviceResources: " + serviceResources) + String serviceResourcesShip = execution.getVariable("serviceResources") + msoLogger.info("serviceResourcesShip: " + serviceResourcesShip) + + if ((! isBlank(serviceResourcesShip)) && (! serviceResourcesShip.isEmpty())) { + List serviceResourcesList = jsonUtil.StringArrayToList(execution, serviceResourcesShip) + msoLogger.info("serviceResourcesList: " + serviceResourcesList) + execution.setVariable(Prefix+"serviceResourceList", serviceResourcesList) + execution.setVariable(Prefix+"serviceResourceCount", serviceResourcesList.size()) + execution.setVariable(Prefix+"nextServiceResource", 0) + msoLogger.info("Service Resource list set end : " + serviceResourcesList.size()) + + } + + execution.setVariable("allottedResources", allottedResources.toString()) + msoLogger.info("allottedResources: " + allottedResources) + String allottedResourcesShip = execution.getVariable("allottedResources") + msoLogger.info("allottedResourcesShip: " + allottedResourcesShip) + if ((! isBlank(allottedResourcesShip)) && (! allottedResourcesShip.isEmpty())) { + List allottedResourcesList = jsonUtil.StringArrayToList(execution, allottedResourcesShip) + msoLogger.info("allottedResourcesList: " + allottedResourcesList) + execution.setVariable(Prefix+"allottedResourcesList", allottedResourcesList) + execution.setVariable(Prefix+"allottedResourcesListCount", allottedResourcesList.size()) + execution.setVariable(Prefix+"nextAllottedResourcesList", 0) + msoLogger.info("Allotted Resource list set end : " + allottedResourcesList.size()) + + } + execution.setVariable("networkResources", networkResources.toString()) + msoLogger.info("networkResources: " + networkResources) + String networkResourcesShip = execution.getVariable("networkResources") + msoLogger.info("networkResourcesShip: " + networkResourcesShip) + if ((! isBlank(networkResourcesShip)) && (! networkResourcesShip.isEmpty())) { + List networkResourcesList = jsonUtil.StringArrayToList(execution, networkResourcesShip) + msoLogger.info("networkResourcesList: " + networkResourcesList) + execution.setVariable(Prefix+"networkResourcesList", networkResourcesList) + execution.setVariable(Prefix+"networkResourcesListCount", networkResourcesList.size()) + execution.setVariable(Prefix+"nextNetworkResourcesList", 0) + msoLogger.info("Network Resource list set end : " + networkResourcesList.size()) + + } + } + } catch (BpmnError e){ + throw e; + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. prepareServiceDeleteResource() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.info("Exited " + method) + } + + private String getAaiAr(DelegateExecution execution, String relink) { + def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink + + msoLogger.debug("get AR info " + aaiEndpoint) + APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint) + + int responseCode = response.getStatusCode() + msoLogger.debug("get AR info responseCode:" + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + msoLogger.debug("get AR info " + aaiResponse) + + if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) { + return null + } + + msoLogger.info("Exited " + method) + return aaiResponse + } + /** + * prepare Decompose next resource to create request + */ + public void preProcessDecomposeNextResource(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + msoLogger.trace("STARTED preProcessDecomposeNextResource Process ") + try{ + int resourceNum = execution.getVariable(Prefix+"nextServiceResource") + List serviceResourceList = execution.getVariable(Prefix+"serviceResourceList") + msoLogger.info("Service Resource List : " + serviceResourceList) + + String serviceResource = serviceResourceList[resourceNum] + execution.setVariable(Prefix+"serviceResource", serviceResource) + msoLogger.info("Current Service Resource : " + serviceResource) + + String resourceType = jsonUtil.getJsonValue(serviceResource, "resourceType") + execution.setVariable("resourceType", resourceType) + msoLogger.info("resourceType : " + resourceType) + + String resourceInstanceId = jsonUtil.getJsonValue(serviceResource, "resourceInstanceId") + execution.setVariable("resourceInstanceId", resourceInstanceId) + msoLogger.info("resourceInstanceId : " + resourceInstanceId) + + String resourceRole = jsonUtil.getJsonValue(serviceResource, "resourceRole") + execution.setVariable("resourceRole", resourceRole) + msoLogger.info("resourceRole : " + resourceRole) + + String resourceVersion = jsonUtil.getJsonValue(serviceResource, "resourceVersion") + execution.setVariable("resourceVersion", resourceVersion) + msoLogger.info("resourceVersion : " + resourceVersion) + + String resourceName = jsonUtil.getJsonValue(serviceResource, "resourceName") + if (isBlank(resourceName)){ + resourceName = resourceInstanceId + } + execution.setVariable(Prefix+"resourceName", resourceName) + msoLogger.info("resource Name : " + resourceName) + + + execution.setVariable(Prefix+"nextServiceResource", resourceNum + 1) + + int serviceResourceCount = execution.getVariable(Prefix+"serviceResourceCount") + if (serviceResourceCount >0 ){ + int progress = (resourceNum*100) / serviceResourceCount + execution.setVariable("progress", progress.toString() ) + } + execution.setVariable("operationStatus", resourceName ) + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method preProcessDecomposeNextResource() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.info("Exited " + method) + } + /** + * post Decompose next resource to create request + */ + public void postProcessDecomposeNextResource(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + msoLogger.trace("STARTED postProcessDecomposeNextResource Process ") + try{ + String resourceName = execution.getVariable(Prefix+"resourceName") + int resourceNum = execution.getVariable(Prefix+"nextServiceResource") + msoLogger.debug("Current Resource count:"+ execution.getVariable(Prefix+"nextServiceResource")) + + int resourceCount = execution.getVariable(Prefix+"serviceResourceCount") + msoLogger.debug("Total Resource count:"+ execution.getVariable(Prefix+"serviceResourceCount")) + + if (resourceNum < resourceCount) { + execution.setVariable(Prefix+"resourceFinish", false) + } + else { + execution.setVariable(Prefix+"resourceFinish", true) + } + + msoLogger.debug("Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish")) + + if (resourceCount >0 ){ + int progress = (resourceNum*100) / resourceCount + + execution.setVariable("progress", progress.toString() ) + msoLogger.trace(":"+ execution.getVariable("")) + } + execution.setVariable("operationStatus", resourceName ) + + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method postProcessDecomposeNextResource() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.info("Exited " + method) + } + /** + * prepare post Unkown Resource Type + */ + public void postOtherControllerType(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugEnabled") + msoLogger.info("Entered " + method) + + try{ + + String resourceName = execution.getVariable(Prefix+"resourceName") + String resourceType = execution.getVariable(Prefix+"resourceType") + String controllerType = execution.getVariable("controllerType") + + String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed n the workflow" + msoLogger.debug(msg) + + }catch(Exception e){ + // try error in method block + String exceptionMessage = "Bpmn error encountered in DoCreateMobileAPNServiceInstance flow. Unexpected Error from method postOtherControllerType() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + msoLogger.info("Exited " + method) + } + + /** + * prepare delete parameters + */ + public void preSDNCResourceDelete(execution, resourceName){ + // we use resource instance ids for delete flow as resourceTemplateUUIDs + + def method = getClass().getSimpleName() + '.preSDNCResourceDelete(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + msoLogger.trace("STARTED preSDNCResourceDelete Process ") + String networkResources = execution.getVariable("networkResources") + + + execution.setVariable("foundResource", false) + if (networkResources != null) { + def jsonSlurper = new JsonSlurper() + List relationShipList = jsonSlurper.parseText(networkResources) + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) { + String resourceInstanceUUID = it.resourceInstanceId + String resourceTemplateUUID = it.resourceInstanceId + execution.setVariable("resourceTemplateId", resourceTemplateUUID) + execution.setVariable("resourceInstanceId", resourceInstanceUUID) + execution.setVariable("resourceType", resourceName) + execution.setVariable("foundResource", true) + msoLogger.info("Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName) + } + } + } + msoLogger.info("Exited " + method) + } + public void preProcessSDNCDelete (DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCDelete(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + msoLogger.trace("preProcessSDNCDelete ") + String msg = "" + + try { + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def serviceInstanceName = execution.getVariable("serviceInstanceName") + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("productFamilyId") + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") + def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + + String serviceModelInfo = execution.getVariable("serviceModelInfo") + def modelInvariantUuid = "" + def modelVersion = "" + def modelUuid = "" + def modelName = "" + if (!isBlank(serviceModelInfo)) + { + modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + + if (modelInvariantUuid == null) { + modelInvariantUuid = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUuid == null) { + modelUuid = "" + } + if (modelName == null) { + modelName = "" + } + } + if (serviceInstanceName == null) { + serviceInstanceName = "" + } + 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 = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + delete + service-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + ${MsoUtils.xmlEscape(serviceType)} + + + + ${MsoUtils.xmlEscape(requestId)} + MSO + + + + DeleteServiceInstance + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${siParamsXml} + + + """ + + sdncDelete = utils.formatXml(sdncDelete) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + execution.setVariable("sdncDelete", sdncDelete) + execution.setVariable("sdncDeactivate", sdncDeactivate) + msoLogger.info("sdncDeactivate:\n" + sdncDeactivate) + msoLogger.info("sdncDelete:\n" + sdncDelete) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) + } + msoLogger.info("Exited " + method) + } + + public void postProcessSDNCDelete(DelegateExecution execution, String response, String action) { + + def method = getClass().getSimpleName() + '.postProcessSDNCDelete(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + msoLogger.trace("postProcessSDNC " + action + " ") + String msg = "" + + /*try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.info("SDNCResponse: " + response) + msoLogger.info("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){ + msoLogger.info("Good response from SDNC Adapter for service-instance " + action + "response:\n" + response) + + }else{ + msg = "Bad Response from SDNC Adapter for service-instance " + action + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in postProcessSDNC " + action + " Exception:" + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + }*/ + msoLogger.info("Exited " + method) + } + + /** + * Init the service Operation Status + */ + public void preUpdateServiceOperationStatus(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String serviceName = execution.getVariable("serviceInstanceName") + String operationType = "DELETE" + String userId = "" + String result = "processing" + String progress = execution.getVariable("progress") + msoLogger.info("progress: " + progress ) + if ("100".equalsIgnoreCase(progress)) + { + result = "finished" + } + String reason = "" + String operationContent = "Prepare service delete: " + execution.getVariable("operationStatus") + msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(serviceName)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(userId)} + ${MsoUtils.xmlEscape(result)} + ${MsoUtils.xmlEscape(operationContent)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(reason)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + msoLogger.info("Outgoing preUpdateServiceOperationStatus: \n" + payload) + + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preUpdateServiceOperationStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preUpdateServiceOperationStatus Process ") + msoLogger.info("Exited " + method) + } + + public void preInitResourcesOperStatus(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + msoLogger.trace("STARTED preInitResourcesOperStatus Process ") + String msg="" + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = "DELETE" + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service delete" + msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + String serviceRelationShip = execution.getVariable("serviceRelationShip") + msoLogger.info("serviceRelationShip: " + serviceRelationShip) + if (! isBlank(serviceRelationShip)) { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + if (relationShipList != null) { + relationShipList.each { + resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":" + } + } + } + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(resourceTemplateUUIDs)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload) + msoLogger.debug("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload) + + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCustomDeleteE2EServiceInstanceV2.preInitResourcesOperStatus. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.info("Exited " + method) + } + + + + /** + * prepare delete parameters + */ + public void preProcessVFCResourceDelete(execution){ + // we use resource instance ids for delete flow as resourceTemplateUUIDs + + def method = getClass().getSimpleName() + '.preProcessVFCResourceDelete(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + msoLogger.trace("STARTED preProcessVFCResourceDelete Process ") + try{ + String serviceResource = execution.getVariable("serviceResource") + msoLogger.info("serviceResource : " + serviceResource) + + String resourceInstanceId = execution.getVariable("resourceInstanceId") + msoLogger.info("resourceInstanceId : " + resourceInstanceId) + + execution.setVariable("resourceTemplateId", resourceInstanceId) + msoLogger.info("resourceTemplateId : " + resourceInstanceId) + + String resourceType = execution.getVariable("resourceType") + msoLogger.info("resourceType : " + resourceType) + + + String resourceName = execution.getVariable(Prefix+"resourceName") + if (isBlank(resourceName)){ + resourceName = resourceInstanceId + } + execution.setVariable("resourceName", resourceName) + msoLogger.info("resource Name : " + resourceName) + + msoLogger.info("Delete Resource Info: resourceInstanceId :" + resourceInstanceId + " resourceTemplateId: " + resourceInstanceId + " resourceType: " + resourceType) + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.preProcessVFCResourceDelete. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.info("Exited " + method) + } + + public void postProcessVFCDelete(DelegateExecution execution, String response, String action) { + def method = getClass().getSimpleName() + '.postProcessVFCDelete(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + + msoLogger.trace("STARTED postProcessVFCDelete Process ") + try{ + + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessVFCDelete. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.info("Exited " + method) + } +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy new file mode 100644 index 0000000000..54dfae3760 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -0,0 +1,439 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition; +import org.onap.so.bpmn.core.json.JsonUtils +import org.springframework.web.util.UriUtils; +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + +import groovy.json.* + +/** + * This groovy class supports the DoDeleteE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion + * @param - failNotFound - TODO + * @param - serviceInputParams - TODO + * + * @param - delResourceList + * @param - serviceRelationShip + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DDEESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) + String msg = "" + + 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 + if (globalSubscriberId == null) + { + execution.setVariable("globalSubscriberId", "") + } + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + execution.setVariable("serviceType", "") + } + + //Generated in parent for AAI PUT + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.log("INFO","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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(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){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + public void postProcessAAIGET(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) + String msg = "" + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + String serviceType = "" + + if(foundInAAI){ + utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) + + String siData = execution.getVariable("GENGS_service") + utils.log("INFO", "SI Data", isDebugEnabled) + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + InputSource source = new InputSource(new StringReader(siData)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document serviceXml = docBuilder.parse(source) + serviceXml.getDocumentElement().normalize() + // get model invariant id + // Get Template uuid and version + if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { + utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled) + def modelInvariantId = serviceXml.getElementsByTagName("model-invariant-id").item(0).getTextContent() + def modelVersionId = serviceXml.getElementsByTagName("model-version-id").item(0).getTextContent() + + // Set Original Template info + execution.setVariable("model-invariant-id-original", modelInvariantId) + execution.setVariable("model-version-id-original", modelVersionId) + } + + utils.log("INFO", "SI Data" + siData, isDebugEnabled) + //Confirm there are no related service instances (vnf/network or volume) + if (utils.nodeExists(siData, "relationship-list")) { + utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled) + //test(siData) + NodeList nodeList = serviceXml.getElementsByTagName("relationship") + JSONArray jArray = new JSONArray() + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns + if(e.equals("service-instance")){ + def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() + utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled) + NodeList dataList = node.getChildNodes() + if(null != dataList) { + JSONObject jObj = new JSONObject() + for (int i = 0; i < dataList.getLength(); i++) { + Node dNode = dataList.item(i) + if(dNode.getNodeName() == "relationship-data") { + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() + if(eKey.equals("service-instance.service-instance-id")){ + jObj.put("resourceInstanceId", eValue) + } + + } + else if(dNode.getNodeName() == "related-to-property"){ + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() + if(eKey.equals("service-instance.service-instance-name")){ + jObj.put("resourceType", eValue) + } + } + } + utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) + jArray.put(jObj) + } + //for overlay/underlay + }else if (e.equals("configuration")){ + def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() + utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled) + NodeList dataList = node.getChildNodes() + if(null != dataList) { + JSONObject jObj = new JSONObject() + for (int i = 0; i < dataList.getLength(); i++) { + Node dNode = dataList.item(i) + if(dNode.getNodeName() == "relationship-data") { + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() + if(eKey.equals("configuration.configuration-id")){ + jObj.put("resourceInstanceId", eValue) + } + } + else if(dNode.getNodeName() == "related-to-property"){ + Element rDataEle = (Element)dNode + def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() + if(eKey.equals("configuration.configuration-type")){ + jObj.put("resourceType", eValue) + } + } + } + utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) + jArray.put(jObj) + } + } + } + } + execution.setVariable("serviceRelationShip", jArray.toString()) + } + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) + } + + public void getCurrentNS(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start getCurrentNS Process ======== ", isDebugEnabled) + + def currentIndex = execution.getVariable("currentNSIndex") + List nsSequence = execution.getVariable("nsSequence") + String nsResourceType = nsSequence.get(currentIndex) + + // GET AAI by Name, not ID, for process convenient + execution.setVariable("GENGS_type", "service-instance") + execution.setVariable("GENGS_serviceInstanceId", "") + execution.setVariable("GENGS_serviceInstanceName", nsResourceType) + + utils.log("INFO", "======== COMPLETED getCurrentNS Process ======== ", isDebugEnabled) + } + + public void prepareDecomposeService(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) + String modelInvariantUuid = execution.getVariable("model-invariant-id-original") + String modelVersionId = execution.getVariable("model-version-id-original") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelVersionId}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + utils.log("DEBUG", " ***** Completed prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void postDecomposeService(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside processDecomposition() of delete generic e2e service flow ***** ", isDebugEnabled) + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + // service model info + execution.setVariable("serviceModelInfo", serviceDecomposition.getModelInfo()) + + List deleteResourceList = serviceDecomposition.getServiceResources() + String serviceRelationShip = execution.getVariable("serviceRelationShip") + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + + List relationShipList = null + if (serviceRelationShip != null) { + relationShipList = jsonSlurper.parseText(serviceRelationShip) + } + + //Set the real resource instance id to the decomosed resource list + for (Resource resource: deleteResourceList) { + //reset the resource instance id , because in the decompose flow ,its a random one. + resource.setResourceId(""); + //match the resource-instance-name and the model name + if (relationShipList != null) { + relationShipList.each { + if (StringUtils.containsIgnoreCase(it.resourceType, resource.getModelInfo().getModelName())) { + resource.setResourceId(it.resourceInstanceId); + } + } + } + } + execution.setVariable("deleteResourceList", deleteResourceList) + utils.log("DEBUG", "delete resource list : " + deleteResourceList, isDebugEnabled) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("DEBUG", " ***** exit processDecomposition() of delete generic e2e service flow ***** ", isDebugEnabled) + } + + public void preInitResourcesOperStatus(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service creation" + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + List deleteResourceList = execution.getVariable("deleteResourceList") + + String serviceRelationShip = execution.getVariable("serviceRelationShip") + for(Resource resource : deleteResourceList){ + resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" + } + + + execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(resourceTemplateUUIDs)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) + utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + } + + /** + * post config request. + */ + public void postConfigRequest(execution){ + //to do + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy new file mode 100644 index 0000000000..3ee059cb02 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -0,0 +1,1077 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.springframework.web.util.UriUtils + +import groovy.json.* + +public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstance.class); + + String Prefix= "DELNWKI_" + String groovyClassName = "DoDeleteNetworkInstance" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "networkRequest", "") + execution.setVariable(Prefix + "isSilentSuccess", false) + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "requestId", "") + execution.setVariable(Prefix + "source", "") + execution.setVariable(Prefix + "lcpCloudRegion", "") + execution.setVariable(Prefix + "networkInputs", "") + execution.setVariable(Prefix + "tenantId", "") + + execution.setVariable(Prefix + "queryAAIRequest","") + execution.setVariable(Prefix + "queryAAIResponse", "") + execution.setVariable(Prefix + "aaiReturnCode", "") + execution.setVariable(Prefix + "isAAIGood", false) + execution.setVariable(Prefix + "isVfRelationshipExist", false) + + // AAI query Cloud Region + execution.setVariable(Prefix + "queryCloudRegionRequest","") + execution.setVariable(Prefix + "queryCloudRegionReturnCode","") + execution.setVariable(Prefix + "queryCloudRegionResponse","") + execution.setVariable(Prefix + "cloudRegionPo","") + execution.setVariable(Prefix + "cloudRegionSdnc","") + + execution.setVariable(Prefix + "deleteNetworkRequest", "") + execution.setVariable(Prefix + "deleteNetworkResponse", "") + execution.setVariable(Prefix + "networkReturnCode", "") + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + + execution.setVariable(Prefix + "deleteSDNCRequest", "") + execution.setVariable(Prefix + "deleteSDNCResponse", "") + execution.setVariable(Prefix + "sdncReturnCode", "") + execution.setVariable(Prefix + "sdncResponseSuccess", false) + + execution.setVariable(Prefix + "deactivateSDNCRequest", "") + execution.setVariable(Prefix + "deactivateSDNCResponse", "") + execution.setVariable(Prefix + "deactivateSdncReturnCode", "") + execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") + + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") + execution.setVariable(Prefix + "isException", false) + + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest() of " + groovyClassName + " Request ") + + // initialize flow variables + InitializeProcessVariables(execution) + + try { + // get incoming message/input + execution.setVariable("action", "DELETE") + String deleteNetwork = execution.getVariable("bpmnRequest") + if (deleteNetwork != null) { + if (deleteNetwork.contains("requestDetails")) { + // JSON format request is sent, create xml + try { + def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString()) + msoLogger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) + deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork) + + } catch (Exception ex) { + String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } else { + // XML format request is sent + + } + } else { + // vIPR format request is sent, create xml from individual variables + deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution) + } + + deleteNetwork = utils.formatXml(deleteNetwork) + msoLogger.debug(deleteNetwork) + execution.setVariable(Prefix + "networkRequest", deleteNetwork) + msoLogger.debug(Prefix + "networkRequest - " + '\n' + deleteNetwork) + + // validate 'backout-on-failure' to override 'mso.rollback' + boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork) + execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) + msoLogger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) + + String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","") + execution.setVariable(Prefix + "networkInputs", networkInputs) + + // prepare messageId + String messageId = execution.getVariable("testMessageId") // for testing + if (messageId == null || messageId == "") { + messageId = UUID.randomUUID() + msoLogger.debug(Prefix + "messageId, random generated: " + messageId) + } else { + msoLogger.debug(Prefix + "messageId, pre-assigned: " + messageId) + } + execution.setVariable(Prefix + "messageId", messageId) + + String source = utils.getNodeText(deleteNetwork, "source") + execution.setVariable(Prefix + "source", source) + msoLogger.debug(Prefix + "source - " + source) + + String networkId = "" + if (utils.nodeExists(networkInputs, "network-id")) { + networkId = utils.getNodeText(networkInputs, "network-id") + if (networkId == null || networkId == "" || networkId == 'null' ) { + sendSyncError(execution) + // missing value of network-id + String dataErrorMessage = "network-request has missing 'network-id' element/value." + msoLogger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + + // lcpCloudRegion or tenantId not sent, will be extracted from query AA&I + def lcpCloudRegion = null + if (utils.nodeExists(networkInputs, "aic-cloud-region")) { + lcpCloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + if (lcpCloudRegion == 'null') { + lcpCloudRegion = null + } + } + execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) + msoLogger.debug("lcpCloudRegion : " + lcpCloudRegion) + + String tenantId = null + if (utils.nodeExists(networkInputs, "tenant-id")) { + tenantId = utils.getNodeText(networkInputs, "tenant-id") + if (tenantId == 'null') { + tenantId = null + } + + } + execution.setVariable(Prefix + "tenantId", tenantId) + msoLogger.debug("tenantId : " + tenantId) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion? : " + sdncVersion) + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + msoLogger.debug(dataErrorMessage ) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + // caught exception + String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, PreProcessRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void callRESTQueryAAI (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAI() of DoDoDeleteNetworkInstance ***** " ) + + // get variables + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String networkId = utils.getNodeText(networkInputs, "network-id") + networkId = UriUtils.encode(networkId,"UTF-8") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + msoLogger.debug(queryAAIRequest) + execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest) + msoLogger.debug(Prefix + "AAIRequest - " + "\n" + queryAAIRequest) + + RESTConfig config = new RESTConfig(queryAAIRequest); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + Boolean isVfRelationshipExist = false + try { + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiReturnCode", returnCode) + + msoLogger.debug(" ***** AAI Response Code : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + execution.setVariable(Prefix + "queryAAIResponse", aaiResponseAsString) + + if (returnCode=='200' || returnCode=='204') { + msoLogger.debug(aaiResponseAsString) + execution.setVariable(Prefix + "isAAIGood", true) + msoLogger.debug(" AAI Query Success REST Response - " + "\n" + aaiResponseAsString) + // verify if vf or vnf relationship exist + if (utils.nodeExists(aaiResponseAsString, "relationship")) { + NetworkUtils networkUtils = new NetworkUtils() + isVfRelationshipExist = networkUtils.isVfRelationshipExist(aaiResponseAsString) + execution.setVariable(Prefix + "isVfRelationshipExist", isVfRelationshipExist) + if (isVfRelationshipExist == true) { + String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId + exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) + + } else { + // verify if lcpCloudRegion was sent as input, if not get value from AAI Response + if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) { + String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString) + execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) + msoLogger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion) + } + if (execution.getVariable(Prefix + "tenantId") == null ) { + String tenantId = networkUtils.getTenantId(aaiResponseAsString) + execution.setVariable(Prefix + "tenantId", tenantId) + msoLogger.debug(" Get AAI getTenantId() : " + tenantId) + } + + } + } + msoLogger.debug(Prefix + "isVfRelationshipExist - " + isVfRelationshipExist) + + } else { + execution.setVariable(Prefix + "isAAIGood", false) + if (returnCode=='404' || aaiResponseAsString == "" || aaiResponseAsString == null) { + // not found // empty aai response + execution.setVariable(Prefix + "isSilentSuccess", true) + msoLogger.debug(" AAI Query is Silent Success") + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Error Response from callRESTQueryAAI() - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + msoLogger.debug(" AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood")) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAICloudRegion (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " ) + + try { + String networkInputs = execution.getVariable(Prefix + "networkInputs") + // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion") + cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + msoLogger.debug(queryCloudRegionRequest) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) + + String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) + + if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { + execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) + execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) + + } else { + String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareNetworkRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareNetworkRequest of DoDeleteNetworkInstance ") + ExceptionUtil exceptionUtil = new ExceptionUtil() + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo") + String tenantId = execution.getVariable(Prefix + "tenantId") + + String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") + String networkType = utils.getNodeText(queryAAIResponse, "network-type") + String networkId = utils.getNodeText(queryAAIResponse, "network-id") + String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") + + String networkStackId = "" + networkStackId = utils.getNodeText(queryAAIResponse, "heat-stack-id") + if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { + networkStackId = "force_delete" + } + + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // Added new Elements + String messageId = execution.getVariable(Prefix + "messageId") + String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? + //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? + + String modelCustomizationUuid = "" + if (utils.nodeExists(networkRequest, "networkModelInfo")) { + String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") + modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") + } else { + modelCustomizationUuid = utils.getNodeText(networkRequest, "modelCustomizationId") + } + + String deleteNetworkRequest = """ + + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(networkId)} + ${MsoUtils.xmlEscape(networkStackId)} + ${MsoUtils.xmlEscape(networkType)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + true + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """.trim() + + msoLogger.debug(Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest) + // Format Response + String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest) + msoLogger.debug(buildDeleteNetworkRequestAsString) + msoLogger.debug(Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString) + + String restURL = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint", execution) + execution.setVariable("mso.adapters.network.rest.endpoint", restURL + "/" + networkId) + msoLogger.debug("mso.adapters.network.rest.endpoint - " + "\n" + restURL + "/" + networkId) + + execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString) + msoLogger.debug(Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString) + } + catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + } + + /** + * This method is used instead of an HTTP Connector task because the + * connector does not allow DELETE with a body. + */ + public void sendRequestToVnfAdapter(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + + String vnfAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution) + String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest") + + RESTConfig config = new RESTConfig(vnfAdapterUrl) + RESTClient client = new RESTClient(config). + addHeader("Content-Type", "application/xml"). + addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO")); + + APIResponse response; + + response = client.httpDelete(vnfAdapterRequest) + + execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode()) + execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString()) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, exceptionMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + } + + + public void prepareSDNCRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareSDNCRequest of DoDeleteNetworkInstance ") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} + + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + msoLogger.debug(Prefix + "requestId " + requestId) + String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) + msoLogger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) + msoLogger.debug(Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, exceptionMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRpcSDNCRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} + + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + msoLogger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) + msoLogger.debug(Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, exceptionMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void prepareRpcSDNCDeactivate(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ") + + try { + + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + msoLogger.debug(" Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void validateNetworkResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside validateNetworkResponse of DoDeleteNetworkInstance ") + + try { + String returnCode = execution.getVariable(Prefix + "networkReturnCode") + String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse") + + msoLogger.debug(" Network Adapter responseCode: " + returnCode) + msoLogger.debug("Network Adapter Response - " + "\n" + networkResponse) + msoLogger.debug(networkResponse) + + String errorMessage = "" + if (returnCode == "200") { + msoLogger.debug(" Network Adapter Response is successful - " + "\n" + networkResponse) + + // prepare rollback data + String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") + if ((rollbackData == null) || (rollbackData.isEmpty())) { + msoLogger.debug(" Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse) + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + } else { + String rollbackNetwork = + """ + ${rollbackData} + """ + String rollbackNetworkXml = utils.formatXml(rollbackNetwork) + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) + msoLogger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) + } + + + } else { // network error + if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx + if (networkResponse.contains("deleteNetworkError") ) { + networkResponse = networkResponse.replace('', '') + errorMessage = utils.getNodeText(networkResponse, "message") + errorMessage = "Received error from Network Adapter: " + errorMessage + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + + } else { // CatchAll exception + if (returnCode == "500") { + errorMessage = "JBWEB000065: HTTP Status 500." + } else { + errorMessage = "Return code is " + returnCode + } + errorMessage = "Received error from Network Adapter: " + errorMessage + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + + } + + } else { // CatchAll exception + String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void validateSDNCResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside validateSDNCResponse of DoDeleteNetworkInstance ") + + String response = execution.getVariable(Prefix + "deleteSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String deleteSDNCResponseDecodeXml = execution.getVariable(Prefix + "deleteSDNCResponse") + deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace('', "") + execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml) + + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncRollbackNeeded", true) // + execution.setVariable(Prefix + "isPONR", true) + msoLogger.debug("Successfully Validated SDNC Response") + } else { + msoLogger.debug("Did NOT Successfully Validated SDNC Response") + throw new BpmnError("MSOWorkflowException") + } + + } + + public void validateRpcSDNCDeactivateResponse (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ") + + String response = execution.getVariable(Prefix + "deactivateSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "deactivateSDNCResponse") + assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('', "") + execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml) + + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true) + msoLogger.debug("Successfully Validated Rpc SDNC Activate Response") + + } else { + msoLogger.debug("Did NOT Successfully Validated Rpc SDNC Deactivate Response") + throw new BpmnError("MSOWorkflowException") + } + + } + + public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ") + + try { + + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse") + String networkId = utils.getNodeText(deactivateSDNCResponse, "network-id") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + msoLogger.debug(" Preparing request for RPC SDNC Topology 'activate-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRollbackData() of DoDeleteNetworkInstance ") + + try { + + Map rollbackData = new HashMap(); + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") + if (rollbackDeactivateSDNCRequest != null) { + if (rollbackDeactivateSDNCRequest != "") { + rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + msoLogger.debug("** rollbackData : " + rollbackData) + + execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) + msoLogger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void postProcessResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside postProcessResponse of DoDeleteNetworkInstance ") + + try { + + msoLogger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) + if (execution.getVariable(Prefix + "isException") == false) { + execution.setVariable(Prefix + "Success", true) + execution.setVariable("WorkflowException", null) + if (execution.getVariable(Prefix + "isSilentSuccess") == true) { + execution.setVariable("rolledBack", false) + } else { + execution.setVariable("rolledBack", true) + } + prepareSuccessRollbackData(execution) // populate rollbackData + + } else { + execution.setVariable(Prefix + "Success", false) + execution.setVariable("rollbackData", null) + String exceptionMessage = " Exception encountered in MSO Bpmn. " + if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. + msoLogger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) + WorkflowException wfex = execution.getVariable("workflowException") + exceptionMessage = wfex.getErrorMessage() + } else { + if (execution.getVariable(Prefix + "WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } else { + if (execution.getVariable("WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable("WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } + } + } + + // going to the Main flow: a-la-carte or macro + msoLogger.debug(" ***** postProcessResponse(), BAD !!!") + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + + } + + } catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + + } + + } + + public void prepareSuccessRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ") + + try { + + if (execution.getVariable("sdncVersion") != '1610') { + prepareRpcSDNCDeactivateRollback(execution) + prepareRpcSDNCUnassignRollback(execution) + } else { + prepareSDNCRollback(execution) + } + + Map rollbackData = new HashMap(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") + if (rollbackDeactivateSDNCRequest != null) { + if (rollbackDeactivateSDNCRequest != "") { + rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("** rollbackData : " + rollbackData) + execution.setVariable("WorkflowException", null) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ") + + try { + + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse") + String networkId = utils.getNodeText(deleteSDNCResponse, "network-id") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + msoLogger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) + msoLogger.debug(Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString) + msoLogger.debug(" Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareSDNCRollback (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareSDNCRollback of DoDeleteNetworkInstance ") + + try { + + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} + + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + + String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) + msoLogger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) + msoLogger.debug(Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) + msoLogger.debug(" Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) + + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, exceptionMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void setExceptionFlag(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside setExceptionFlag() of DoDeleteNetworkInstance ") + + try { + + execution.setVariable(Prefix + "isException", true) + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + msoLogger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) + + } catch(Exception ex){ + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + public void processJavaException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a Java Exception") + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") + } + msoLogger.debug("Completed processJavaException Method of " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy new file mode 100644 index 0000000000..ca6e21eedc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy @@ -0,0 +1,338 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoCreateNetworkInstanceRollback.bpmn process. + * + */ +public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstanceRollback.class); + + String Prefix="DELNWKIR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the DoDeleteNetworkInstanceRollback.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "WorkflowException", null) + + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", null) + execution.setVariable(Prefix + "rollbackDeactivateSDNCResponse", "") + execution.setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "") + + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + execution.setVariable(Prefix + "rollbackSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") + + execution.setVariable(Prefix + "rollbackNetworkRequest", null) + execution.setVariable(Prefix + "rollbackNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") + + execution.setVariable(Prefix + "Success", false) + execution.setVariable(Prefix + "fullRollback", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the DoDeleteNetworkInstanceRollback.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy ") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request/variables + String rollbackDeactivateSDNCRequest = null + String rollbackSDNCRequest = null + String rollbackNetworkRequest = null + + Map rollbackData = execution.getVariable("rollbackData") + if (rollbackData != null && rollbackData instanceof Map) { + + if(rollbackData.containsKey("rollbackDeactivateSDNCRequest")) { + rollbackDeactivateSDNCRequest = rollbackData["rollbackDeactivateSDNCRequest"] + } + + if(rollbackData.containsKey("rollbackSDNCRequest")) { + rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] + } + + if(rollbackData.containsKey("rollbackNetworkRequest")) { + rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] + } + } + + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", rollbackDeactivateSDNCRequest) + msoLogger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion? : " + sdncVersion) + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + msoLogger.debug(dataErrorMessage ) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + msoLogger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) + if(execution.getVariable(Prefix + "WorkflowException") != null) { + // called by: DoCreateNetworkInstance, partial rollback + execution.setVariable(Prefix + "fullRollback", false) + + } else { + // called by: Macro - Full Rollback, WorkflowException = null + execution.setVariable(Prefix + "fullRollback", true) + + } + + msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void validateRollbackResponses (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateRollbackResponses() of DoDeleteNetworkInstanceRollback ") + + try { + + // validate SDNC activate response + String rollbackDeactivateSDNCMessages = "" + String rollbackDeactivateSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") != null) { + rollbackDeactivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode") + String rollbackDeactivateSDNCResponse = execution.getVariable(Prefix + "rollbackDeactivateSDNCResponse") + String rollbackDeactivateSDNCReturnInnerCode = "" + rollbackDeactivateSDNCResponse = rollbackDeactivateSDNCResponse.replace('$', '').replace('', "") + if (rollbackDeactivateSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackDeactivateSDNCResponse, "response-code")) { + rollbackDeactivateSDNCReturnInnerCode = utils.getNodeText(rollbackDeactivateSDNCResponse, "response-code") + if (rollbackDeactivateSDNCReturnInnerCode == "200" || rollbackDeactivateSDNCReturnInnerCode == "" || rollbackDeactivateSDNCReturnInnerCode == "0") { + rollbackDeactivateSDNCMessages = " + SNDC deactivate rollback completed." + } else { + rollbackDeactivateSDNCMessages = " + SDNC deactivate rollback failed. " + } + } else { + rollbackDeactivateSDNCMessages = " + SNDC deactivate rollback completed." + } + } else { + rollbackDeactivateSDNCMessages = " + SDNC deactivate rollback failed. " + } + msoLogger.debug(" SDNC deactivate rollback Code - " + rollbackDeactivateSDNCReturnCode) + msoLogger.debug(" SDNC deactivate rollback Response - " + rollbackDeactivateSDNCResponse) + } + + // validate SDNC rollback response + String rollbackSdncErrorMessages = "" + String rollbackSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { + rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") + String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") + String rollbackSDNCReturnInnerCode = "" + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('', "") + if (rollbackSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { + rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") + if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { + rollbackSdncErrorMessages = " + SNDC unassign rollback completed." + } else { + rollbackSdncErrorMessages = " + SDNC unassign rollback failed. " + } + } else { + rollbackSdncErrorMessages = " + SNDC unassign rollback completed." + } + } else { + rollbackSdncErrorMessages = " + SDNC unassign rollback failed. " + } + msoLogger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode) + msoLogger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse) + } + + // validate PO network rollback response + String rollbackNetworkErrorMessages = "" + String rollbackNetworkReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { + rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") + String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse") + if (rollbackNetworkReturnCode != "200") { + rollbackNetworkErrorMessages = " + PO Network rollback failed. " + } else { + rollbackNetworkErrorMessages = " + PO Network rollback completed." + } + + msoLogger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) + msoLogger.debug(" NetworkRollback Response - " + rollbackNetworkResponse) + } + + String statusMessage = "" + int errorCode = 7000 + msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + if (execution.getVariable(Prefix + "fullRollback") == false) { + WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") // original WorkflowException + if (wfe != null) { + statusMessage = wfe.getErrorMessage() + errorCode = wfe.getErrorCode() + } else { + statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + errorCode = '7000' + } + + // set if all rolledbacks are successful + if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { + execution.setVariable("rolledBack", true) + execution.setVariable("wasDeleted", true) + + } else { + execution.setVariable("rolledBack", false) + execution.setVariable("wasDeleted", true) + } + + statusMessage = statusMessage + rollbackDeactivateSDNCMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages + msoLogger.debug("Final DoDeleteNetworkInstanceRollback status message: " + statusMessage) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); + execution.setVariable("workflowException", exception); + + } else { + // rollback due to failures in Main flow (Macro or a-ala-carte) - Full rollback + if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { + execution.setVariable("rollbackSuccessful", true) + execution.setVariable("rollbackError", false) + } else { + String exceptionMessage = "Network Delete Rollback was not Successful. " + msoLogger.debug(exceptionMessage) + execution.setVariable("rollbackSuccessful", false) + execution.setVariable("rollbackError", true) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } + } + + } catch (Exception ex) { + String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ******************************* + // Build Error Section + // ******************************* + + + + public void processJavaException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + try{ + msoLogger.debug("Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.debug("Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResources.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResources.groovy new file mode 100644 index 0000000000..f6dd0cad16 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResources.groovy @@ -0,0 +1,317 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import org.json.JSONArray; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceInstance +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.rest.APIResponse; +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import java.util.List; +import java.util.UUID; +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + +import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoDeleteResources.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) + * @param - sdncVersion + * @param - failNotFound - TODO + * @param - serviceInputParams - TODO + * + * @param - delResourceList + * @param - serviceRelationShip + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoDeleteResources extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteResources.class); + + String Prefix="DDELR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + msoLogger.trace("preProcessRequest ") + String msg = "" + + List realNSRessources = new ArrayList() + + // related ns from AAI + String serviceRelationShip = execution.getVariable("serviceRelationShip") + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + List nsSequence = new ArrayList() + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + if (relationShipList != null) { + relationShipList.each { + String resourceType = it.resourceType + nsSequence.add(resourceType) + } + } + + execution.setVariable("currentNSIndex", 0) + execution.setVariable("nsSequence", nsSequence) + execution.setVariable("realNSRessources", realNSRessources) + msoLogger.info("nsSequence: " + nsSequence) + + msoLogger.trace("Exit preProcessRequest ") + } + + public void getCurrentNS(execution){ + msoLogger.trace("Start getCurrentNS Process ") + + def currentIndex = execution.getVariable("currentNSIndex") + List nsSequence = execution.getVariable("nsSequence") + String nsResourceType = nsSequence.get(currentIndex) + + // GET AAI by Name, not ID, for process convenient + execution.setVariable("GENGS_type", "service-instance") + execution.setVariable("GENGS_serviceInstanceId", "") + execution.setVariable("GENGS_serviceInstanceName", nsResourceType) + + msoLogger.trace("COMPLETED getCurrentNS Process ") + } + + public void postProcessAAIGET(DelegateExecution execution) { + msoLogger.trace("postProcessAAIGET2 ") + String msg = "" + + try { + String nsResourceName = execution.getVariable("GENGS_serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error getting Service-instance from AAI in postProcessAAIGET", + nsResourceName) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + String aaiService = execution.getVariable("GENGS_service") + if (!isBlank(aaiService)) { + String svcId = utils.getNodeText(aaiService, "service-instance-id") + //String mn = utils.getNodeText(aaiService, "model-name") + String mIuuid = utils.getNodeText(aaiService, "model-invariant-id") + String muuid = utils.getNodeText(aaiService, "model-version-id") + String mCuuid = utils.getNodeText(aaiService, "model-customization-uuid") + ServiceInstance rc = new ServiceInstance() + ModelInfo modelInfo = new ModelInfo() + //modelInfo.setModelName(mn) + modelInfo.setModelUuid(muuid) + modelInfo.setModelInvariantUuid(mIuuid) + modelInfo.getModelCustomizationUuid(mCuuid) + rc.setModelInfo(modelInfo) + rc.setInstanceId(svcId) + rc.setInstanceName(nsResourceName) + + List realNSRessources = execution.getVariable("realNSRessources") + realNSRessources.add(rc) + execution.setVariable("realNSRessources", realNSRessources) + + msoLogger.info("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName")) + } + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteResources.postProcessAAIGET " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET ") + } + + public void parseNextNS(execution){ + msoLogger.trace("Start parseNextNS Process ") + def currentIndex = execution.getVariable("currentNSIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentNSIndex", nextIndex) + List nsSequence = execution.getVariable("nsSequence") + if(nextIndex >= nsSequence.size()){ + execution.setVariable("allNsFinished", "true") + }else{ + execution.setVariable("allNsFinished", "false") + } + msoLogger.trace("COMPLETED parseNextNS Process ") + } + + + public void sequenceResource(execution){ + msoLogger.trace("STARTED sequenceResource Process ") + List nsResources = new ArrayList() + List wanResources = new ArrayList() + List resourceSequence = new ArrayList() + + // get delete resource list and order list + List delResourceList = execution.getVariable("delResourceList") + // existing resource list + List existResourceList = execution.getVariable("realNSRessources") + + for(ServiceInstance rc_e : existResourceList){ + + String muuid = rc_e.getModelInfo().getModelUuid() + String mIuuid = rc_e.getModelInfo().getModelInvariantUuid() + String mCuuid = rc_e.getModelInfo().getModelCustomizationUuid() + rcType = rc_e.getInstanceName() + + for(Resource rc_d : delResourceList){ + + if(rc_d.getModelInfo().getModelUuid() == muuid + && rc_d.getModelInfo().getModelInvariantUuid() == mIuuid + && rc_d.getModelInfo().getModelCustomizationUuid() == mCuuid) { + + if(StringUtils.containsIgnoreCase(rcType, "overlay") + || StringUtils.containsIgnoreCase(rcType, "underlay")){ + wanResources.add(rcType) + }else{ + nsResources.add(rcType) + } + + } + } + + } + + resourceSequence.addAll(wanResources) + resourceSequence.addAll(nsResources) + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("resourceSequence", resourceSequence) + msoLogger.info("resourceSequence: " + resourceSequence) + execution.setVariable("wanResources", wanResources) + msoLogger.trace("END sequenceResource Process ") + } + + public void getCurrentResource(execution){ + msoLogger.trace("Start getCurrentResoure Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + List resourceSequence = execution.getVariable("resourceSequence") + List wanResources = execution.getVariable("wanResources") + String resourceName = resourceSequence.get(currentIndex) + execution.setVariable("resourceType",resourceName) + if(wanResources.contains(resourceName)){ + execution.setVariable("controllerInfo", "SDN-C") + }else{ + execution.setVariable("controllerInfo", "VF-C") + } + msoLogger.trace("COMPLETED getCurrentResoure Process ") + } + + /** + * prepare delete parameters + */ + public void preResourceDelete(execution, resourceName){ + + msoLogger.trace("STARTED preResourceDelete Process ") + + List existResourceList = execution.getVariable("realNSRessources") + + for(ServiceInstance rc_e : existResourceList){ + + if(StringUtils.containsIgnoreCase(rc_e.getInstanceName(), resourceName)) { + + String resourceInstanceUUID = rc_e.getInstanceId() + String resourceTemplateUUID = rc_e.getModelInfo().getModelUuid() + execution.setVariable("resourceInstanceId", resourceInstanceUUID) + execution.setVariable("resourceTemplateId", resourceTemplateUUID) + execution.setVariable("resourceType", resourceName) + msoLogger.info("Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName) + } + } + + msoLogger.trace("END preResourceDelete Process ") + } + + public void parseNextResource(execution){ + msoLogger.trace("Start parseNextResource Process ") + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List resourceSequence = execution.getVariable("resourceSequence") + if(nextIndex >= resourceSequence.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + msoLogger.trace("COMPLETED parseNextResource Process ") + } + + /** + * post config request. + */ + public void postConfigRequest(execution){ + //to do + } + +} + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy new file mode 100644 index 0000000000..a5a96f3bd3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy @@ -0,0 +1,400 @@ + +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.isBlank + +import org.apache.commons.lang3.StringUtils +import org.apache.http.HttpResponse +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONObject +import org.onap.so.bpmn.common.recipe.BpmnRestClient +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.domain.AllottedResource +import org.onap.so.bpmn.core.domain.NetworkResource +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.properties.BPMNProperties +import org.onap.so.logger.MsoLogger + +/** + * input for script : + * msoRequestId + * isDebugLogEnabled + * globalSubscriberId + * serviceType + * serviceInstanceId + * URN_mso_workflow_sdncadapter_callback + * serviceInputParams + * deleteResourceList + * resourceInstanceIDs + * + * output from script: + * + */ + +public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteResourcesV1.class); + + String Prefix="DDR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) + String msg = "" + + 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 + if (globalSubscriberId == null) + { + execution.setVariable("globalSubscriberId", "") + } + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + if (serviceType == null) + { + execution.setVariable("serviceType", "") + } + + //Generated in parent for AAI PUT + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (isBlank(sdncCallbackUrl)) { + msg = "URN_mso_workflow_sdncadapter_callback is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.log("INFO","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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(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){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + public void sequenceResource(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled) + List sequencedResourceList = new ArrayList() + List wanResources = new ArrayList() + + // get delete resource list and order list + List delResourceList = execution.getVariable("deleteResourceList") + + def resourceSequence = BPMNProperties.getResourceSequenceProp() + + if(resourceSequence != null) { + for (resourceType in resourceSequence.reverse()) { + for (resource in delResourceList) { + if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { + sequencedResourceList.add(resource) + + if (resource instanceof NetworkResource) { + wanResources.add(resource) + } + } + } + } + }else { + //define sequenced resource list, we deploy vf first and then network and then ar + //this is defaule sequence + List vnfResourceList = new ArrayList() + List arResourceList = new ArrayList() + for (Resource rc : delResourceList) { + if (rc instanceof VnfResource) { + vnfResourceList.add(rc) + } else if (rc instanceof NetworkResource) { + wanResources.add(rc) + } else if (rc instanceof AllottedResource) { + arResourceList.add(rc) + } + } + + sequencedResourceList.addAll(arResourceList) + sequencedResourceList.addAll(wanResources) + sequencedResourceList.addAll(vnfResourceList) + } + + String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" + execution.setVariable("isContainsWanResource", isContainsWanResource) + execution.setVariable("currentResourceIndex", 0) + execution.setVariable("sequencedResourceList", sequencedResourceList) + utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) + utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled) + } + + /** + * prepare delete parameters + */ + public void preResourceDelete(DelegateExecution execution){ + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("INFO", " ======== STARTED preResourceDelete Process ======== ", isDebugEnabled) + + List sequencedResourceList = execution.getVariable("sequencedResourceList") + + int currentIndex = execution.getVariable("currentResourceIndex") + Resource curResource = sequencedResourceList.get(currentIndex); + + String resourceInstanceUUID = curResource.getResourceId() + String resourceTemplateUUID = curResource.getModelInfo().getModelUuid() + execution.setVariable("resourceInstanceId", resourceInstanceUUID) + execution.setVariable("currentResource", curResource) + utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + + resourceInstanceUUID + " resourceModelName: " + curResource.getModelInfo().getModelName(), isDebugEnabled) + + utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled) + } + + + /** + * Execute delete workflow for resource + */ + public void executeResourceDelete(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start executeResourceDelete Process ======== ", isDebugEnabled) + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceType = execution.getVariable("serviceType") + + String resourceInstanceId = execution.getVariable("resourceInstanceId") + + Resource currentResource = execution.getVariable("currentResource") + String action = "deleteInstance" + JSONObject resourceRecipe = cutils.getResourceRecipe(execution, currentResource.getModelInfo().getModelUuid(), action) + String recipeUri = resourceRecipe.getString("orchestrationUri") + int recipeTimeout = resourceRecipe.getInt("recipeTimeout") + String recipeParamXsd = resourceRecipe.get("paramXSD") + + + ResourceInput resourceInput = new ResourceInput(); + resourceInput.setServiceInstanceId(serviceInstanceId) + resourceInput.setResourceInstanceName(currentResource.getResourceInstanceName()) + resourceInput.setResourceInstancenUuid(currentResource.getResourceId()) + resourceInput.setOperationId(execution.getVariable("operationId")) + resourceInput.setOperationType(execution.getVariable("operationType")) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + resourceInput.setGlobalSubscriberId(globalSubscriberId) + resourceInput.setResourceModelInfo(currentResource.getModelInfo()); + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); + resourceInput.setServiceType(serviceType) + + String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + recipeUri + + HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeout, action, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) + utils.log("INFO", " ======== END executeResourceDelete Process ======== ", isDebugEnabled) + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug("Error occured within DoDeleteResourcesV1 executeResourceDelete method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured during DoDeleteResourcesV1 executeResourceDelete Catalog") + } + } + + + public void parseNextResource(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) + def currentIndex = execution.getVariable("currentResourceIndex") + def nextIndex = currentIndex + 1 + execution.setVariable("currentResourceIndex", nextIndex) + List sequencedResourceList = execution.getVariable("sequencedResourceList") + if(nextIndex >= sequencedResourceList.size()){ + execution.setVariable("allResourceFinished", "true") + }else{ + execution.setVariable("allResourceFinished", "false") + } + utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) + } + + public void prepareFinishedProgressForResource(DelegateExecution execution) { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceType = execution.getVariable("serviceType") + String resourceInstanceId = execution.getVariable("resourceInstanceId") + Resource currentResource = execution.getVariable("currentResource") + String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid() + String resourceModelName = currentResource.getModelInfo().getModelName() + String operationType = execution.getVariable("operationType") + String progress = "100" + String status = "finished" + String statusDescription = "The resource instance does not exist for " + resourceModelName + String operationId = execution.getVariable("operationId") + + String body = """ + + + + + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(resourceCustomizationUuid)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(statusDescription)} + + + """; + + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + execution.setVariable("CVFMI_updateResOperStatusRequest", body) + } + + public void prepareSDNCServiceDeactivateRequest (DelegateExecution execution) { + prepareSDNCServiceRequest (execution, "deactivate") + } + + public void prepareSDNCServiceDeleteRequest (DelegateExecution execution) { + prepareSDNCServiceRequest (execution, "delete") + } + + public void prepareSDNCServiceRequest (DelegateExecution execution, String svcAction) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** Started prepareSDNCServiceRequest for " + svcAction + "*****", isDebugEnabled) + + try { + // get variables + String sdnc_svcAction = svcAction + String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") + String hdrRequestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + String sdnc_service_id = serviceInstanceId + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String serviceType = execution.getVariable("serviceType") + String globalCustomerId = execution.getVariable("globalSubscriberId") + String serviceModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid() + String serviceModelUuid = serviceDecomposition.getModelInfo().getModelUuid() + String serviceModelVersion = serviceDecomposition.getModelInfo().getModelVersion() + String serviceModelName = serviceDecomposition.getModelInfo().getModelName() + + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyDeleteRequest = + """ + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(sdnc_svcAction)} + service-topology-operation + sdncCallback + generic-resource + + + + ${MsoUtils.xmlEscape(hdrRequestId)} + DeleteServiceInstance + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceType)} + + ${MsoUtils.xmlEscape(serviceModelInvariantUuid)} + ${MsoUtils.xmlEscape(serviceModelUuid)} + ${MsoUtils.xmlEscape(serviceModelVersion)} + ${MsoUtils.xmlEscape(serviceModelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(globalCustomerId)} + + + + + """.trim() + + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) + utils.logAudit(sndcTopologyDeleteRequesAsString) + execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyDeleteRequesAsString) + utils.log("INFO","sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteResourcesV1 flow. prepareSDNCServiceRequest() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + utils.log("INFO","***** Exit prepareSDNCServiceRequest for " + svcAction + "*****", isDebugEnabled) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy new file mode 100644 index 0000000000..198144ad34 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -0,0 +1,472 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.springframework.web.util.UriUtils; +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + +import groovy.json.* + +/** + * This groovy class supports the DoDeleteServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @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 + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteServiceInstance.class); + + String Prefix="DDELSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + + msoLogger.trace("preProcessRequest ") + String msg = "" + + 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 + if (globalSubscriberId == null) + { + execution.setVariable("globalSubscriberId", "") + } + + //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + if (subscriptionServiceType == null) + { + execution.setVariable("subscriptionServiceType", "") + } + + //Generated in parent for AAI PUT + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String sdncCallbackUrl = UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution) + if (isBlank(sdncCallbackUrl)) { + msg = "mso.workflow.sdncadapter.callback is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + + 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 = + """ + ${MsoUtils.xmlEscape(paramName)} + ${MsoUtils.xmlEscape(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){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void preProcessSDNCDelete (DelegateExecution execution) { + + msoLogger.trace("preProcessSDNCDelete ") + String msg = "" + + try { + def serviceInstanceId = execution.getVariable("serviceInstanceId") ?: "" + def serviceInstanceName = execution.getVariable("serviceInstanceName") ?: "" + def callbackURL = execution.getVariable("sdncCallbackUrl") ?: "" + def requestId = execution.getVariable("msoRequestId") ?: "" + def serviceId = execution.getVariable("productFamilyId") ?: "" + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") ?: "" + def globalSubscriberId = execution.getVariable("globalSubscriberId") ?: "" //globalCustomerId + + String serviceModelInfo = execution.getVariable("serviceModelInfo") ?: "" + def modelInvariantUuid = "" + def modelVersion = "" + def modelUuid = "" + def modelName = "" + if (!isBlank(serviceModelInfo)) + { + modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") ?: "" + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") ?: "" + modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") ?: "" + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") ?: "" + + } + + def siParamsXml = execution.getVariable("siParamsXml") ?: "" + def msoAction = "" + // special URL for SDNW, msoAction helps set diff url in SDNCA + if("TRANSPORT".equalsIgnoreCase(execution.getVariable("serviceType"))) + { + msoAction = "TRANSPORT" + } + + def sdncRequestId = UUID.randomUUID().toString() + + String sdncDelete = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + delete + service-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + ${MsoUtils.xmlEscape(msoAction)} + + + + ${MsoUtils.xmlEscape(requestId)} + MSO + + + + DeleteServiceInstance + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${siParamsXml} + + + """ + + sdncDelete = utils.formatXml(sdncDelete) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + execution.setVariable("sdncDelete", sdncDelete) + execution.setVariable("sdncDeactivate", sdncDeactivate) + msoLogger.debug("sdncDeactivate:\n" + sdncDeactivate) + msoLogger.debug("sdncDelete:\n" + sdncDelete) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) + } + msoLogger.debug(" *****Exit preProcessSDNCDelete *****") + } + + public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) { + + + msoLogger.trace("postProcessSDNC " + method + " ") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Good response from SDNC Adapter for service-instance " + method + "response:\n" + response) + + }else{ + msg = "Bad Response from SDNC Adapter for service-instance " + method + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessSDNC " + method + " ") + } + + public void postProcessAAIGET(DelegateExecution execution) { + + msoLogger.trace("postProcessAAIGET ") + String msg = "" + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + String serviceType = "" + + if(foundInAAI == true){ + msoLogger.debug("Found Service-instance in AAI") + + //Extract GlobalSubscriberId + String siRelatedLink = execution.getVariable("GENGS_siResourceLink") + if (isBlank(siRelatedLink)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + msoLogger.debug("Found Service-instance in AAI. link: " + siRelatedLink) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if(isBlank(globalSubscriberId)){ + int custStart = siRelatedLink.indexOf("customer/") + int custEnd = siRelatedLink.indexOf("/service-subscriptions") + globalSubscriberId = siRelatedLink.substring(custStart + 9, custEnd) + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //Extract Service Type if not provided on request + 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) + subscriptionServiceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + if (isBlank(globalSubscriberId) || isBlank(subscriptionServiceType)) + { + msg = "Could not retrive global-customer-id & subscription-service-type from AAI to delete id:" + serviceInstanceId + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + String siData = execution.getVariable("GENGS_service") + msoLogger.debug("SI Data") + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + msoLogger.debug("SI Data" + siData) + serviceType = utils.getNodeText(siData,"service-type") + execution.setVariable("serviceType", serviceType) + execution.setVariable("serviceRole", utils.getNodeText(siData,"service-role")) + String orchestrationStatus = utils.getNodeText(siData,"orchestration-status") + + //Confirm there are no related service instances (vnf/network or volume) + if (utils.nodeExists(siData, "relationship-list")) { + msoLogger.debug("SI Data relationship-list exists:") + InputSource source = new InputSource(new StringReader(siData)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document serviceXml = docBuilder.parse(source) + + NodeList nodeList = serviceXml.getElementsByTagName("relationship") + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() + if(e.equals("generic-vnf") || e.equals("l3-network") || e.equals("allotted-resource") ){ + msoLogger.debug("ServiceInstance still has relationship(s) to generic-vnfs, l3-networks or allotted-resources") + execution.setVariable("siInUse", true) + //there are relationship dependencies to this Service Instance + msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + }else{ + msoLogger.debug("Relationship NOT related to OpenStack") + } + } + } + } + + 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 + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + } + + //alacarte SIs are NOT sent to sdnc. exceptions are listed in config variable + String svcTypes = UrnPropertiesReader.getVariable("sdnc.si.svc.types",execution) ?: "" + msoLogger.debug("SDNC SI serviceTypes:" + svcTypes) + List svcList = Arrays.asList(svcTypes.split("\\s*,\\s*")); + boolean isSdncService= false + for (String listEntry : svcList){ + if (listEntry.equalsIgnoreCase(serviceType)){ + isSdncService = true + break; + } + } + + //All Macros are sent to SDNC, TRANSPORT(Macro) is sent to SDNW + //Alacartes are sent to SDNC if they are listed in config variable above + execution.setVariable("sendToSDNC", true) + if(execution.getVariable("sdncVersion").equals("1610")) //alacarte + { + if(!isSdncService){ + execution.setVariable("sendToSDNC", false) + } + } + + msoLogger.debug("isSdncService: " + isSdncService) + msoLogger.debug("Send To SDNC: " + execution.getVariable("sendToSDNC")) + msoLogger.debug("Service Type: " + execution.getVariable("serviceType")) + + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(succInAAI != true){ + msoLogger.debug("Error getting Service-instance from AAI", + serviceInstanceId) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + msoLogger.debug("Service-instance NOT found in AAI. Silent Success") + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteServiceInstance.postProcessAAIGET. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET ") + } + + /** + * Deletes the service instance in aai + */ + public void deleteServiceInstance(DelegateExecution execution) { + msoLogger.trace("Entered deleteServiceInstance") + try { + String globalCustId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + resourceClient.delete(serviceInstanceUri) + + msoLogger.trace("Exited deleteServiceInstance") + }catch(Exception e){ + msoLogger.debug("Error occured within deleteServiceInstance method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteServiceInstance from aai") + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy new file mode 100644 index 0000000000..0069bf4f0a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@ -0,0 +1,285 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig + +import groovy.json.* + +/** + * This groovy class supports the DoDeleteVFCNetworkServiceInstance.bpmn process. + * flow for E2E ServiceInstance Delete + */ +public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVFCNetworkServiceInstance.class); + + + String vfcUrl = "/vfc/rest/v1/vfcadapter" + + String host = "http://mso.mso.testlab.openecomp.org:8080" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + */ + public void preProcessRequest (DelegateExecution execution) { + + String msg = "" + msoLogger.trace("preProcessRequest() ") + try { + //deal with operation key + String globalSubscriberId = execution.getVariable("globalSubscriberId") + msoLogger.info("globalSubscriberId:" + globalSubscriberId) + String serviceType = execution.getVariable("serviceType") + msoLogger.info("serviceType:" + serviceType) + String serviceId = execution.getVariable("serviceId") + msoLogger.info("serviceId:" + serviceId) + String operationId = execution.getVariable("operationId") + msoLogger.info("serviceType:" + serviceType) + String nodeTemplateUUID = execution.getVariable("resourceTemplateId") + msoLogger.info("nodeTemplateUUID:" + nodeTemplateUUID) + String nsInstanceId = execution.getVariable("resourceInstanceId") + msoLogger.info("nsInstanceId:" + nsInstanceId) + execution.setVariable("nsInstanceId",nsInstanceId) + String nsOperationKey = """{ + "globalSubscriberId":"${globalSubscriberId}", + "serviceType":"${serviceType}", + "serviceId":"${serviceId}", + "operationId":"${operationId}", + "nodeTemplateUUID":"${nodeTemplateUUID}" + }""" + execution.setVariable("nsOperationKey", nsOperationKey); + msoLogger.info("nsOperationKey:" + nsOperationKey) + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + /** + * unwind NS from AAI relationship + */ + public void deleteNSRelationship(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** deleteNSRelationship *****", isDebugEnabled) + String nsInstanceId = execution.getVariable("resourceInstanceId") + if(nsInstanceId == null || nsInstanceId == ""){ + utils.log("INFO"," Delete NS failed", isDebugEnabled) + return + } + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceId = execution.getVariable("serviceId") + String deleteRelationPayload = """ + service-instance + /aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId} + + customer.global-customer-id + ${MsoUtils.xmlEscape(globalSubscriberId)} + + + service-subscription.service-type + ${MsoUtils.xmlEscape(serviceType)} + + + service-instance.service-instance-id + ${MsoUtils.xmlEscape(nsInstanceId)} + + """ + String endpoint = execution.getVariable("URN_aai_endpoint") + utils.log("INFO","Delete Relationship req:\n" + deleteRelationPayload, isDebugEnabled) + String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship" + + APIResponse aaiRsp = executeAAIDeleteCall(execution, url, deleteRelationPayload) + utils.log("INFO","aai response status code:" + aaiRsp.getStatusCode(), isDebugEnabled) + utils.log("INFO","aai response content:" + aaiRsp.getResponseBodyAsString(), isDebugEnabled) + utils.log("INFO"," *****Exit deleteNSRelationship *****", isDebugEnabled) + } + + public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO", " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled) + APIResponse apiResponse = null + try{ + String uuid = utils.getRequestID() + utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled) + utils.log("INFO","URL to be used is: " + url, isDebugEnabled) + String userName = execution.getVariable("URN_aai_auth") + String password = execution.getVariable("URN_mso_msoKey") + String basicAuthCred = utils.getBasicAuth(userName,password) + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + apiResponse = client.httpDelete(payload) + utils.log("INFO","======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) + }catch(Exception e){ + utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + + /** + * delete NS task + */ + public void deleteNetworkService(DelegateExecution execution) { + + msoLogger.trace("deleteNetworkService start ") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId") + APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String apiResponseAsString = apiResponse.getResponseBodyAsString() + String operationStatus = "error"; + if(returnCode== "200" || returnCode== "202"){ + operationStatus = "finished" + } + execution.setVariable("operationStatus", operationStatus) + + msoLogger.trace("deleteNetworkService end ") + } + + /** + * instantiate NS task + */ + public void terminateNetworkService(DelegateExecution execution) { + + msoLogger.trace("terminateNetworkService start ") + String nsOperationKey = execution.getVariable("nsOperationKey") + String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate" + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String jobId = ""; + if(returnCode== "200" || returnCode== "202"){ + jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") + } + execution.setVariable("jobId", jobId) + msoLogger.trace("terminateNetworkService end ") + } + + /** + * query NS task + */ + public void queryNSProgress(DelegateExecution execution) { + + msoLogger.trace("queryNSProgress start ") + String jobId = execution.getVariable("jobId") + String nsOperationKey = execution.getVariable("nsOperationKey"); + String url = host + vfcUrl + "/jobs/" + execution.getVariable("jobId") + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String apiResponseAsString = apiResponse.getResponseBodyAsString() + String operationProgress = "100" + if(returnCode== "200"){ + operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress") + } + execution.setVariable("operationProgress", operationProgress) + msoLogger.trace("queryNSProgress end ") + } + + /** + * delay 5 sec + */ + public void timeDelay(DelegateExecution execution) { + try { + Thread.sleep(5000); + } catch(InterruptedException e) { + msoLogger.info("Time Delay exception" + e) + } + } + + /** + * finish NS task + */ + public void finishNSDelete(DelegateExecution execution) { + //no need to do anything util now + } + + /** + * post request + * url: the url of the request + * requestBody: the body of the request + */ + private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){ + + msoLogger.trace("Started Execute VFC adapter Post Process ") + msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) + APIResponse apiResponse = null + try{ + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk");; + apiResponse = client.httpPost(requestBody) + msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.trace("Completed Execute VF-C adapter Post Process ") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + /** + * delete request + * url: the url of the request + * requestBody: the body of the request + */ + private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){ + + msoLogger.trace("Started Execute VFC adapter Delete Process ") + msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) + APIResponse apiResponse = null + try{ + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); + apiResponse = client.httpDelete(requestBody) + msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.trace("Completed Execute VF-C adapter Delete Process ") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy new file mode 100644 index 0000000000..b41b74e509 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -0,0 +1,711 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VfModule +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.springframework.web.util.UriUtils +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource + +/* Subflow for Delete VF Module. When no DoDeleteVfModuleRequest is specified on input, + * functions as a building block subflow + +* Inputs for building block interface: +* @param - requestId +* @param - isDebugLogEnabled +* @param - vnfId +* @param - vfModuleId +* @param - serviceInstanceId +* @param - vfModuleName O +* @param - vfModuleModelInfo +* @param - cloudConfiguration* +* @param - sdncVersion ("1610") +* @param - retainResources +* @param - aLaCarte +* +* Outputs: +* @param - WorkflowException +* +*/ +public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModule.class); + + def Prefix="DoDVfMod_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", null) + execution.setVariable("DoDVfMod_oamManagementV4Address", null) + execution.setVariable("DoDVfMod_oamManagementV6Address", null) + + } + + // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids + // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest + public void preProcessRequest(DelegateExecution execution) { + + initProcessVariables(execution) + + try { + def xml = execution.getVariable("DoDeleteVfModuleRequest") + String vnfId = "" + String vfModuleId = "" + + if (xml == null || xml.isEmpty()) { + // Building Block-type request + + // Set mso-request-id to request-id for VNF Adapter interface + String requestId = execution.getVariable("requestId") + execution.setVariable("mso-request-id", requestId) + + String cloudConfiguration = execution.getVariable("cloudConfiguration") + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") + execution.setVariable("tenantId", tenantId) + String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") + execution.setVariable("cloudSiteId", cloudSiteId) + // Source is HARDCODED + String source = "VID" + execution.setVariable("source", source) + // SrvInstId is hardcoded to empty + execution.setVariable("srvInstId", "") + // ServiceId is hardcoded to empty + execution.setVariable("serviceId", "") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + vnfId = execution.getVariable("vnfId") + vfModuleId = execution.getVariable("vfModuleId") + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) + } + else { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) + } + //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 { + + msoLogger.debug("DoDeleteVfModule Request: " + xml) + + msoLogger.debug("input request xml: " + xml) + + vnfId = utils.getNodeText(xml,"vnf-id") + execution.setVariable("vnfId", vnfId) + vfModuleId = utils.getNodeText(xml,"vf-module-id") + execution.setVariable("vfModuleId", vfModuleId) + def srvInstId = execution.getVariable("mso-service-instance-id") + execution.setVariable("srvInstId", srvInstId) + String requestId = "" + try { + requestId = execution.getVariable("mso-request-id") + } catch (Exception ex) { + requestId = utils.getNodeText(xml, "request-id") + } + execution.setVariable("requestId", requestId) + String source = utils.getNodeText(xml, "source") + execution.setVariable("source", source) + String serviceId = utils.getNodeText(xml, "service-id") + execution.setVariable("serviceId", serviceId) + String tenantId = utils.getNodeText(xml, "tenant-id") + execution.setVariable("tenantId", tenantId) + + String serviceInstanceIdToSdnc = "" + if (xml.contains("service-instance-id")) { + serviceInstanceIdToSdnc = utils.getNodeText(xml, "service-instance-id") + } else { + serviceInstanceIdToSdnc = vfModuleId + } + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceIdToSdnc) + String vfModuleName = utils.getNodeText(xml, "vf-module-name") + execution.setVariable("vfModuleName", vfModuleName) + String vfModuleModelName = utils.getNodeText(xml, "vf-module-model-name") + execution.setVariable("vfModuleModelName", vfModuleModelName) + String cloudSiteId = utils.getNodeText(xml, "aic-cloud-region") + execution.setVariable("cloudSiteId", cloudSiteId) + } + + // formulate the request for PrepareUpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + pending-delete + """ as String + msoLogger.debug("PrepareUpdateAAIVfModuleRequest :" + request) + msoLogger.debug("UpdateAAIVfModule Request: " + request) + execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) + execution.setVariable("vfModuleFromAAI", null) + }catch(BpmnError b){ + throw b + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") + } + } + + // build a SDNC vnf-topology-operation request for the specified action + // (note: the action passed is expected to be 'changedelete' or 'delete') + public void prepSDNCAdapterRequest(DelegateExecution execution, String action) { + + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("requestId") + "-" + System.currentTimeMillis() + } + + def srvInstId = execution.getVariable("srvInstId") + def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String requestId = execution.getVariable("requestId") + String source = execution.getVariable("source") + String serviceId = execution.getVariable("serviceId") + String vnfId = execution.getVariable("vnfId") + String tenantId = execution.getVariable("tenantId") + String vfModuleId = execution.getVariable("vfModuleId") + String serviceInstanceIdToSdnc = execution.getVariable(Prefix + "serviceInstanceIdToSdnc") + String vfModuleName = execution.getVariable("vfModuleName") + // Get vfModuleName from AAI response if it was not specified on the request + if (vfModuleName == null || vfModuleName.isEmpty()) { + if (execution.getVariable("vfModuleFromAAI") != null) { + VfModule vfModuleFromAAI = execution.getVariable("vfModuleFromAAI") + vfModuleName = vfModuleFromAAI.getElementText("vf-module-name") + } + } + String vfModuleModelName = execution.getVariable("vfModuleModelName") + String cloudSiteId = execution.getVariable("cloudSiteId") + boolean retainResources = execution.getVariable("retainResources") + String requestSubActionString = "" + if (retainResources) { + requestSubActionString = "RetainResource" + } + String request = """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + DisconnectVNFRequest + ${requestSubActionString} + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(serviceInstanceIdToSdnc)} + notsurewecare + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(vnfId)} + + + ${MsoUtils.xmlEscape(cloudSiteId)} + ${MsoUtils.xmlEscape(tenantId)} + + + """ + + msoLogger.debug("sdncAdapterWorkflowRequest: " + request) + msoLogger.debug("DoDeleteVfModule - SDNCAdapterWorkflowRequest: " + request) + execution.setVariable("sdncAdapterWorkflowRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(DelegateExecution execution) { + + 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('DoDVfMod_heatStackId') + def tenantId = execution.getVariable("tenantId") + def messageId = execution.getVariable('requestId') + '-' + + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ + + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleStackId)} + true + + ${MsoUtils.xmlEscape(origRequestId)} + ${MsoUtils.xmlEscape(srvInstId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ as String + + msoLogger.debug("vnfAdapterRestV1Request: " + request) + msoLogger.debug("deleteVfModuleRequest: " + request) + execution.setVariable("vnfAdapterRestV1Request", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing UpdateAAIVfModuleRequest request + public void prepUpdateAAIVfModule(DelegateExecution execution) { + + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + DELETE + deleted + """ as String + msoLogger.debug("UpdateAAIVfModuleRequest :" + request) + msoLogger.debug("UpdateAAIVfModuleRequest: " + request) + execution.setVariable("UpdateAAIVfModuleRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(DelegateExecution execution) { + + + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + """ as String + msoLogger.debug("DeleteAAIVfModuleRequest :" + request) + msoLogger.debug("DeleteAAIVfModuleRequest: " + request) + execution.setVariable("DeleteAAIVfModuleRequest", request) + } + + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("DoDVfMod_deleteGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + public void sdncValidateResponse(DelegateExecution execution, String response){ + + execution.setVariable("prefix",Prefix) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Successfully Validated SDNC Response") + }else{ + throw new BpmnError("MSOWorkflowException") + } + } + + public void postProcessVNFAdapterRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix",Prefix) + try{ + msoLogger.trace("STARTED postProcessVNFAdapterRequest Process") + + String vnfResponse = execution.getVariable("DoDVfMod_doDeleteVfModuleResponse") + msoLogger.debug("VNF Adapter Response is: " + vnfResponse) + msoLogger.debug("deleteVnfAResponse is: \n" + vnfResponse) + + if(vnfResponse != null){ + + if(vnfResponse.contains("deleteVfModuleResponse")){ + msoLogger.debug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.") + execution.setVariable("DoDVfMod_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() + msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) + execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) + execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) + } + + } + } + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + msoLogger.debug("Setting the fqdn list") + execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) + } + } + }else{ + msoLogger.debug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + }else{ + msoLogger.debug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") + } + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + msoLogger.debug("Internal Error Occured in PostProcess Method") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") + } + msoLogger.trace("COMPLETED postProcessVnfAdapterResponse Process") + } + + public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED deleteNetworkPoliciesFromAAI ") + + try { + // get variables + List fqdnList = execution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList") + if (fqdnList == null) { + msoLogger.debug("No network policies to delete") + return + } + int fqdnCount = fqdnList.size() + + execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount) + msoLogger.debug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) + + if (fqdnCount > 0) { + // AII loop call over contrail network policy fqdn list + 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") + msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) + msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) + int returnCode = response.getStatusCode() + execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (isOneOf(returnCode, 200, 201)) { + msoLogger.debug("The return code is: " + returnCode) + // This network policy FQDN exists in AAI - need to delete it now + msoLogger.debug(aaiResponseAsString) + execution.setVariable("DoDVfMod_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) + msoLogger.debug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) + // Retrieve the network policy id for this FQDN + def networkPolicyId = utils.getNodeText(aaiResponseAsString, "network-policy-id") + msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId) + + // Retrieve the resource version for this network policy + def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") + msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) + + String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) + + msoLogger.debug("invoking DELETE call to AAI") + msoLogger.debug("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest) + APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest) + int returnCodeDel = responseDel.getStatusCode() + execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", returnCodeDel) + msoLogger.debug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel) + + if (isOneOf(returnCodeDel, 200, 201, 204)) { + msoLogger.debug("The return code from deleting network policy is: " + returnCodeDel) + // This network policy was deleted from AAI successfully + msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ") + + } else { + // aai all errors + String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel + msoLogger.debug(delErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) + } + } else if (returnCode == 404) { + // This network policy FQDN is not in AAI. No need to delete. + msoLogger.debug("The return code is: " + returnCode) + msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn) + msoLogger.debug("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 + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + + + + } // end loop + + + } else { + msoLogger.debug("No contrail network policies to query/create") + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('vnfId') + def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') + def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') + def ipv4OamAddressElement = '' + def managementV6AddressElement = '' + + if (oamManagementV4Address != null) { + ipv4OamAddressElement = '' + 'DELETE' + '' + } + + if (oamManagementV6Address != null) { + managementV6AddressElement = '' + 'DELETE' + '' + } + + + String updateAAIGenericVnfRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${ipv4OamAddressElement} + ${managementV6AddressElement} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Using the vnfId and vfModuleId provided in the inputs, + * query AAI to get the corresponding VF Module info. + * A 200 response is expected with the VF Module info in the response body, + * Will determine VF Module's orchestration status if one exists + * + * @param execution The flow's execution instance. + */ + public void queryAAIVfModuleForStatus(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + execution.setVariable(Prefix + 'orchestrationStatus', '') + + try { + def vnfId = execution.getVariable('vnfId') + def vfModuleId = execution.getVariable('vfModuleId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + + "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") + msoLogger.debug("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'); + msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') + APIResponse response = client.httpGet() + msoLogger.debug("createVfModule - invoking httpGet() to AAI") + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received generic VNF data: " + responseData) + + } + + msoLogger.debug("deleteVfModule - queryAAIVfModule Response: " + responseData) + msoLogger.debug("deleteVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponseCode', response.getStatusCode()) + execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponse', responseData) + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + // Retrieve VF Module info and its orchestration status; if not found, do nothing + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + msoLogger.debug('Parsing the VNF data to find orchestration status') + if (responseData != null) { + def vfModuleText = utils.getNodeXml(responseData, "vf-module") + //def xmlVfModule= new XmlSlurper().parseText(vfModuleText) + def orchestrationStatus = utils.getNodeText(vfModuleText, "orchestration-status") + execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus) + msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus) + + } + } + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) + } + } + + + + + +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy new file mode 100644 index 0000000000..1024fc57da --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -0,0 +1,609 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VfModule +import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +public class DoDeleteVfModuleFromVnf extends VfModuleBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModuleFromVnf.class); + + def Prefix="DDVFMV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null) + } + + // parse the incoming request + public void preProcessRequest(DelegateExecution execution) { + + 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) + msoLogger.debug("msoRequestId: " + requestId) + String tenantId = execution.getVariable("tenantId") + msoLogger.debug("tenantId: " + tenantId) + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("cloudSiteId", cloudSiteId) + msoLogger.debug("cloudSiteId: " + cloudSiteId) + // 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") + msoLogger.debug("serviceInstanceId: " + serviceInstanceId) + String vnfId = execution.getVariable("vnfId") + msoLogger.debug("vnfId: " + vnfId) + String vfModuleId = execution.getVariable("vfModuleId") + msoLogger.debug("vfModuleId: " + vfModuleId) + 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) + msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion) + + String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl) + + + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + msoLogger.debug("Exception is: " + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") + } + } + + public void queryAAIForVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.queryAAIForVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + + msoLogger.debug("DoDeleteVfModuleFromVnf: AAI endPoint : " + endPoint) + + try { + msoLogger.debug("DoDeleteVfModuleFromVnf: - invoking httpGet to AAI") + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + + def responseData = response.getResponseBodyAsString() + execution.setVariable('DDVMFV_getVnfResponseCode', response.getStatusCode()) + execution.setVariable('DDVMFV_getVnfResponse', responseData) + + msoLogger.debug("DoDeleteVfModuleFromVnf: AAI Response : " + responseData) + msoLogger.debug("DoDeleteVfModuleFromVnf: AAI ResponseCode : " + response.getStatusCode()) + + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + execution.setVariable('DDVMFV_getVnfResponseCode', 500) + execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, '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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + msoLogger.trace('Entered ' + method) + + 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 + '\'' + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, msg) + } else { + + if (isDebugLogEnabled) { + msoLogger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() + ', isOnlyVfModule=' + vfModule.isOnlyVfModule()) + } + 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 + '\'' + msoLogger.debug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + + def heatStackId = vfModule.getElementText('heat-stack-id') + execution.setVariable('DDVMFV_heatStackId', heatStackId) + msoLogger.debug('VF Module heatStackId retrieved from AAI: ' + heatStackId) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) + } + } + + + public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCDeactivateRequest ") + + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable("DDVMFV_deactivateSDNCRequest", deactivateSDNCRequest) + msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCDeactivateRequest ") + } + + public void preProcessSDNCUnassignRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process ") + try{ + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DDVMFV_unassignSDNCRequest", unassignSDNCRequest) + msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + + }catch(Exception e){ + msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCUnassignRequest Process ") + } + + public String buildSDNCRequest(DelegateExecution 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 = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vf-module-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + generic-resource + + + + ${MsoUtils.xmlEscape(requestId)} + DeleteVfModuleInstance + ${MsoUtils.xmlEscape(source)} + + + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + + + ${MsoUtils.xmlEscape(vnfId)} + + + + ${MsoUtils.xmlEscape(vfModuleId)} + + + + """ + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + msoLogger.debug("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.trace("COMPLETED ValidateSDNCResponse Process") + } + + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(DelegateExecution execution) { + + 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 = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ + + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleStackId)} + true + + ${MsoUtils.xmlEscape(origRequestId)} + ${MsoUtils.xmlEscape(srvInstId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ as String + + msoLogger.debug("vnfAdapterRestV1Request: " + request) + msoLogger.debug("deleteVfModuleRequest: " + request) + execution.setVariable("vnfAdapterRestV1Request", request) + } + + + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DDVFMV_deleteGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("DDVFMV_deleteGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + public void postProcessVNFAdapterRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix",Prefix) + try{ + msoLogger.trace("STARTED postProcessVNFAdapterRequest Process") + + String vnfResponse = execution.getVariable("DDVMFV_doDeleteVfModuleResponse") + msoLogger.debug("VNF Adapter Response is: " + vnfResponse) + msoLogger.debug("deleteVnfAResponse is: \n" + vnfResponse) + + if(vnfResponse != null){ + + if(vnfResponse.contains("deleteVfModuleResponse")){ + msoLogger.debug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.") + execution.setVariable("DDVFMV_vnfVfModuleDeleteCompleted", true) + + // Parse vnfOutputs for contrail network polcy FQDNs + def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") + if(!isBlank(vfModuleOutputsXml)) { + vfModuleOutputsXml = utils.removeXmlNamespaces(vfModuleOutputsXml) + List contrailNetworkPolicyFqdnList = [] + for(Node node: utils.getMultNodeObjects(vfModuleOutputsXml, "entry")) { + String key = utils.getChildNodeText(node, "key") + if(key == null) { + + } else if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = utils.getChildNodeText(node, "value") + msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = utils.getChildNodeText(node, "value") + msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) + execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = utils.getChildNodeText(node, "value") + msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) + execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) + } + } + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + msoLogger.debug("Setting the fqdn list") + execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) + } + } + }else{ + msoLogger.debug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + }else{ + msoLogger.debug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") + } + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + msoLogger.debug("Internal Error Occured in PostProcess Method") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") + } + msoLogger.trace("COMPLETED postProcessVnfAdapterResponse Process") + } + + public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED deleteNetworkPoliciesFromAAI ") + + try { + // get variables + List fqdnList = execution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList") + if (fqdnList == null) { + msoLogger.debug("No network policies to delete") + return + } + int fqdnCount = fqdnList.size() + + execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount) + msoLogger.debug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) + + if (fqdnCount > 0) { + // AII loop call over contrail network policy fqdn list + 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") + msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) + + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) + int returnCode = response.getStatusCode() + execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (isOneOf(returnCode, 200, 201)) { + msoLogger.debug("The return code is: " + returnCode) + // This network policy FQDN exists in AAI - need to delete it now + msoLogger.debug(aaiResponseAsString) + execution.setVariable("DDVFMV_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) + msoLogger.debug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) + // Retrieve the network policy id for this FQDN + def networkPolicyId = utils.getNodeText(aaiResponseAsString, "network-policy-id") + msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId) + + // Retrieve the resource version for this network policy + def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") + msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) + + String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) + + msoLogger.debug("invoking DELETE call to AAI") + msoLogger.debug("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest) + APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest) + int returnCodeDel = responseDel.getStatusCode() + execution.setVariable("DDVFMV_aaiDeleteNetworkPolicyReturnCode", returnCodeDel) + msoLogger.debug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel) + + if (isOneOf(returnCodeDel, 200, 201, 204)) { + msoLogger.debug("The return code from deleting network policy is: " + returnCodeDel) + // This network policy was deleted from AAI successfully + msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ") + + } else { + // aai all errors + String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel + msoLogger.debug(delErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) + } + } else if (returnCode == 404) { + // This network policy FQDN is not in AAI. No need to delete. + msoLogger.debug("The return code is: " + returnCode) + msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn) + msoLogger.debug("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 + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + + + + } // end loop + + + } else { + msoLogger.debug("No contrail network policies to query/create") + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(DelegateExecution execution) { + + + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """ + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + """ as String + msoLogger.debug("DeleteAAIVfModuleRequest :" + request) + + execution.setVariable("DeleteAAIVfModuleRequest", request) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy new file mode 100644 index 0000000000..b1cef477be --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -0,0 +1,355 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModuleVolumeV2.class); + + String prefix="DDVMV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + XmlParser xmlParser = new XmlParser() + JsonUtils jsonUtil = new JsonUtils() + + @Override + public void preProcessRequest(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + /** + * Set default variable values + * @param execution + * @param isDebugLogEnabled + */ + public void preProcessRequest (DelegateExecution 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") + msoLogger.debug("Using cloudConfiguration variable to get tenantId and lcpCloudRegionId - " + cloudConfiguration) + 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(DelegateExecution 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(DelegateExecution execution, isDebugEnabled) { + + String cloudRegion = execution.getVariable('lcpCloudRegionId') + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + msoLogger.debug(queryCloudRegionRequest) + msoLogger.debug("AAI query cloud region URI - " + queryCloudRegionRequest) + + 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 { + msoLogger.debug("AAI Query Cloud Region Unsuccessful.") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")) + } + } + + + /** + * Query AAI Volume Group + * Output variables: prefix+'queryAAIVolGrpResponse'; prefix+'volumeGroupHeatStackId' + * @param execution + * @param isDebugLogEnabled + */ + public void callRESTQueryAAIForVolumeGroup(DelegateExecution 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") + + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query volume group by id return code: " + returnCode) + msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString) + msoLogger.debug('AAI query volume group by id return code: ' + returnCode) + msoLogger.debug('AAI query volume group by id response: ' + aaiResponseAsString) + + execution.setVariable(prefix+"queryAAIVolGrpResponse", aaiResponseAsString) + + if (returnCode=='200' || returnCode == '204') { + + def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id') + execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId) + + msoLogger.debug('Heat stack id from AAI response: ' + heatStackId) + + if(hasVfModuleRelationship(aaiResponseAsString)){ + msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use') + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") + } + + def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) + msoLogger.debug('Tenant ID from AAI response: ' + volumeGroupTenantId) + + if (volumeGroupTenantId == null) { + msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") + } + + if (volumeGroupTenantId != tenantId) { + def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId + msoLogger.debug("Error in DeleteVfModuleVolume: " + errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, errorMessage) + } + msoLogger.debug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId ) + } + else { + if (returnCode=='404') { + msoLogger.debug("Volume Group ${volumeGroupId} not found in AAI") + 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(DelegateExecution execution, isDebugLogEnabled) { + def cloudRegion = execution.getVariable(prefix+'aicCloudRegion') + def tenantId = execution.getVariable('tenantId') // input parameter (optional) - see preProcessRequest + def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required) + def 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 = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String vnfAdapterRestRequest = """ + + ${MsoUtils.xmlEscape(cloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupHeatStackId)} + true + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable(prefix+'deleteVnfARequest', vnfAdapterRestRequest) + msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) + } + + + /** + * Delete volume group in AAI + * @param execution + * @param isDebugEnabled + */ + public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) { + + // get variables + String queryAAIVolGrpIdResponse = execution.getVariable(prefix+"queryAAIVolGrpResponse") + String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id") + String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version") + + String messageId = UUID.randomUUID().toString() + String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") + + if(resourceVersion !=null){ + deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8') + } + + msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) + msoLogger.debug("Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest) + + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI delete volume group return code: " + returnCode) + msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString) + msoLogger.debug("AAI delete volume group return code: " + returnCode) + msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + if (returnCode=='200' || (returnCode == '204')) { + msoLogger.debug("Volume group $groupId deleted.") + } 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/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy new file mode 100644 index 0000000000..699e9bf40a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy @@ -0,0 +1,161 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.w3c.dom.Document +import org.w3c.dom.Element +import org.w3c.dom.Node +import org.w3c.dom.NodeList +import org.xml.sax.InputSource + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This class supports the DoDeleteVnf subFlow + * with the Deletion of a generic vnf for + * infrastructure. + * + */ +class DoDeleteVnf extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVnf.class); + + String Prefix="DoDVNF_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DoDeleteVnf PreProcessRequest Process") + + execution.setVariable("DoDVNF_SuccessIndicator", false) + execution.setVariable("DoDVNF_vnfInUse", false) + + try{ + // Get Variables + + String vnfId = execution.getVariable("vnfId") + execution.setVariable("DoDVNF_vnfId", vnfId) + msoLogger.debug("Incoming Vnf(Instance) Id is: " + vnfId) + + // Setting for sub flow calls + execution.setVariable("DoDVNF_type", "generic-vnf") + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DoDeleteVnf PreProcessRequest method!" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf PreProcessRequest") + + } + msoLogger.trace("COMPLETED DoDeleteVnf PreProcessRequest Process ") + } + + + public void processGetVnfResponse(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DoDeleteVnf processGetVnfResponse Process ") + try { + String vnf = execution.getVariable("DoDVNF_genericVnf") + String resourceVersion = utils.getNodeText(vnf, "resource-version") + execution.setVariable("DoDVNF_resourceVersion", resourceVersion) + + if(utils.nodeExists(vnf, "relationship")){ + InputSource source = new InputSource(new StringReader(vnf)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document vnfXml = docBuilder.parse(source) + + NodeList nodeList = vnfXml.getElementsByTagName("relationship") + for (int x = 0; x < nodeList.getLength(); x++) { + Node node = nodeList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() + if(e.equals("volume-group") || e.equals("l3-network")){ + msoLogger.debug("Generic Vnf still has relationship to OpenStack.") + execution.setVariable("DoDVNF_vnfInUse", true) + }else{ + msoLogger.debug("Relationship NOT related to OpenStack") + } + } + } + } + + if(utils.nodeExists(vnf, "vf-module")){ + execution.setVariable("DoDVNF_vnfInUse", true) + msoLogger.debug("Generic Vnf still has vf-modules.") + } + + + } catch (Exception ex) { + msoLogger.debug("Error Occured in DoDeleteVnf processGetVnfResponse Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf processGetVnfResponse Process") + + } + msoLogger.trace("COMPLETED DoDeleteVnf processGetVnfResponse Process ") + } + + /** + * Deletes the generic vnf from aai + */ + public void deleteVnf(DelegateExecution execution) { + msoLogger.trace("STARTED deleteVnf") + try { + String vnfId = execution.getVariable("DoDVNF_vnfId") + + AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + resourceClient.delete(uri) + + msoLogger.trace("COMPLETED deleteVnf") + } catch (Exception ex) { + msoLogger.debug("Error Occured in DoDeleteVnf deleteVnf Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf deleteVnf Process") + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy new file mode 100644 index 0000000000..d448dd3e79 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -0,0 +1,538 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ModuleResource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils; + +/** + * This class supports the macro VID Flow + * with the deletion of a generic vnf and related VF modules. + */ +class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVnfAndModules.class); + + String Prefix="DDVAM_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DoDeleteVnfAndModules PreProcessRequest Process") + + try{ + // Get Variables + + String cloudConfiguration = execution.getVariable("cloudConfiguration") + msoLogger.debug("Cloud Configuration: " + cloudConfiguration) + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("requestId", requestId) + execution.setVariable("mso-request-id", requestId) + msoLogger.debug("Incoming Request Id is: " + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + + String vnfId = execution.getVariable("vnfId") + msoLogger.debug("Incoming Vnf Id is: " + vnfId) + + String source = "VID" + execution.setVariable("DDVAM_source", source) + msoLogger.debug("Incoming Source is: " + source) + + execution.setVariable("DDVAM_isVidRequest", "true") + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DDVAM_sdncVersion", sdncVersion) + msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion) + + // Set aLaCarte flag to false + execution.setVariable("aLaCarte", false) + + String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback", execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl) + + + if (!sdncVersion.equals("1702")) { + //String vnfModelInfo = execution.getVariable("vnfModelInfo") + //String serviceModelInfo = execution.getVariable("serviceModelInfo") + + String serviceId = execution.getVariable("productFamilyId") + execution.setVariable("DDVAM_serviceId", serviceId) + msoLogger.debug("Incoming Service Id is: " + serviceId) + + + //String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId") + //execution.setVariable("DDVAM_modelInvariantId", modelInvariantId) + //msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId) + + //String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") + //if (modelVersionId == null) { + // modelVersionId = "" + //} + //execution.setVariable("DDVAM_modelVersionId", modelVersionId) + //msoLogger.debug("Incoming Version Id is: " + modelVersionId) + + //String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") + //execution.setVariable("DDVAM_modelVersion", modelVersion) + //msoLogger.debug("Incoming Model Version is: " + modelVersion) + + //String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") + //execution.setVariable("DDVAM_modelName", modelName) + //msoLogger.debug("Incoming Model Name is: " + modelName) + + //String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId") + //if (modelCustomizationId == null) { + // modelCustomizationId = "" + //} + //execution.setVariable("DDVAM_modelCustomizationId", modelCustomizationId) + //msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId) + + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DDVAM_cloudSiteId", cloudSiteId) + msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DDVAM_tenantId", tenantId) + msoLogger.debug("Incoming Tenant Id is: " + tenantId) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if (globalSubscriberId == null) { + globalSubscriberId = "" + } + execution.setVariable("DDVAM_globalSubscriberId", globalSubscriberId) + msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) + + } + execution.setVariable("DDVAM_vfModulesFromDecomposition", null) + // Retrieve serviceDecomposition if present + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + if (serviceDecomposition != null) { + msoLogger.debug("Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString()) + List vnfs = serviceDecomposition.getVnfResources() + msoLogger.debug("Read vnfs") + if (vnfs == null) { + msoLogger.debug("Error - vnfs are empty in serviceDecomposition object") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnfs are empty") + } + VnfResource vnf = vnfs[0] + + if (vnf == null) { + msoLogger.debug("Error - vnf is empty in serviceDecomposition object") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnf is empty") + } + + List vfModules = vnf.getAllVfModuleObjects() + + execution.setVariable("DDVAM_vfModulesFromDecomposition", vfModules) + } + + execution.setVariable("DDVAM_moduleCount", 0) + execution.setVariable("DDVAM_nextModule", 0) + + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") + + } + msoLogger.trace("COMPLETED DoDeleteVnfAndModules PreProcessRequest Process ") + } + + + + public void preProcessAddOnModule(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessAddOnModule ") + + try { + JSONArray addOnModules = (JSONArray) execution.getVariable("addOnModules") + int addOnIndex = (int) execution.getVariable("addOnModulesDeployed") + + JSONObject addOnModule = addOnModules[addOnIndex] + + def newVfModuleId = UUID.randomUUID().toString() + execution.setVariable("addOnVfModuleId", newVfModuleId) + + execution.setVariable("instancesOfThisModelDeployed", 0) + + JSONObject addOnVfModuleModelInfoObject = jsonUtil.getJsonValueForKey(addOnModule, "modelInfo") + String addOnVfModuleModelInfo = addOnVfModuleModelInfoObject.toString() + execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) + String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel") + execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) + String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantUuid") + execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) + String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") + execution.setVariable("initialCount", addOnInitialCount) + + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule." + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCAssignRequest ") + } + + /** + * 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(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.queryAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + msoLogger.debug("AAI endPoint: " + endPoint) + + try { + msoLogger.debug("createVfModule - invoking httpGet() to AAI") + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + + def responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received generic VNF data: " + responseData) + + } + + msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData) + msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + //Map[] vfModules = new HashMap[] + List vfModulesFromDecomposition = execution.getVariable("DDVAM_vfModulesFromDecomposition") + 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 + msoLogger.debug('Parsing the VNF data to find base module info') + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + msoLogger.debug("vModulesText: " + vfModulesText) + if (vfModulesText != null && !vfModulesText.trim().isEmpty()) { + def xmlVfModules= new XmlSlurper().parseText(vfModulesText) + vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} + execution.setVariable("DDVAM_moduleCount", vfModules.size()) + int vfModulesSize = 0 + ModelInfo vfModuleModelInfo = null + for (i in 0..vfModules.size()-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + + Map vfModuleEntry = new HashMap() + def vfModuleId = utils.getNodeText(vfModuleXml, "vf-module-id") + vfModuleEntry.put("vfModuleId", vfModuleId) + def vfModuleName = utils.getNodeText(vfModuleXml, "vf-module-name") + vfModuleEntry.put("vfModuleName", vfModuleName) + + // Find the model for this vf module in decomposition if specified + if (vfModulesFromDecomposition != null) { + msoLogger.debug("vfModulesFromDecomposition is not null") + def vfModuleUuid = utils.getNodeText(vfModuleXml, "model-version-id") + if (vfModuleUuid == null) { + vfModuleUuid = utils.getNodeText(vfModuleXml, "persona-model-version") + } + msoLogger.debug("vfModule UUID is: " + vfModuleUuid) + for (j in 0..vfModulesFromDecomposition.size()-1) { + ModuleResource mr = vfModulesFromDecomposition[j] + if (mr.getModelInfo().getModelUuid() == vfModuleUuid) { + msoLogger.debug("Found modelInfo") + vfModuleModelInfo = mr.getModelInfo() + break + } + + } + } + if (vfModuleModelInfo != null) { + String vfModuleModelInfoString = vfModuleModelInfo.toString() + def vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfoString, "modelInfo") + vfModuleEntry.put("vfModuleModelInfo", vfModuleModelInfoValue) + } + else { + vfModuleEntry.put("vfModuleModelInfo", null) + } + + + def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") + // Save base vf module for last + if (isBaseVfModule == "true") { + vfModuleBaseEntry = vfModuleEntry + } + else { + vfModulesList.add(vfModuleEntry) + } + } + if (vfModuleBaseEntry != null) { + vfModulesList.add(vfModuleBaseEntry) + } + } + + } + } + execution.setVariable("DDVAM_vfModules", vfModulesList) + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + public void prepareNextModuleToDelete(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED prepareNextModuleToDelete ") + + try { + int i = execution.getVariable("DDVAM_nextModule") + def vfModules = execution.getVariable("DDVAM_vfModules") + def vfModule = vfModules[i] + + def vfModuleId = vfModule.get("vfModuleId") + execution.setVariable("DDVAM_vfModuleId", vfModuleId) + + def vfModuleName = vfModule.get("vfModuleName") + execution.setVariable("DDVAM_vfModuleName", vfModuleName) + + def vfModuleModelInfo = vfModule.get("vfModuleModelInfo") + msoLogger.debug("vfModuleModelInfo for module delete: " + vfModuleModelInfo) + execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule." + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToDelete Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED prepareNextModuleToDelete ") + } + + public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCDeactivateRequest ") + 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("DDVAM_deactivateSDNCRequest", deactivateSDNCRequest) + msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest." + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCDeactivateRequest ") + } + + public void preProcessSDNCUnassignRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process ") + try{ + String vnfId = execution.getVariable("vnfId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DDVAM_unassignSDNCRequest", unassignSDNCRequest) + msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preProcessSDNCUnassignRequest Process ") + } + + public String buildSDNCRequest(DelegateExecution 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("DDVAM_serviceId") + def tenantId = execution.getVariable("DDVAM_tenantId") + def source = execution.getVariable("DDVAM_source") + def vnfId = execution.getVariable("vnfId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def cloudSiteId = execution.getVariable("DDVAM_cloudSiteId") + def modelCustomizationId = execution.getVariable("DDVAM_modelCustomizationId") + //def serviceModelInfo = execution.getVariable("serviceModelInfo") + //def vnfModelInfo = execution.getVariable("vnfModelInfo") + //String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) + //String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) + def globalSubscriberId = execution.getVariable("DDVAM_globalSubscriberId") + def sdncVersion = execution.getVariable("DDVAM_sdncVersion") + + String sdncRequest = + """ + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + ${MsoUtils.xmlEscape(action)} + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackURL)} + generic-resource + + + + ${MsoUtils.xmlEscape(requestId)} + DeleteVnfInstance + ${MsoUtils.xmlEscape(source)} + + + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + + + ${MsoUtils.xmlEscape(vnfId)} + + + + + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(cloudSiteId)} + + + """ + + msoLogger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + msoLogger.debug("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.trace("COMPLETED ValidateSDNCResponse Process") + } + + + + + + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy new file mode 100644 index 0000000000..41d9384f52 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC All rights reserved. * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils; + + + +/** + * This groovy class supports the DoScaleServiceInstance.bpmn process. + * + */ +public class DoScaleE2EServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoScaleE2EServiceInstance.class); + + + String Prefix = "DCRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest(DelegateExecution execution) { + String msg = "" + msoLogger.trace("preProcessRequest ") + + try { + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("prefix", Prefix) + + //Inputs + String globalSubscriberId = execution.getVariable("globalSubscriberId") + + String serviceType = execution.getVariable("serviceType") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + execution.setVariable("serviceType", serviceType) + + String resourceTemplateUUIDs = "" + String scaleNsRequest = execution.getVariable("bpmnRequest") + JSONObject jsonObject = new JSONObject(scaleNsRequest).getJSONObject("service") + JSONArray jsonArray = jsonObject.getJSONArray("resources") + + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject reqBodyJsonObj = jsonArray.getJSONObject(i) + String nsInstanceId = reqBodyJsonObj.getString("resourceInstanceId") + resourceTemplateUUIDs = resourceTemplateUUIDs + nsInstanceId + ":" + } + + execution.setVariable("resourceTemplateUUIDs", resourceTemplateUUIDs) + + if (serviceInstanceName == null) { + execution.setVariable("serviceInstanceName", "") + } + if (isBlank(serviceInstanceId)) { + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + + public void preInitResourcesOperStatus(DelegateExecution execution){ + msoLogger.trace("STARTED preInitResourcesOperStatus Process ") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = "SCALE" + + // resourceTemplateUUIDs should be created ?? + String resourceTemplateUUIDs = execution.getVariable("resourceTemplateUUIDs") + msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(resourceTemplateUUIDs)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload) + msoLogger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy new file mode 100644 index 0000000000..e06e5238c6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy @@ -0,0 +1,332 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject; + +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.json.JsonUtils + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import com.fasterxml.jackson.databind.ObjectMapper + +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.onap.so.rest.APIResponse; + +import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleResource +import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleNsByStepsData +import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleNsData + +import org.onap.so.bpmn.infrastructure.vfcmodel.NSResourceInputParameter +import org.onap.so.bpmn.infrastructure.vfcmodel.NsOperationKey +import org.onap.so.bpmn.infrastructure.vfcmodel.NsScaleParameters +import org.onap.so.bpmn.infrastructure.vfcmodel.NsParameters +import org.onap.so.bpmn.infrastructure.vfcmodel.LocationConstraint +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + + + + +/** + * This groovy class supports the DoScaleVFCNetworkServiceInstance.bpmn process. + * flow for VFC Network Service Scale + */ +public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoScaleVFCNetworkServiceInstance.class); + + + String host = "http://mso.mso.testlab.openecomp.org:8080" + + String scaleUrl = "/vfc/rest/v1/vfcadapter/ns/{nsInstanceId}/scale" + + String queryJobUrl = "/vfc/rest/v1/vfcadapter/jobs/{jobId}" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + public void preProcessRequest(DelegateExecution execution) { + msoLogger.trace("preProcessRequest() ") + + List nsRIPList = convertScaleNsReq2NSResInputParamList(execution) + String requestJsonStr = "" + int size = nsRIPList.size() + for (int i = 0; i < size; i++) { + NSResourceInputParameter nsRIP = nsRIPList.get(i) + + if (i == size - 1) { + requestJsonStr += objectToJsonStr(nsRIP) + } else { + requestJsonStr += objectToJsonStr(nsRIP) + "|" + } + } + + execution.setVariable("reqBody", requestJsonStr) + + msoLogger.trace("Exit preProcessRequest ") + } + + /** + * scale NS task + */ + public void scaleNetworkService(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + String saleNsRequest = execution.getVariable("reqBody") + String[] nsReqStr = saleNsRequest.split("\\|") + + for (int i = 0; i < nsReqStr.length; i++) { + JSONObject reqBodyJsonObj = new JSONObject(nsReqStr[i]) + String nsInstanceId = reqBodyJsonObj.getJSONObject("nsScaleParameters").getString("nsInstanceId") + String nodeTemplateUUID = reqBodyJsonObj.getJSONObject("nsOperationKey").getString("nodeTemplateUUID") + reqBodyJsonObj.getJSONObject("nsScaleParameters").remove("nsInstanceId") + String reqBody = reqBodyJsonObj.toString() + + String url = host + scaleUrl.replaceAll("\\{nsInstanceId\\}", nsInstanceId) + + APIResponse apiResponse = postRequest(execution, url, reqBody) + + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + String jobId = "" + if (returnCode == "200" || returnCode == "202") { + jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") + } + utils.log("INFO", "scaleNetworkService get a ns scale job Id:" + jobId, isDebugEnabled) + execution.setVariable("jobId", jobId) + execution.setVariable("nodeTemplateUUID", nodeTemplateUUID) + + String isScaleFinished = "" + + if(jobId =="" || jobId == null){ + continue + } + // query the requested network service scale status, if finished, then start the next one, otherwise, wait + while (isScaleFinished != "finished" && isScaleFinished != "error"){ + timeDelay() + queryNSProgress(execution) + isScaleFinished = execution.getVariable("operationStatus") + } + } + } + + /** + * query NS task + */ + private void queryNSProgress(DelegateExecution execution) { + String jobId = execution.getVariable("jobId") + String url = host + queryJobUrl.replaceAll("\\{jobId\\}", jobId) + + NsOperationKey nsOperationKey = new NsOperationKey() + // is this net work service ID or E2E service ID? + nsOperationKey.setServiceId(execution.getVariable("serviceId")) + nsOperationKey.setServiceType(execution.getVariable("serviceType")) + nsOperationKey.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) + nsOperationKey.setNodeTemplateUUID(execution.getVariable("nodeTemplateUUID")) + nsOperationKey.setOperationId(execution.getVariable("operationId")) + String queryReqBody = objectToJsonStr(nsOperationKey) + + APIResponse apiResponse = postRequest(execution,url, queryReqBody) + + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() + + String operationStatus = "error" + + if (returnCode == "200") { + operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status") + } + + execution.setVariable("operationStatus", operationStatus) + } + + /** + * delay 5 sec + * + */ + private void timeDelay() { + try { + Thread.sleep(5000) + } catch (InterruptedException e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Time Delay exception" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + } + } + + /** + * finish NS task + */ + public void finishNSScale(DelegateExecution execution) { + //no need to do anything util now + System.out.println("Scale finished.") + } + + /** + * post request + * url: the url of the request + * requestBody: the body of the request + */ + private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){ + msoLogger.trace("Started Execute VFC adapter Post Process ") + msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) + APIResponse apiResponse = null + try{ + RESTConfig config = new RESTConfig(url) + RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk") +// RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk") + apiResponse = client.httpPost(requestBody) + msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.trace("Completed Execute VF-C adapter Post Process ") + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VFC Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + + /** + * create a Scale Resource object list from a NSScaleRequestJso nString + * This method is for the specific request from Scale Network Service BPMN workflow + * @param nsScaleRequestJsonString , a specific request Json string which conform to ?? class + * @return List < ScaleResource > + */ + private List jsonGetNsResourceList(String nsScaleRequestJsonString) { + List list = new ArrayList() + JSONObject jsonObject = new JSONObject(nsScaleRequestJsonString) + + JSONObject jsonResource = jsonObject.getJSONObject("service") + JSONArray arr = jsonResource.getJSONArray("resources") + + for (int i = 0; i < arr.length(); i++) { + JSONObject tempResource = arr.getJSONObject(i) + ScaleResource resource = new ScaleResource() + resource.setResourceInstanceId(tempResource.getString("resourceInstanceId")) + resource.setScaleType(tempResource.getString("scaleType")) + + JSONObject jsonScaleNsData = tempResource.getJSONObject("scaleNsData") + JSONObject jsonScaleNsByStepData = jsonScaleNsData.getJSONObject("scaleNsByStepsData") + + ScaleNsData scaleNsData = new ScaleNsData() + ScaleNsByStepsData stepsData = new ScaleNsByStepsData() + + stepsData.setAspectId(jsonScaleNsByStepData.getString("aspectId")) + stepsData.setScalingDirection(jsonScaleNsByStepData.getString("scalingDirection")) + stepsData.setNumberOfSteps(Integer.parseInt(jsonScaleNsByStepData.getString("numberOfSteps"))) + + scaleNsData.setScaleNsByStepsData(stepsData) + resource.setScaleNsData(scaleNsData) + list.add(resource) + } + + return list + } + + /** + * Convert a java class to JSON string + * @param obj + * @return + */ + private String objectToJsonStr(Object obj) { + ObjectMapper mapper = new ObjectMapper() + String jsonStr = null + try { + jsonStr = mapper.writeValueAsString(obj) + } catch (IOException ioe) { + System.out.println(ioe.getMessage()) + } + return jsonStr + + } + + /** + * create a NSResourceInputParameter list from a Scale Network request Json string + * @return + */ + private List convertScaleNsReq2NSResInputParamList(DelegateExecution execution) { + String saleNsRequest = execution.getVariable("bpmnRequest") + + //String requestId = execution.getVariable("msoRequestId") + //String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + //String nodeTemplateUUID = execution.getVariable("nodeTemplateUUID") + String serviceType = execution.getVariable("serviceType") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String operationId = execution.getVariable("operationId") + String serviceId = execution.getVariable("serviceId") + String nsServiceDescription = execution.getVariable("requestDescription") + + String resource = JsonUtils.getJsonValue(saleNsRequest, "service.resources") + + // set nsScaleParameters properties + List scaleResourcesList = jsonGetNsResourceList(saleNsRequest) + List nsResourceInputParameterList = new ArrayList() + + for (ScaleResource sr : scaleResourcesList) { + NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter() + NsOperationKey nsOperationKey = new NsOperationKey() + NsParameters nsParameters = new NsParameters() + NsScaleParameters nsScaleParameters = new NsScaleParameters() + nsParameters.setLocationConstraints(new ArrayList()) + nsParameters.setAdditionalParamForNs(new HashMap()) + + // set NsOperationKey properties + nsOperationKey.setGlobalSubscriberId(globalSubscriberId) + nsOperationKey.setServiceId(serviceId) + nsOperationKey.setServiceType(serviceType) + // for ns scale the resourceInstanceId is the nodeTemplateUUID + nsOperationKey.setNodeTemplateUUID(sr.getResourceInstanceId()) + nsOperationKey.setOperationId(operationId) + + nsScaleParameters.setScaleType(sr.getScaleType()) + nsScaleParameters.setNsInstanceId(sr.getResourceInstanceId()) + + ScaleNsByStepsData scaleNsByStepsData = new ScaleNsByStepsData() + scaleNsByStepsData.setScalingDirection(sr.getScaleNsData().getScaleNsByStepsData().getScalingDirection()) + scaleNsByStepsData.setNumberOfSteps(sr.getScaleNsData().getScaleNsByStepsData().getNumberOfSteps()) + scaleNsByStepsData.setAspectId(sr.getScaleNsData().getScaleNsByStepsData().getAspectId()) + + List scaleNsByStepsDataList = new ArrayList() + scaleNsByStepsDataList.add(scaleNsByStepsData) + nsScaleParameters.setScaleNsByStepsData(scaleNsByStepsDataList) + + nsResourceInputParameter.setNsOperationKey(nsOperationKey) + nsResourceInputParameter.setNsServiceName(serviceInstanceName) + nsResourceInputParameter.setNsServiceDescription(nsServiceDescription) + nsResourceInputParameter.setNsParameters(nsParameters) + nsResourceInputParameter.setNsScaleParameters(nsScaleParameters) + + nsResourceInputParameterList.add(nsResourceInputParameter) + } + return nsResourceInputParameterList + } +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy new file mode 100644 index 0000000000..5fb6a9df9a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy @@ -0,0 +1,451 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.json.JsonUtils +import org.springframework.web.util.UriUtils; + +import groovy.json.* + + +/** + * This groovy class supports the DoUpdateE2EServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId + * @param - serviceType + * @param - serviceInstanceId + * @param - serviceInstanceName + * @param - serviceModelInfo + * @param - productFamilyId + * @param - uuiRequest + * @param - serviceDecomposition_Target + * @param - serviceDecomposition_Original + * @param - addResourceList + * @param - delResourceList + * + * Outputs: + * @param - rollbackData (localRB->null) + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * @param - WorkflowException + */ +public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DUPDSI_" + private static final String DebugFlag = "isDebugEnabled" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** Enter DoUpdateE2EServiceInstance preProcessRequest *****", isDebugEnabled) + + String msg = "" + + try { + execution.setVariable("prefix", Prefix) + //Inputs + //for AAI GET & PUT & SDNC assignToplology + String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId + utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled) + + //for AAI PUT & SDNC assignTopology + String serviceType = execution.getVariable("serviceType") + utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled) + + //for SDNC assignTopology + String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId + + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + if (isBlank(serviceType)) { + msg = "Input serviceType is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //Generated in parent for AAI + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)){ + msg = "Input serviceInstanceId is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + String serviceInstanceName = execution.getVariable("serviceInstanceName") + + // user params + String uuiRequest = execution.getVariable("uuiRequest") + + // target model Invariant uuid + String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + utils.log("INFO", "modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled) + + // target model uuid + String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") + execution.setVariable("modelUuid", modelUuid) + + utils.log("INFO","modelUuid: " + modelUuid, isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "======== COMPLETED preProcessRequest Process ======== ", isDebugEnabled) + } + + + public void preInitResourcesOperStatus(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + + utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String resourceTemplateUUIDs = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service updating" + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + List resourceList = new ArrayList() + List addResourceList = execution.getVariable("addResourceList") + List delResourceList = execution.getVariable("delResourceList") + resourceList.addAll(addResourceList) + resourceList.addAll(delResourceList) + for(Resource resource : resourceList){ + resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" + } + + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(resourceTemplateUUIDs)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_initResOperStatusRequest", payload) + utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) + utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) + } + utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) + } + + + public void preProcessForAddResource(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** preProcessForAddResource ***** ", isDebugEnabled) + + execution.setVariable("operationType", "create") + + execution.setVariable("hasResourcetoAdd", false) + List addResourceList = execution.getVariable("addResourceList") + if(addResourceList != null && !addResourceList.isEmpty()) { + execution.setVariable("hasResourcetoAdd", true) + } + + utils.log("INFO"," *** Exit preProcessForAddResource *** ", isDebugEnabled) + } + + public void postProcessForAddResource(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessForAddResource ***** ", isDebugEnabled) + + execution.setVariable("operationType", "update") + + utils.log("INFO"," *** Exit postProcessForAddResource *** ", isDebugEnabled) + } + + public void preProcessForDeleteResource(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** preProcessForDeleteResource ***** ", isDebugEnabled) + + execution.setVariable("operationType", "delete") + + def hasResourcetoDelete = false + List delResourceList = execution.getVariable("delResourceList") + if(delResourceList != null && !delResourceList.isEmpty()) { + hasResourcetoDelete = true + } + execution.setVariable("hasResourcetoDelete", hasResourcetoDelete) + + if(hasResourcetoDelete) { + def jsonSlurper = new JsonSlurper() + String serviceRelationShip = execution.getVariable("serviceRelationShip") + List relationShipList = jsonSlurper.parseText(serviceRelationShip) + + //Set the real resource instance id to the decomosed resource list + for(Resource resource: delResourceList){ + //reset the resource instance id , because in the decompose flow ,its a random one. + resource.setResourceId(""); + //match the resource-instance-name and the model name + if (relationShipList != null) { + relationShipList.each { + if(StringUtils.containsIgnoreCase(it.resourceType, resource.getModelInfo().getModelName())){ + resource.setResourceId(it.resourceInstanceId); + } + } + } + } + } + + execution.setVariable("deleteResourceList", delResourceList) + + utils.log("INFO"," *** Exit preProcessForDeleteResource *** ", isDebugEnabled) + } + + public void postProcessForDeleteResource(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessForDeleteResource ***** ", isDebugEnabled) + + execution.setVariable("operationType", "update") + + utils.log("INFO"," *** Exit postProcessForDeleteResource *** ", isDebugEnabled) + } + + public void preProcessAAIGET(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + } + + public void postProcessAAIGET(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET", + serviceInstanceName, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + String aaiService = execution.getVariable("GENGS_service") + if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "resource-version"))) { + execution.setVariable("serviceInstanceVersion", utils.getNodeText(aaiService, "resource-version")) + utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled) + } + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoUpdateE2EServiceInstance.postProcessAAIGET " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) + } + + public void preProcessAAIPUT(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + String msg = "" + utils.log("INFO"," ***** preProcessAAIPUT *****", isDebugEnabled) + + + String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion") + //execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion) + + //requestDetails.modelInfo.for AAI PUT servieInstanceData + //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + //aai serviceType and Role can be setted as fixed value now. + String aaiServiceType = "E2E Service" + String aaiServiceRole = "E2E Service" + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + + + AaiUtil aaiUriUtil = new AaiUtil(this) + utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) + String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + utils.log("INFO","namespace: " + namespace, isDebugEnabled) + + //update target model to aai + String serviceInstanceData = + """ + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${MsoUtils.xmlEscape(aaiServiceType)} + ${MsoUtils.xmlEscape(aaiServiceRole)} + ${MsoUtils.xmlEscape(serviceInstanceVersion)} + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + """.trim() + + execution.setVariable("serviceInstanceData", serviceInstanceData) + utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled) + utils.logAudit(serviceInstanceData) + utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled) + utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) + + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void postProcessAAIPUT(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled) + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") + if(!succInAAI){ + utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + } + else + { + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "serviceType", execution.getVariable("serviceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled) + } + + public void preProcessRollback (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled) + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled) + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + } + utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled) + } + + public void postProcessRollback (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled) + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled) + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + } + utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled) + } + + + public void postConfigRequest(execution){ + //now do noting + } + + +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy new file mode 100644 index 0000000000..a2d94baaed --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy @@ -0,0 +1,345 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MsoLogger + +import groovy.json.* + + +/** + * This groovy class supports the DoUpdateE2EServiceInstanceRollback.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - rollbackData with + * globalCustomerId + * subscriptionServiceType + * serviceInstanceId + * disableRollback + * rollbackAAI + * rollbackAdded + * rollbackDeleted + * + * + * Outputs: + * @param - rollbackError + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * + */ +public class DoUpdateE2EServiceInstanceRollback extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateE2EServiceInstanceRollback.class); + + + String Prefix="DUPDSIRB_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void preProcessRequest(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + String msg = "" + msoLogger.trace("preProcessRequest ") + execution.setVariable("rollbackAAI",false) + execution.setVariable("rollbackAdded",false) + execution.setVariable("rollbackDeleted",false) + + List addResourceList = execution.getVariable("addResourceList") + List delResourceList = execution.getVariable("delResourceList") + execution.setVariable("addResourceList_o", addResourceList) + execution.setVariable("delResourceList_o", delResourceList) + //exchange add and delete resource list + execution.setVariable("addResourceList", delResourceList) + execution.setVariable("delResourceList", addResourceList) + + try { + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("RollbackData:" + rollbackData) + + if (rollbackData != null) { + if (rollbackData.hasType("SERVICEINSTANCE")) { + + def serviceInstanceId = rollbackData.get("SERVICEINSTANCE", "serviceInstanceId") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + def subscriptionServiceType = rollbackData.get("SERVICEINSTANCE", "subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + + def globalSubscriberId = rollbackData.get("SERVICEINSTANCE", "globalSubscriberId") + execution.setVariable("globalSubscriberId", globalSubscriberId) + + def rollbackAAI = rollbackData.get("SERVICEINSTANCE", "rollbackAAI") + if ("true".equals(rollbackAAI)) + { + execution.setVariable("rollbackAAI",true) + } + + def rollbackAdded = rollbackData.get("SERVICEINSTANCE", "rollbackAdded") + if ("true".equals(rollbackAdded)) + { + execution.setVariable("rollbackAdded", true) + } + + def rollbackDeleted = rollbackData.get("SERVICEINSTANCE", "rollbackDeleted") + if ("true".equals(rollbackDeleted)) + { + execution.setVariable("rollbackDeleted", true) + } + + if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackAdded") != true + && execution.getVariable("rollbackDeleted") != true) + { + execution.setVariable("skipRollback", true) + } + + } + else { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in Update ServiceInstance Rollback preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void postProcessRequest(DelegateExecution execution) { + msoLogger.trace("postProcessRequest ") + String msg = "" + try { + execution.setVariable("rollbackData", null) + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean rollbackAAI = execution.getVariable("rollbackAAI") + boolean rollbackAdded = execution.getVariable("rollbackAdded") + boolean rollbackDeleted = execution.getVariable("rollbackDeleted") + + List addResourceList = execution.getVariable("addResourceList_o") + List delResourceList = execution.getVariable("delResourceList_o") + execution.setVariable("addResourceList", addResourceList) + execution.setVariable("delResourceList", delResourceList) + + if (rollbackAAI || rollbackAdded || rollbackDeleted) + { + execution.setVariable("rolledBack", true) + } + if (rollbackAAI) + { + boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") + if(!succInAAI){ + execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful + execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback") + msoLogger.debug("Error deleting service-instance in AAI for rollback", + serviceInstanceId) + } + } + msoLogger.trace("Exit postProcessRequest ") + + } catch (BpmnError e) { + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage() + msoLogger.debug(msg) + } catch (Exception ex) { + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() + msoLogger.debug(msg) + } + } + + + public void preProcessForAddResource(DelegateExecution execution) { + } + + public void postProcessForAddResource(DelegateExecution execution) { + } + + public void preProcessForDeleteResource(DelegateExecution execution) { + } + + public void postProcessForDeleteResource(DelegateExecution execution) { + } + + public void preProcessAAIGET(DelegateExecution execution) { + } + + public void postProcessAAIGET(DelegateExecution execution) { + msoLogger.trace("postProcessAAIGET ") + String msg = "" + + try { + String serviceInstanceName = execution.getVariable("serviceInstanceName") + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error getting Service-instance from AAI in postProcessAAIGET", + serviceInstanceName) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + else + { + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + if(foundInAAI){ + String aaiService = execution.getVariable("GENGS_service") + if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "resource-version"))) { + execution.setVariable("serviceInstanceVersion_n", utils.getNodeText(aaiService, "resource-version")) + msoLogger.info("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName")) + } + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIGET " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIGET ") + } + + public void preProcessAAIPUT(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + msoLogger.info("Entered " + method) + String msg = "" + msoLogger.trace("preProcessAAIPUT ") + + String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion_n") +// execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion) + + //requestDetails.modelInfo.for AAI PUT servieInstanceData + //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData + String serviceInstanceName = execution.getVariable("serviceInstanceName") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + //aai serviceType and Role can be setted as fixed value now. + String aaiServiceType = "E2E Service" + String aaiServiceRole = "E2E Service" + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("model-version-id-original") + + //AAI PUT + AaiUtil aaiUriUtil = new AaiUtil(this) + utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) + String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + utils.log("INFO","namespace: " + namespace, isDebugEnabled) + + String serviceInstanceData = + """ + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceInstanceName)} + ${MsoUtils.xmlEscape(aaiServiceType)} + ${MsoUtils.xmlEscape(aaiServiceRole)} + ${MsoUtils.xmlEscape(serviceInstanceVersion)} + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + """.trim() + + execution.setVariable("serviceInstanceData", serviceInstanceData) + msoLogger.info("serviceInstanceData: " + serviceInstanceData) + msoLogger.debug(serviceInstanceData) + msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace) + msoLogger.info(" 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData) + + msoLogger.info("Exited " + method) + } + + public void postProcessAAIPUT(DelegateExecution execution) { + msoLogger.trace("postProcessAAIPUT ") + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") + if(!succInAAI){ + msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId) + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + } + else + { + + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + msoLogger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit postProcessAAIPUT ") + } + + public void processRollbackException(DelegateExecution execution){ + msoLogger.trace("processRollbackException ") + try{ + msoLogger.debug("Caught an Exception in DoUpdateE2EServiceInstanceRollback") + execution.setVariable("rollbackData", null) + execution.setVariable("rollbackError", "Caught exception in ServiceInstance Update Rollback") + execution.setVariable("WorkflowException", null) + + }catch(BpmnError b){ + msoLogger.debug("BPMN Error during processRollbackExceptions Method: ") + }catch(Exception e){ + msoLogger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage()) + } + + msoLogger.debug(" Exit processRollbackException") + } + + public void processRollbackJavaException(DelegateExecution execution){ + msoLogger.trace("processRollbackJavaException ") + try{ + execution.setVariable("rollbackData", null) + execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Update Rollback") + msoLogger.debug("Caught Exception in processRollbackJavaException") + + }catch(Exception e){ + msoLogger.debug("Caught Exception in processRollbackJavaException " + e.getMessage()) + } + msoLogger.trace("Exit processRollbackJavaException ") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy new file mode 100644 index 0000000000..7272f421fc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -0,0 +1,1408 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +import groovy.json.* +import groovy.xml.XmlUtil + +/** + * This groovy class supports the DoUpdateNetworkInstance.bpmn process. + * + */ +public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateNetworkInstance.class); + + String Prefix="UPDNETI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + /** + * This method is executed during the preProcessRequest task of the DoUpdateNetworkInstance.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "messageId", "") + execution.setVariable("BasicAuthHeaderValuePO", "") + execution.setVariable("BasicAuthHeaderValueSDNC", "") + execution.setVariable(Prefix + "networkRequest", "") + execution.setVariable(Prefix + "networkInputs", "") + execution.setVariable(Prefix + "networkOutputs", "") + execution.setVariable(Prefix + "requestId", "") + execution.setVariable(Prefix + "source", "") + execution.setVariable(Prefix + "networkId", "") + + execution.setVariable(Prefix + "isPONR", false) // Point-of-no-return, means, rollback is not needed + + // AAI query Cloud Region + execution.setVariable(Prefix + "queryCloudRegionRequest","") + execution.setVariable(Prefix + "queryCloudRegionReturnCode","") + execution.setVariable(Prefix + "queryCloudRegionResponse","") + execution.setVariable(Prefix + "cloudRegionPo","") + execution.setVariable(Prefix + "cloudRegionSdnc","") + execution.setVariable(Prefix + "isCloudRegionGood", false) + + // AAI query Id + execution.setVariable(Prefix + "queryIdAAIRequest","") + execution.setVariable(Prefix + "queryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiIdReturnCode", "") + + // AAI query vpn binding + execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") + execution.setVariable(Prefix + "vpnBindings", null) + execution.setVariable(Prefix + "vpnCount", 0) + execution.setVariable(Prefix + "routeCollection", "") + + // AAI query network policy + execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") + execution.setVariable(Prefix + "networkPolicyUriList", null) + execution.setVariable(Prefix + "networkPolicyCount", 0) + execution.setVariable(Prefix + "networkCollection", "") + + // AAI query route table reference + execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") + execution.setVariable(Prefix + "networkTableRefUriList", null) + execution.setVariable(Prefix + "networkTableRefCount", 0) + execution.setVariable(Prefix + "tableRefCollection", "") + + // AAI requery Id + execution.setVariable(Prefix + "requeryIdAAIRequest","") + execution.setVariable(Prefix + "requeryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") + + // AAI update contrail + execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") + execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") + execution.setVariable(Prefix + "updateContrailAAIResponse", "") + execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") + + execution.setVariable(Prefix + "updateNetworkRequest", "") + execution.setVariable(Prefix + "updateNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + execution.setVariable(Prefix + "networkReturnCode", "") + execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) + + execution.setVariable(Prefix + "changeAssignSDNCRequest", "") + execution.setVariable(Prefix + "changeAssignSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + execution.setVariable(Prefix + "sdncReturnCode", "") + execution.setVariable(Prefix + "isSdncRollbackNeeded", false) + execution.setVariable(Prefix + "sdncResponseSuccess", false) + + execution.setVariable(Prefix + "isVnfBindingPresent", false) + execution.setVariable(Prefix + "Success", false) + execution.setVariable(Prefix + "serviceInstanceId", "") + + execution.setVariable(Prefix + "isException", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the DoUpdateNetworkInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest DoUpdateNetworkInstance Request ") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request & validate 3 kinds of format. + execution.setVariable("action", "UPDATE") + String networkRequest = execution.getVariable("bpmnRequest") + if (networkRequest != null) { + if (networkRequest.contains("requestDetails")) { + // JSON format request is sent, create xml + try { + def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) + msoLogger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) + networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) + + } catch (Exception ex) { + String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } else { + // XML format request is sent + + } + } else { + // vIPR format request is sent, create xml from individual variables + networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) + } + + networkRequest = utils.formatXml(networkRequest) + msoLogger.debug(networkRequest) + execution.setVariable(Prefix + "networkRequest", networkRequest) + msoLogger.debug(" network-request - " + '\n' + networkRequest) + + // validate 'disableRollback' (aka, 'suppressRollback') + boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) + execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) + msoLogger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) + + String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") + execution.setVariable(Prefix + "networkInputs", networkInputs) + msoLogger.debug(Prefix + "networkInputs - " + '\n' + networkInputs) + + // prepare messageId + String messageId = execution.getVariable(Prefix + "messageId") // for testing + if (messageId == null || messageId == "") { + messageId = UUID.randomUUID() + msoLogger.debug(" UPDNETI_messageId, random generated: " + messageId) + } else { + msoLogger.debug(" UPDNETI_messageId, pre-assigned: " + messageId) + } + execution.setVariable(Prefix + "messageId", messageId) + + String source = utils.getNodeText(networkRequest, "source") + execution.setVariable(Prefix + "source", source) + msoLogger.debug(Prefix + "source - " + source) + + String networkId = "" + if (utils.nodeExists(networkRequest, "network-id")) { + networkId = utils.getNodeText(networkRequest, "network-id") + if (networkId == 'null' || networkId == "") { + sendSyncError(execution) + // missing value of networkId + String dataErrorMessage = "Variable 'network-id' value/element is missing." + msoLogger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + + String lcpCloudRegion = "" + if (utils.nodeExists(networkRequest, "aic-cloud-region")) { + lcpCloudRegion = utils.getNodeText(networkRequest, "aic-cloud-region") + if ((lcpCloudRegion == 'null') || (lcpCloudRegion == "")) { + sendSyncError(execution) + String dataErrorMessage = "requestDetails has missing 'aic-cloud-region' value/element." + msoLogger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + + String serviceInstanceId = "" + if (utils.nodeExists(networkRequest, "service-instance-id")) { + serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id") + if ((serviceInstanceId == 'null') || (lcpCloudRegion == "")) { + sendSyncError(execution) + String dataErrorMessage = "Variable 'serviceInstanceId' value/element is missing." + msoLogger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // Set variables for Generic Get Sub Flow use + execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) + msoLogger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId) + + execution.setVariable("GENGS_type", "service-instance") + msoLogger.debug("GENGS_type - " + "service-instance") + msoLogger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution)) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion? : " + sdncVersion) + + // build 'networkOutputs' + networkId = utils.getNodeText(networkRequest, "network-id") + if ((networkId == null) || (networkId == "null")) { + networkId = "" + } + String networkName = utils.getNodeText(networkRequest, "network-name") + if ((networkName == null) || (networkName == "null")) { + networkName = "" + } + String networkOutputs = + """ + ${MsoUtils.xmlEscape(networkId)} + ${MsoUtils.xmlEscape(networkName)} + """ + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + msoLogger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs) + execution.setVariable(Prefix + "networkId", networkId) + execution.setVariable(Prefix + "networkName", networkName) + + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + } + + public void callRESTQueryAAICloudRegion (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAICloudRegion of DoUpdateNetworkInstance ***** " ) + + try { + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + msoLogger.debug(queryCloudRegionRequest) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + msoLogger.debug(" UPDNETI_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) + + String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) + + if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { + execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) + execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) + execution.setVariable(Prefix + "isCloudRegionGood", true) + + } else { + String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood")) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // try error + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkId(DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkId of DoUpdateNetworkInstance ***** " ) + + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String networkId = utils.getNodeText(networkRequest, "network-id") + networkId = UriUtils.encode(networkId,"UTF-8") + execution.setVariable(Prefix + "networkId", networkId) + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + msoLogger.debug(queryIdAAIRequest) + execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) + msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiIdReturnCode", returnCode) + msoLogger.debug(" ***** AAI Response Code : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + msoLogger.debug(aaiResponseAsString) + execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString) + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." + msoLogger.debug(" AAI Query Failed. " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode + msoLogger.debug("Unexpected Response from QueryAAINetworkId - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTReQueryAAINetworkId(DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTReQueryAAINetworkId of DoUpdateNetworkInstance ***** " ) + + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String networkId = utils.getNodeText(networkRequest, "network-id") + networkId = UriUtils.encode(networkId,"UTF-8") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + msoLogger.debug(requeryIdAAIRequest) + execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) + msoLogger.debug(" UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode) + msoLogger.debug(" ***** AAI ReQuery Response Code : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + msoLogger.debug(aaiResponseAsString) + execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString) + msoLogger.debug(" ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString) + + String netId = utils.getNodeText(aaiResponseAsString, "network-id") + String netName = utils.getNodeText(aaiResponseAsString, "network-name") + String networkOutputs = + """ + ${MsoUtils.xmlEscape(netId)} + ${MsoUtils.xmlEscape(netName)} + """ + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs) + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." + msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding of DoUpdateNetworkInstance ***** " ) + + try { + + // get variables + String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") + String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") + msoLogger.debug(" relationship - " + relationship) + + // Check if Vnf Binding is present, then build a List of vnfBinding + List vpnBindingUri = networkUtils.getVnfBindingObject(relationship) + int vpnCount = vpnBindingUri.size() + execution.setVariable(Prefix + "vpnCount", vpnCount) + msoLogger.debug(" UPDNETI_vpnCount - " + vpnCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (vpnCount > 0) { + execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) + msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri) + + String routeTargets = "" + // AII loop call using list vpnBindings + for (i in 0..vpnBindingUri.size()-1) { + + int counting = i+1 + + // prepare url using vpnBinding + String queryVpnBindingAAIRequest = "" + String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) + + // Note: By default, the vpnBinding url is found in 'related-link' of the response, + // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. + if (aai_uri == null || aai_uri == "") { + // using value of 'related-link' from response + if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" + } else { + queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" + } + + } else { + // using uri value in URN mapping + String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) + if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { + vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) + } + queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" + } + + msoLogger.debug(queryVpnBindingAAIRequest) + execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) + msoLogger.debug(" UPDNETI_queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) + msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + msoLogger.debug(aaiResponseAsString) + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) + msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString) + + String routeTarget = "" + String routeRole = "" + if (utils.nodeExists(aaiResponseAsString, "route-targets")) { + String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) + def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) + def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} + for (j in 0..aaiRouteTarget.size()-1) { + routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") + routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") + routeTargets += "" + '\n' + + " " + routeTarget + "" + '\n' + + " " + routeRole + "" + '\n' + + "" + '\n' + } + } + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + execution.setVariable(Prefix + "routeCollection", routeTargets) + msoLogger.debug(" UPDNETI_routeCollection - " + '\n' + routeTargets) + + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiStubResponse = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "routeCollection", "") + msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkPolicy of DoUpdateNetworkInstance ***** " ) + + try { + // get variables + String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") + String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") + msoLogger.debug(" relationship - " + relationship) + + // Check if Network Policy is present, then build a List of network policy + List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship) + int networkPolicyCount = networkPolicyUriList.size() + execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) + msoLogger.debug(" UPDNETI_networkPolicyCount - " + networkPolicyCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (networkPolicyCount > 0) { + execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList) + msoLogger.debug(" networkPolicyUri List - " + networkPolicyUriList) + + String networkPolicies = "" + // AII loop call using list vpnBindings + for (i in 0..networkPolicyUriList.size()-1) { + + int counting = i+1 + + // prepare url using vpnBinding + String queryNetworkPolicyAAIRequest = "" + + String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) + + // Note: By default, the network policy url is found in 'related-link' of the response, + // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. + if (aai_uri == null || aai_uri == "") { + // using value of 'related-link' from response + if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" + } else { + queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" + } + } else { + // using uri value in URN mapping + String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) + println " networkPolicyId - " + networkPolicyId + if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { + networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) + } + queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" + + } + + + msoLogger.debug(queryNetworkPolicyAAIRequest) + execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) + msoLogger.debug(" UPDNETI_queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + msoLogger.debug(aaiResponseAsString) + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) + + String networkPolicy = "" + if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) { + networkPolicy = utils.getNodeText(aaiResponseAsString, "network-policy-fqdn") + networkPolicies += "" + networkPolicy + "" + '\n' + } + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + execution.setVariable(Prefix + "networkCollection", networkPolicies) + msoLogger.debug(" UPDNETI_networkCollection - " + '\n' + networkPolicies) + + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiStubResponse = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "networkCollection", "") + msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTQueryAAINetworkTableRef of DoUpdateNetworkInstance ***** " ) + + try { + // get variables + String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") + String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") + msoLogger.debug(" relationship - " + relationship) + + // Check if Network TableREf is present, then build a List of network policy + List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship) + int networkTableRefCount = networkTableRefUriList.size() + execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount) + msoLogger.debug(" UPDNETI_networkTableRefCount - " + networkTableRefCount) + + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (networkTableRefCount > 0) { + execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList) + msoLogger.debug(" networkTableRefUri List - " + networkTableRefUriList) + + // AII loop call using list vpnBindings + String networkTableRefs = "" + for (i in 0..networkTableRefUriList.size()-1) { + + int counting = i+1 + + // prepare url using tableRef + String queryNetworkTableRefAAIRequest = "" + + String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) + + // Note: By default, the network policy url is found in 'related-link' of the response, + // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. + if (aai_uri == null || aai_uri == "") { + // using value of 'related-link' from response + if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" + } else { + queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" + } + } else { + // using uri value in URN mapping + String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) + + if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { + networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) + } + queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" + + } + + + msoLogger.debug(queryNetworkTableRefAAIRequest) + execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) + msoLogger.debug(" UPDNETI_queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) + String returnCode = response.getStatusCode() + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode) + msoLogger.debug(" ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode) + + String aaiResponseAsString = response.getResponseBodyAsString() + + if (returnCode=='200') { + msoLogger.debug(aaiResponseAsString) + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString) + msoLogger.debug(" QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString) + + String networkTableRef = "" + if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) { + networkTableRef = utils.getNodeText(aaiResponseAsString, "route-table-reference-fqdn") + networkTableRefs += "" + networkTableRef + "" + '\n' + } + + } else { + if (returnCode=='404') { + String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + } + + } // end loop + + execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) + msoLogger.debug(" UPDNETI_tableRefCollection - " + '\n' + networkTableRefs) + + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiStubResponse = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "tableRefCollection", "") + msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.debug(" ***** Inside callRESTUpdateContrailAAINetwork of DoUpdateNetworkInstance ***** " ) + + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String networkId = utils.getNodeText(networkRequest, "network-id") + networkId = UriUtils.encode(networkId,"UTF-8") + String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") + + // Prepare url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) + String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + + msoLogger.debug(updateContrailAAIUrlRequest) + execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) + msoLogger.debug(" UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest) + + //Prepare payload (PUT) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) + String payloadXml = utils.formatXml(payload) + msoLogger.debug(payloadXml) + execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml) + msoLogger.debug(" 'payload' to Update Contrail - " + "\n" + payloadXml) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payload) + String returnCode = response.getStatusCode() + String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() + + execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode) + msoLogger.debug(" ***** AAI Update Contrail Response Code : " + returnCode) + + + if (returnCode=='200') { + msoLogger.debug(aaiUpdateContrailResponseAsString) + execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString) + msoLogger.debug(" AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString) + // Point-of-no-return is set to false, rollback not needed. + execution.setVariable(Prefix + "isPONR", true) + + } else { + if (returnCode=='404') { + String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + if (aaiUpdateContrailResponseAsString.contains("RESTFault")) { + WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution) + execution.setVariable("WorkflowException", exceptionObject) + throw new BpmnError("MSOWorkflowException") + + } else { + // aai all errors + String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode + msoLogger.debug(errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + } + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareUpdateNetworkRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareUpdateNetworkRequest of DoUpdateNetworkInstance ") + + try { + + // get variables + String requestId = execution.getVariable(Prefix + "requestId") + String messageId = execution.getVariable(Prefix + "messageId") + String source = execution.getVariable(Prefix + "source") + + String requestInput = execution.getVariable(Prefix + "networkRequest") + String queryIdResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") + String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") + + // Prepare Network request + String routeCollection = execution.getVariable(Prefix + "routeCollection") + String policyCollection = execution.getVariable(Prefix + "networkCollection") + String tableCollection = execution.getVariable(Prefix + "tableRefCollection") + String updateNetworkRequest = networkUtils.UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) + // Format Response + String buildUpdateNetworkRequestAsString = utils.formatXml(updateNetworkRequest) + buildUpdateNetworkRequestAsString = buildUpdateNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") + msoLogger.debug(buildUpdateNetworkRequestAsString) + + execution.setVariable(Prefix + "updateNetworkRequest", buildUpdateNetworkRequestAsString) + msoLogger.debug(" UPDNETI_updateNetworkRequest - " + "\n" + buildUpdateNetworkRequestAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareUpdateNetworkRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareSDNCRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareSDNCRequest of DoUpdateNetworkInstance ") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + + String networkId = "" + if (utils.nodeExists(updateNetworkInput, "network-id")) { + networkId = utils.getNodeText(updateNetworkInput, "network-id") + } + if (networkId == null) {networkId = ""} + + String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id") + + String queryAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse") + + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "changeassign", "NetworkActivateRequest", cloudRegionId, networkId, queryAAIResponse, null) + + String sndcTopologyUpdateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + msoLogger.debug(sndcTopologyUpdateRequesAsString) + execution.setVariable(Prefix + "changeAssignSDNCRequest", sndcTopologyUpdateRequesAsString) + msoLogger.debug(" UPDNETI_changeAssignSDNCRequest - " + "\n" + sndcTopologyUpdateRequesAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void validateUpdateNetworkResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside validateUpdateNetworkResponse of DoUpdateNetworkInstance ") + + try { + String returnCode = execution.getVariable(Prefix + "networkReturnCode") + String networkResponse = execution.getVariable(Prefix + "updateNetworkResponse") + if (networkResponse==null) { + networkResponse="" // reset + } + + msoLogger.debug(" Network Adapter update responseCode: " + returnCode) + + String errorMessage = "" + if (returnCode == "200") { + execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) + msoLogger.debug(networkResponse) + execution.setVariable(Prefix + "updateNetworkResponse", networkResponse) + msoLogger.debug(" Network Adapter update Success Response - " + "\n" + networkResponse) + + // prepare rollback data + String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") + rollbackData = rollbackData.replace("rollback>", "networkRollback>") + String rollbackNetwork = + """ + ${rollbackData} + """ + String rollbackNetworkXml = utils.formatXml(rollbackNetwork) + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) + msoLogger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) + + } else { // network error + if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx + if (networkResponse.contains("updateNetworkError")) { + networkResponse = networkResponse.replace('', '') + errorMessage = utils.getNodeText(networkResponse, "message") + errorMessage = "Received error from Network Adapter: " + errorMessage + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + + } else { // CatchAll exception + if (returnCode == "500") { + errorMessage = "JBWEB000065: HTTP Status 500." + } else { + errorMessage = "Return code is " + returnCode + } + errorMessage = "Received error from Network Adapter: " + errorMessage + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + + } + + } else { // CatchAll exception + String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. validateUpdateNetworkResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + public void validateSDNCResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside validateSDNCResponse of DoUpdateNetworkInstance ") + + String response = execution.getVariable(Prefix + "changeAssignSDNCResponse") + WorkflowException workflowException = null + try { + workflowException = execution.getVariable(Prefix + "WorkflowException") + //execution.setVariable("WorkflowException", workflowException) + } catch (Exception ex) { + msoLogger.debug(" Sdnc 'WorkflowException' object is empty or null. ") + } + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String changeAssignSDNCResponseDecodeXml = execution.getVariable(Prefix + "changeAssignSDNCResponse") + changeAssignSDNCResponseDecodeXml = changeAssignSDNCResponseDecodeXml.replace('', "") + execution.setVariable(Prefix + "changeAssignSDNCResponse", changeAssignSDNCResponseDecodeXml) + + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncRollbackNeeded", true) + msoLogger.debug("Successfully Validated SDNC Response") + + } else { + msoLogger.debug("Did NOT Successfully Validated SDNC Response") + throw new BpmnError("MSOWorkflowException") + } + + } + + + public void postProcessResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside postProcessResponse of DoUpdateNetworkInstance ") + + try { + msoLogger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) + if (execution.getVariable(Prefix + "isException") == false) { + // set rollback data + execution.setVariable("orchestrationStatus", "") + execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) + execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) + prepareSuccessRollbackData(execution) // populate rollbackData + execution.setVariable("WorkflowException", null) + execution.setVariable(Prefix + "Success", true) + msoLogger.debug(" ***** postProcessResponse(), GOOD !!!") + } else { + execution.setVariable(Prefix + "Success", false) + execution.setVariable("rollbackData", null) + String exceptionMessage = " Exception encountered in MSO Bpmn. " + if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. + msoLogger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) + WorkflowException wfex = execution.getVariable("workflowException") + exceptionMessage = wfex.getErrorMessage() + } else { + if (execution.getVariable(Prefix + "WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } + } + // going to the Main flow: a-la-carte or macro + msoLogger.debug(" ***** postProcessResponse(), BAD !!!") + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } + + } catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + public void prepareSDNCRollbackRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside prepareSDNCRollbackRequest of DoUpdateNetworkInstance ") + + try { + // for some reason the WorkflowException object is null after the sdnc rollback call task, need to save WorkflowException. + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String changeAssignSDNCResponse = execution.getVariable(Prefix + "changeAssignSDNCResponse") + String networkId = utils.getNodeText(changeAssignSDNCResponse, "network-id") + + String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id") + + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) + msoLogger.debug(" Preparing request for SDNC Topology assign's rollback/compensation . . . - " + "\n" + sndcTopologyRollbackRequestAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareRollbackData() of DoUpdateNetworkInstance ") + + try { + + Map rollbackData = new HashMap(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + msoLogger.debug("** rollbackData : " + rollbackData) + + execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) + msoLogger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareSuccessRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareSuccessRollbackData() of DoUpdateNetworkInstance ") + + try { + + if (execution.getVariable("sdncVersion") != '1610') { + // skip: 1702 for 'changeassign' or equivalent not yet defined in SNDC, so no rollback. + } else { + prepareSDNCRollbackRequest(execution) + } + + Map rollbackData = new HashMap(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + } + } + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("** 'rollbackData' for Full Rollback : " + rollbackData) + execution.setVariable("WorkflowException", null) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void setExceptionFlag(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside setExceptionFlag() of DoUpdateNetworkInstance ") + + try { + + execution.setVariable(Prefix + "isException", true) + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + msoLogger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) + + } catch(Exception ex){ + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + public void processJavaException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a Java Exception") + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") + } + msoLogger.debug("Completed processJavaException Method") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy new file mode 100644 index 0000000000..8a13b3c392 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy @@ -0,0 +1,310 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* + +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoCreateNetworkInstance.bpmn process. + * + */ +public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateNetworkInstanceRollback.class); + + String Prefix="UPDNETIR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the DoUpdateNetworkInstanceRollback.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "rollbackNetworkRequest", null) + execution.setVariable(Prefix + "rollbackSDNCRequest", null) + execution.setVariable(Prefix + "WorkflowException", null) + + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + execution.setVariable(Prefix + "rollbackNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") + + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + execution.setVariable(Prefix + "rollbackSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") + + execution.setVariable(Prefix + "Success", false) + execution.setVariable(Prefix + "fullRollback", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the DoUpdateNetworkInstanceRollback.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy ") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request/variables + String rollbackNetworkRequest = null + String rollbackSDNCRequest = null + + // Partial Rollback + Map rollbackData = execution.getVariable("rollbackData") + if (rollbackData != null && rollbackData instanceof Map) { + + if(rollbackData.containsKey("rollbackNetworkRequest")) { + rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] + } + + if(rollbackData.containsKey("rollbackSDNCRequest")) { + rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] + } + } + + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) + msoLogger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion? : " + sdncVersion) + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + msoLogger.debug(dataErrorMessage ) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + msoLogger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) + if(execution.getVariable(Prefix + "WorkflowException") != null) { + // called by: DoCreateNetworkInstance, partial rollback + execution.setVariable(Prefix + "fullRollback", false) + + } else { + // called by: Macro - Full Rollback, WorkflowException = null + execution.setVariable(Prefix + "fullRollback", true) + + } + msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void validateRollbackResponses (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside validateRollbackResponses() of DoUpdateNetworkInstanceRollback ") + + try { + // validate PO network rollback response + String rollbackNetworkErrorMessages = "" + String rollbackNetworkReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { + rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") + String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse") + msoLogger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) + msoLogger.debug(" NetworkRollback Response - " + rollbackNetworkResponse) + if (rollbackNetworkReturnCode != "200") { + rollbackNetworkErrorMessages = " + PO Network rollback failed. " + } else { + rollbackNetworkErrorMessages = " + PO Network rollback completed." + } + } + + // validate SDNC rollback response + String rollbackSdncErrorMessages = "" + String rollbackSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { + rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") + String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") + String rollbackSDNCReturnInnerCode = "" + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('', "") + if (rollbackSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { + rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") + if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { + rollbackSdncErrorMessages = " + SNDC changeassign rollback completed." + } else { + rollbackSdncErrorMessages = " + SDNC changeassign rollback failed. " + } + } else { + rollbackSdncErrorMessages = " + SNDC changeassign rollback completed." + } + } else { + rollbackSdncErrorMessages = " + SDNC changeassign rollback failed. " + } + msoLogger.debug(" SDNC changeassign rollback Code - " + rollbackSDNCReturnCode) + msoLogger.debug(" SDNC changeassign rollback Response - " + rollbackSDNCResponse) + } + + String statusMessage = "" + int errorCode = 7000 + msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + if (execution.getVariable(Prefix + "fullRollback") == false) { + // original WorkflowException, + WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") + if (wfe != null) { + // rollback due to failure in DoCreate - Partial rollback + statusMessage = wfe.getErrorMessage() + errorCode = wfe.getErrorCode() + } else { + statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + errorCode = '7000' + } + + // set if all rolledbacks are successful + if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { + execution.setVariable("rolledBack", true) + + } else { + execution.setVariable("rolledBack", false) + + } + + statusMessage = statusMessage + rollbackNetworkErrorMessages + rollbackSdncErrorMessages + msoLogger.debug("Final DoUpdateNetworkInstanceRollback status message: " + statusMessage) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); + execution.setVariable("workflowException", exception); + + } else { + // rollback due to failures in Main flow (Macro) - Full rollback + // WorkflowException = null + if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { + execution.setVariable("rollbackSuccessful", true) + execution.setVariable("rollbackError", false) + } else { + String exceptionMessage = "Network Update Rollback was not Successful. " + msoLogger.debug(exceptionMessage) + execution.setVariable("rollbackSuccessful", false) + execution.setVariable("rollbackError", true) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } + + } + + + } catch (Exception ex) { + execution.setVariable("WorkflowException", null) + String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) + + } + + } + + // ******************************* + // Build Error Section + // ******************************* + + + + public void processJavaException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + try{ + msoLogger.debug("Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.trace("Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy new file mode 100644 index 0000000000..451e0293ef --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -0,0 +1,1040 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.common.scripts.VfModule +import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +public class DoUpdateVfModule extends VfModuleBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateVfModule.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils catalog = new CatalogDbUtils() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'DOUPVfMod_') + execution.setVariable('DOUPVfMod_requestInfo', null) + execution.setVariable('DOUPVfMod_serviceInstanceId', null) + execution.setVariable('DOUPVfMod_requestId', null) + execution.setVariable('DOUPVfMod_vnfInputs', null) + execution.setVariable('DOUPVfMod_vnfId', null) + execution.setVariable('DOUPVfMod_vnfName', null) + execution.setVariable('DOUPVfMod_vnfNameFromAAI', null) + execution.setVariable('DOUPVfMod_vfModuleName', null) + execution.setVariable('DOUPVfMod_vfModuleId', null) + execution.setVariable('DOUPVfMod_vnfType', null) + execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null) + execution.setVariable('DOUPVfMod_vfModuleModelName', null) + execution.setVariable('DOUPVfMod_modelCustomizationUuid', null) + execution.setVariable("DOUPVfMod_isBaseVfModule", "false") + execution.setVariable('DOUPVfMod_serviceId', null) + 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", "") + execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "") + execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null) + execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null) + execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null) + execution.setVariable('DOUPVfMod_sdncActivateRequest', null) + execution.setVariable('DOUPVfMod_sdncActivateResponse', null) + execution.setVariable('DOUPVfMod_sdncTopologyRequest', null) + execution.setVariable('DOUPVfMod_sdncTopologyResponse', null) + execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null) + execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null) + execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null) + execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false) + execution.setVariable('DoUpdateVfModuleSuccessIndicator', false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + initProcessVariables(execution) + def xml = getVariable(execution, 'DoUpdateVfModuleRequest') + msoLogger.debug("DoUpdateVfModule request: " + xml) + msoLogger.debug('Received request xml:\n' + xml) + + if (xml == null || xml.isEmpty()) { + // Building Block-type request + + String cloudConfiguration = execution.getVariable("cloudConfiguration") + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + + def serviceModelInfo = execution.getVariable("serviceModelInfo") + msoLogger.debug("serviceModelInfo: " + serviceModelInfo) + String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") + msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid) + def vnfModelInfo = execution.getVariable("vnfModelInfo") + + //tenantId + def tenantId = execution.getVariable("tenantId") + execution.setVariable("DOUPVfMod_tenantId", tenantId) + + //volumeGroupId + def volumeGroupId = execution.getVariable("volumeGroupId") + execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) + + //cloudSiteId + def cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId) + + msoLogger.debug("cloudSiteId: " + cloudSiteId) + //vnfType + def vnfType = execution.getVariable("vnfType") + execution.setVariable("DOUPVfMod_vnfType", vnfType) + + msoLogger.debug("vnfType: " + vnfType) + //vnfName + def vnfName = execution.getVariable("vnfName") + execution.setVariable("DOUPVfMod_vnfName", vnfName) + + msoLogger.debug("vnfName: " + vnfName) + //vnfId + def vnfId = execution.getVariable("vnfId") + execution.setVariable("DOUPVfMod_vnfId", vnfId) + + msoLogger.debug("vnfId: " + vnfId) + //vfModuleName + def vfModuleName = execution.getVariable("vfModuleName") + execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName) + + msoLogger.debug("vfModuleName: " + vfModuleName) + //vfModuleModelName + def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") + execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName) + + msoLogger.debug("vfModuleModelName: " + vfModuleModelName) + //modelCustomizationUuid + def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") + if (modelCustomizationUuid == null) { + modelCustomizationUuid = "" + } + execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) + + msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid) + //vfModuleId + def vfModuleId = execution.getVariable("vfModuleId") + execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId) + msoLogger.debug("vfModuleId: " + vfModuleId) + def requestId = execution.getVariable("msoRequestId") + execution.setVariable("DOUPVfMod_requestId", requestId) + msoLogger.debug("requestId: " + requestId) + // Set mso-request-id to request-id for VNF Adapter interface + execution.setVariable("mso-request-id", requestId) + //serviceId + def serviceId = execution.getVariable("serviceId") + execution.setVariable("DOUPVfMod_serviceId", serviceId) + msoLogger.debug("serviceId: " + serviceId) + //serviceInstanceId + def serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId) + + msoLogger.debug("serviceInstanceId: " + serviceInstanceId) + //source - HARDCODED + def source = "VID" + execution.setVariable("DOUPVfMod_source", source) + + msoLogger.debug("source: " + source) + //backoutOnFailure + def disableRollback = execution.getVariable("disableRollback") + def backoutOnFailure = true + if (disableRollback != null && disableRollback.equals("true")) { + backoutOnFailure = false + } + execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) + msoLogger.debug("backoutOnFailure: " + backoutOnFailure) + //isBaseVfModule + def isBaseVfModule = execution.getVariable("isBaseVfModule") + execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) + msoLogger.debug("isBaseVfModule: " + isBaseVfModule) + //asdcServiceModelVersion + def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") + execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion) + msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion) + //personaModelId + execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid")) + //personaModelVersion + execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion")) + //Get or Generate UUID + String uuid = execution.getVariable("DOUPVfMod_uuid") + if(uuid == null){ + uuid = UUID.randomUUID() + msoLogger.debug("Generated messageId (UUID) is: " + uuid) + }else{ + msoLogger.debug("Found messageId (UUID) is: " + uuid) + } + //isVidRequest + String isVidRequest = execution.getVariable("isVidRequest") + // default to true + if (isVidRequest == null || isVidRequest.isEmpty()) { + execution.setVariable("isVidRequest", "true") + } + //usePreload + def usePreload = execution.getVariable("usePreload") + execution.setVariable("DOUPVfMod_usePreload", usePreload) + msoLogger.debug("usePreload: " + usePreload) + //globalSubscriberId + String globalSubscriberId = execution.getVariable("globalSubscriberId") + execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId) + msoLogger.debug("globalSubsrciberId: " + globalSubscriberId) + //vnfQueryPath + String vnfQueryPath = execution.getVariable("vnfQueryPath") + execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath) + msoLogger.debug("vnfQueryPath: " + vnfQueryPath) + + Map vfModuleInputParams = execution.getVariable("vfModuleInputParams") + if (vfModuleInputParams != null) { + execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) + } + //get workload and environment context from parent SI + String environmentContext = "" + String workloadContext ="" + String serviceType ="" + + try{ + String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + String msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + try{ + AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) + AAIResourcesClient aaiRC = new AAIResourcesClient() + AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI) + Map aaiJson = aaiRW.asMap() + environmentContext = aaiJson.getOrDefault("environment-context","") + workloadContext = aaiJson.getOrDefault("workload-context","") + + }catch (Exception ex) { + msoLogger.debug("Error retreiving parent service instance information") + } + + execution.setVariable("DCVFM_environmentContext",environmentContext) + execution.setVariable("DCVFM_workloadContext",workloadContext) + } + else { + + def requestInfo = getRequiredNodeXml(execution, xml, 'request-info') + execution.setVariable('DOUPVfMod_requestInfo', requestInfo) + execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) + def serviceInstanceId = execution.getVariable('mso-service-instance-id') + if (serviceInstanceId == null) { + serviceInstanceId = '' + } + execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId) + + def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs') + execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs) + execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) + execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) + execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name')) + execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type')) + execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name')) + execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version')) + execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name')) + execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id')) + execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id')) + execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region')) + execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) + //isBaseVfModule + def isBaseVfModule = "false" + if (utils.nodeExists(xml, "is-base-vf-module")) { + isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module") + execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) + } + msoLogger.debug("isBaseVfModule: " + isBaseVfModule) + + NetworkUtils networkUtils = new NetworkUtils() + def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml) + execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) + + def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id') + execution.setVariable('DOUPVfMod_volumeGroupId', vgi) + + execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false)) + } + + def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will + * set the orchestration-status to 'pending-update'. + * + * @param execution The flow's execution instance. + */ + public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + def orchestrationStatus = 'pending-update' + + String prepareUpdateAAIVfModuleRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(orchestrationStatus)} + + """ + prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest) + execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest) + msoLogger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest) + msoLogger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. + * Determine cloud region id for the volume group. + * + * @param execution The flow's execution instance. + */ + public void prepConfirmVolumeGroupTenant(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + + 'execution=' + execution.getId() + + ')' + + def prefix = execution.getVariable("prefix") + + msoLogger.trace('Entered ' + method) + + try { + String cloudRegion = execution.getVariable(prefix + "aicCloudRegion") + + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) + String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) + String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + msoLogger.debug("CloudRegion Request: " + queryCloudRegionRequest) + + execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + msoLogger.debug(prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) + + 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") + msoLogger.debug(errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + execution.setVariable(prefix + "isCloudRegionGood", false) + } + msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood")) + + } catch(BpmnError b){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + b); + throw b + }catch (Exception e) { + // try error + String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage()) + } + msoLogger.trace('Exited ' + method) + + } + + /** + * Prepare a Request for invoking the SDNC Adapter subflow to perform + * a VNF topology 'changeassign' operation. + * + * @param execution The flow's execution instance. + */ + public void prepSDNCTopologyChg(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + 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) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + def serviceId = execution.getVariable('DOUPVfMod_serviceId') + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vnfType = execution.getVariable('DOUPVfMod_vnfType') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') + def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule') + 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') + execution.setVariable('DOUPVfMod_vnfName', vnfName) + + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') + def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) + + String sdncTopologyRequest = """ + + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + changeassign + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + ChangeVNFActivateRequest + PORTAL + + + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(vnfId)} + dontcare + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${modelCustomizationUuidString} + ${MsoUtils.xmlEscape(usePreloadToSDNC)} + ${vnfNetworks} + + + + """ + sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) + execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest) + msoLogger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest) + msoLogger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the SDNC Adapter subflow to perform + * a VNF topology 'query' operation. + * + * @param execution The flow's execution instance. + */ + public void prepSDNCTopologyQuery(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + 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) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + + def svcInstId = "" + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + svcInstId = vfModuleId + } + else { + svcInstId = serviceInstanceId + } + + //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE + sleep(5000) + + String sdncTopologyRequest = """ + + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(svcInstId)} + query + /VNF-API:vnfs/vnf-list/${vfModuleId} + ${MsoUtils.xmlEscape(callbackUrl)} + mobility + + + """ + sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) + execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest) + msoLogger.debug("sdncTopologyRequest : " + sdncTopologyRequest) + msoLogger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the VnfAdapterRest subflow. + * + * @param execution The flow's execution instance. + */ + public void prepVnfAdapterRest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestId = execution.getVariable('DOUPVfMod_requestId') + def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName') + 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') + def vnfType = execution.getVariable('DOUPVfMod_vnfType') + def vnfName = execution.getVariable('DOUPVfMod_vnfName') + def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') + def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId") + def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId") + def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion') + def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid') + def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure") + + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String environmentContext = execution.getVariable("DOUPVEnvironment_context") + String workloadContext = execution.getVariable("DOUPVWorkload_context") + msoLogger.debug("workloadContext: " + workloadContext) + msoLogger.debug("environmentContext: " + environmentContext) + + Map vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap") + + String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') + + String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName, + vfModuleId, vfModuleName, null, environmentContext, workloadContext) + + + String vnfAdapterRestRequest = """ + + ${MsoUtils.xmlEscape(cloudId)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(heatStackId)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(asdcServiceModelVersion)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupStackId)} + ${MsoUtils.xmlEscape(baseVfModuleId)} + ${MsoUtils.xmlEscape(baseVfModuleStackId)} + true + ${MsoUtils.xmlEscape(backoutOnFailure)} + false + + ${vfModuleParams} + + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest) + msoLogger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest) + msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') + + def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id') + def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version') + if ((personaModelId == null) || (personaModelVersion == null)) { + msoLogger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent") + execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true) + } else { + def personaModelIdElement = '' + personaModelId + '' + def personaModelVersionElement = '' + personaModelVersion + '' + + String updateAAIGenericVnfRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${personaModelIdElement} + ${personaModelVersionElement} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the UpdateAAIVfModule subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + def orchestrationStatus = 'updated' + def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') + + def volumeGroupIdElement = '' + def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId') + if (volumeGroupId != null) { + volumeGroupIdElement = '' + volumeGroupId + '' + } + def personaModelIdElement = '' + def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id') + if (personaModelId != null) { + personaModelIdElement = '' + personaModelId + '' + } + def personaModelVersionElement = '' + def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version') + if (personaModelVersion != null) { + personaModelVersionElement = '' + personaModelVersion + '' + } + def contrailServiceInstanceFqdnElement = '' + def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn') + if (contrailServiceInstanceFqdn != null) { + contrailServiceInstanceFqdnElement = '' + contrailServiceInstanceFqdn + '' + } + def personaModelCustomizationIdElement = '' + def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid') + if (modelCustomizationId != null) { + personaModelCustomizationIdElement = '' + modelCustomizationId + '' + } + + String updateAAIVfModuleRequest = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(orchestrationStatus)} + ${volumeGroupIdElement} + ${personaModelIdElement} + ${personaModelVersionElement} + ${contrailServiceInstanceFqdnElement} + ${personaModelCustomizationIdElement} + + """ + + msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest) + updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) + execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest) + msoLogger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest) + msoLogger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the SDNC Adapter subflow to perform + * a VNF topology 'activate' operation. + * + * @param execution The flow's execution instance. + */ + public void prepSDNCTopologyAct(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + 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) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + def serviceId = execution.getVariable('DOUPVfMod_serviceId') + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vnfName = execution.getVariable('DOUPVfMod_vnfName') + def vnfType = execution.getVariable('DOUPVfMod_vnfType') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') + def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule') + 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 + "" + } + + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') + def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) + + String sdncTopologyRequest = """ + + + ${MsoUtils.xmlEscape(uuid)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + activate + vnf-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + ChangeVNFActivateRequest + PORTAL + + + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(vnfId)} + dontcare + + + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(vfModuleModelName)} + ${MsoUtils.xmlEscape(vfModuleName)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${modelCustomizationUuidString} + ${MsoUtils.xmlEscape(usePreloadToSDNC)} + + + + """ + sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) + execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest) + msoLogger.debug("sdncActivateRequest : " + sdncTopologyRequest) + msoLogger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage()) + } + } + + /** + * Log a WorkflowException that has been created. + * + * @param execution The flow's execution instance. + */ + public void handleWorkflowException(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.handleWorkflowException(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException') + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage()) + } + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + + def prefix = execution.getVariable("prefix") + + msoLogger.trace("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + msoLogger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + msoLogger.debug("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + msoLogger.trace("COMPLETED ValidateSDNCResponse Process") + } + + /** + * 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(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.getVfModule(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + msoLogger.debug("AAI endPoint: " + endPoint) + + try { + def aaiRequestId = UUID.randomUUID().toString() + msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + msoLogger.debug("createVfModule - invoking httpGet() to AAI") + + def responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received generic VNF data: " + responseData) + + } + + msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData) + msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData) + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + msoLogger.debug('Parsing the VNF data to find base module info') + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + def xmlVfModules= new XmlSlurper().parseText(vfModulesText) + def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} + int vfModulesSize = 0 + for (i in 0..vfModules.size()-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") + + if (isBaseVfModule == "true") { + String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id") + execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId) + msoLogger.debug('Received baseVfModuleId: ' + baseModuleId) + String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id") + execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId) + msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId) + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy new file mode 100644 index 0000000000..34a73bd35c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -0,0 +1,414 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.*; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ModuleResource +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +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 { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateVnfAndModules.class); + + String Prefix="DUVAM_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + msoLogger.trace("STARTED DoUpdateVnfAndModules PreProcessRequest Process") + + try{ + // Get Variables + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("requestId", requestId) + execution.setVariable("mso-request-id", requestId) + msoLogger.debug("Incoming Request Id is: " + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) + + String vnfId = execution.getVariable("vnfId") + msoLogger.debug("Incoming Vnf Id is: " + vnfId) + + String source = "VID" + execution.setVariable("DUVAM_source", source) + msoLogger.debug("Incoming Source is: " + source) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DUVAM_sdncVersion", sdncVersion) + msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion) + + 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) + msoLogger.debug("Incoming Service Id is: " + serviceId) + + String modelUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid") + execution.setVariable("DUVAM_modelUuid", modelUuid) + msoLogger.debug("Incoming modelUuid is: " + modelUuid) + + String modelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") + execution.setVariable("DUVAM_modelCustomizationUuid", modelCustomizationUuid) + msoLogger.debug("Incoming Model Customization Uuid is: " + modelCustomizationUuid) + + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DUVAM_cloudSiteId", cloudSiteId) + msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DUVAM_tenantId", tenantId) + msoLogger.debug("Incoming Tenant Id is: " + tenantId) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if (globalSubscriberId == null) { + globalSubscriberId = "" + } + execution.setVariable("DUVAM_globalSubscriberId", globalSubscriberId) + msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) + + execution.setVariable("DUVAM_moduleCount", 0) + execution.setVariable("DUVAM_nextModule", 0) + + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + msoLogger.debug(" Error Occured in DoUpdateVnfAndModules PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoUpdateVnfAndModules PreProcessRequest") + + } + msoLogger.trace("COMPLETED DoUpdateVnfAndModules PreProcessRequest Process ") + } + + /** + * 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(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.queryAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + msoLogger.debug('AAI URI is: ' + aai_uri) + + String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + msoLogger.debug("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'); + msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') + APIResponse response = client.httpGet() + msoLogger.debug("createVfModule - invoking httpGet() to AAI") + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + msoLogger.debug("Received generic VNF data: " + responseData) + + } + + msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData) + msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('DUVAM_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DUVAM_queryAAIVfModuleResponse', responseData) + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + //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 + msoLogger.debug('Parsing the VNF data to find base module info') + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + msoLogger.debug("vModulesText: " + vfModulesText) + 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.getNodeText(vfModuleXml, "vf-module-id") + vfModuleEntry.put("vfModuleId", vfModuleId) + def vfModuleName = utils.getNodeText(vfModuleXml, "vf-module-name") + vfModuleEntry.put("vfModuleName", vfModuleName) + def modelInvariantUuid = utils.getNodeText(vfModuleXml, "model-invariant-id") + vfModuleEntry.put("modelInvariantUuid", modelInvariantUuid) + def modelUuid = utils.getNodeText(vfModuleXml, "model-version-id") + vfModuleEntry.put("modelUuid", modelUuid) + def modelCustomizationUuid = utils.getNodeText(vfModuleXml, "model-customization-id") + vfModuleEntry.put("modelCustomizationUuid", modelCustomizationUuid) + + def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") + vfModuleEntry.put("isBaseVfModule", isBaseVfModule) + + String volumeGroupId = '' + + msoLogger.debug("Next module!") + def vfModuleRelationships = vfModules[i].'**'.findAll {it.name() == 'relationship-data'} + if (vfModuleRelationships.size() > 0) { + for (j in 0..vfModuleRelationships.size()-1) { + if (vfModuleRelationships[j] != null) { + + def relationshipKey = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-key'} + + if (relationshipKey[0] == 'volume-group.volume-group-id') { + def relationshipValue = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-value'} + volumeGroupId = relationshipValue[0] + break + } + } + } + } + + vfModuleEntry.put("volumeGroupId", volumeGroupId) + msoLogger.debug("volumeGroupId is: " + volumeGroupId) + + // 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 { + msoLogger.debug('Response code from AAI GET is: ' + response.getStatusCode()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Response code from AAI GET is: ' + response.getStatusCode()) + } + execution.setVariable("DUVAM_vfModules", vfModulesList) + } catch (Exception ex) { + ex.printStackTrace() + msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + public void prepareNextModuleToUpdate(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + msoLogger.trace("STARTED prepareNextModuleToUpdate ") + + 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") + msoLogger.debug("ModelInvariantUuid: " + modelInvariantUuid) + + def volumeGroupId = vfModule.get("volumeGroupId") + execution.setVariable("DUVAM_volumeGroupId", 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() + msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition) + + if (modelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + String vfModuleModelInfo = modelInfo.toJsonString() + String vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfo, "modelInfo") + execution.setVariable("DUVAM_vfModuleModelInfo", vfModuleModelInfoValue) + msoLogger.debug("vfModuleModelInfo: " + vfModuleModelInfoValue) + break + } + + } + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToUpdate Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED prepareNextModuleToUpdate ") + } + + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + 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 = """ + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + ${nfTypeString} + ${nfRoleString} + ${nfFunctionString} + ${nfNamingCodeString} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DUVAM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * APP-C Call - placeholder. + * + * @param execution The flow's execution instance. + */ + public void callAppCf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.callAppC(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HealchCheckActivate.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HealchCheckActivate.groovy new file mode 100644 index 0000000000..4deb53f0ce --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HealchCheckActivate.groovy @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.apache.commons.lang3.* +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + + + +public class HealthCheckActivate extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, HealthCheckActivate.class); + + + /** + * Validates the request message and sets up the workflow. + * @param execution the execution + */ + public void preProcessRequest(DelegateExecution execution) { + + } + + + /** + * Sends the synchronous response back to the API Handler. + * @param execution the execution + */ + public void sendResponse(DelegateExecution execution) { + def status = execution.getVariable("healthyStatus") + def healthcheckmessage = execution.getVariable("healthcheckmessage") + if (status == "true") { + sendWorkflowResponse(execution, 200, healthcheckmessage) + }else{ + sendWorkflowResponse(execution, 503, healthcheckmessage) + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy new file mode 100644 index 0000000000..8673ee7662 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -0,0 +1,611 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.Status +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.* +import org.onap.so.client.appc.ApplicationControllerOrchestrator +import org.onap.so.client.appc.ApplicationControllerSupport +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class ReplaceVnfInfra extends VnfCmBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ReplaceVnfInfra.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "RPLVnfI_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'RPLVnfI_') + execution.setVariable('Request', null) + execution.setVariable('requestInfo', null) + execution.setVariable('source', null) + execution.setVariable('vnfInputs', null) + execution.setVariable('tenantId', null) + execution.setVariable('vnfParams', null) + execution.setVariable('controllerType', null) + execution.setVariable('cloudConfiguration', null) + execution.setVariable('ReplaceVnfSuccessIndicator', false) + execution.setVariable('serviceType', null) + execution.setVariable('nfRole', null) + execution.setVariable('currentActivity', 'RPLVnfI') + execution.setVariable('workStep', null) + execution.setVariable('failedActivity', null) + execution.setVariable('errorCode', "0") + execution.setVariable('errorText', null) + execution.setVariable('healthCheckIndex', 1) + execution.setVariable('retainResources', true) + execution.setVariable('productFamilyId', null) + execution.setVariable('healthCheckIndex0', 0) + execution.setVariable('healthCheckIndex1', 1) + execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) + execution.setVariable("rollbackVnfStop", false) + execution.setVariable("rollbackVnfLock", false) + execution.setVariable("rollbackQuiesceTraffic", false) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) + execution.setVariable("platform", null) + execution.setVariable("lineOfBusiness", null) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + + msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + def incomingRequest = execution.getVariable('bpmnRequest') + + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + execution.setVariable('serviceInstanceId', serviceInstanceId) + execution.setVariable("isVidRequest", "true") + execution.setVariable('serviceType', 'Mobility') + execution.setVariable('retainResources', true) + execution.setVariable('disableRollback', true) + execution.setVariable('payload', "") + execution.setVariable('actionLock', Action.Lock) + execution.setVariable('actionUnlock', Action.Unlock) + execution.setVariable('actionHealthCheck', Action.HealthCheck) + execution.setVariable('actionStart', Action.Start) + execution.setVariable('actionStop', Action.Stop) + + def asdcServiceModelVersion = '' + def serviceModelInfo = null + + def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + msoLogger.debug("PROCESSING SERVICE INFO") + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + msoLogger.debug("ServiceModelInfo: " + serviceModelInfo) + def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid") + msoLogger.debug("modelInvariant: " + modelInvariant) + } + + } + } + + execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion) + execution.setVariable('serviceModelInfo', serviceModelInfo) + def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable('vnfModelInfo', vnfModelInfo) + def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid") + execution.setVariable('vnfModelInvariantUuid', vnfModelInvariantUuid) + msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid) + + def vnfType = execution.getVariable('vnfType') + execution.setVariable('vnfType', vnfType) + + + def controllerType = reqMap.requestDetails?.requestParameters?.controllerType + execution.setVariable('controllerType', controllerType) + + msoLogger.debug('Controller Type: ' + controllerType) + + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value.toString()) + } + } + + msoLogger.debug('Processed user params: ' + userParamsMap) + + execution.setVariable('vfModuleInputParams', userParamsMap) + + def requestId = execution.getVariable("requestId") + execution.setVariable('msoRequestId', requestId) + msoLogger.debug("requestId is: " + requestId) + + def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null + execution.setVariable('vnfName', vnfName) + + def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null + execution.setVariable('requestorId', requestorId) + + def usePreload = reqMap.requestDetails?.requestParameters?.usePreload + execution.setVariable('usePreload', usePreload) + + def productFamilyId = reqMap.requestDetails?.requestInfo?.productFamilyId ?: null + execution.setVariable('productFamilyId', productFamilyId) + + def cloudConfiguration = jsonOutput.toJson(reqMap.requestDetails?.cloudConfiguration) + execution.setVariable('cloudConfiguration', cloudConfiguration) + def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId") + execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId") + execution.setVariable('tenantId', tenantId) + + def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' + execution.setVariable('globalSubscriberId', globalSubscriberId) + + execution.setVariable('sdncVersion', '1702') + + execution.setVariable("ReplaceVnfInfraSuccessIndicator", false) + + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + REPLACE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("requestInfo", requestInfo) + + msoLogger.debug('RequestInfo: ' + execution.getVariable("requestInfo")) + + msoLogger.trace('Exited ' + method) + + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + + try { + def requestInfo = execution.getVariable('requestInfo') + def requestId = execution.getVariable('requestId') + def source = execution.getVariable('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) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + + /** + * Get VnfResource decomposition object for this VNF. + * + * + * @param execution The flow's execution instance. + */ + public void getVnfResourceDecomposition(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid') + msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid) + List vnfResources = serviceDecomposition.getVnfResources() + + for (i in 0..vnfResources.size()-1) { + ModelInfo modelInfo = vnfResources[i].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition) + + if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + VnfResource vnfResourceDecomposition = vnfResources[i] + execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition) + def nfRole = vnfResourceDecomposition.getNfRole() + execution.setVariable('nfRole', nfRole) + msoLogger.debug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString()) + break + } + else { + //exception! + } + + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, '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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkIfVnfInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + 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) + msoLogger.debug("isInMaint result: " + isInMaint) + execution.setVariable('isVnfInMaintenance', isInMaint) + + if (isInMaint) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "VNF is in maintenance in A&AI") + } + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("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) + msoLogger.debug("areLocked result: " + areLocked) + execution.setVariable('arePserversLocked', areLocked) + + if (areLocked) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "pServers are locked in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + if (inMaint) { + execution.setVariable("workStep", "setVnfInMaintFlagInAAI") + } + else { + execution.setVariable("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) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution, Action action) { + def method = getClass().getSimpleName() + '.runAppcCommand(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + + try { + msoLogger.debug("Running APP-C action: " + action.toString()) + String vnfId = execution.getVariable('vnfId') + String msoRequestId = execution.getVariable('requestId') + execution.setVariable('msoRequestId', msoRequestId) + execution.setVariable("failedActivity", "APP-C") + execution.setVariable("workStep", action.toString() + "VNF") + + ApplicationControllerOrchestrator appcClient = new ApplicationControllerOrchestrator() + Status appcStatus = null + switch(action) { + case Action.Lock: + execution.setVariable('workStep', "LockVNF") + appcStatus = appcClient.runCommand(Action.Lock,msoRequestId,vnfId,null) + break + case Action.Unlock: + execution.setVariable('workStep', "UnlockVNF") + appcStatus = appcClient.runCommand(Action.Unlock,msoRequestId,vnfId,null) + break + case Action.HealthCheck: + def healthCheckIndex = execution.getVariable('healthCheckIndex') + execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex) + execution.setVariable('healthCheckIndex', healthCheckIndex + 1) + appcStatus = appcClient.runCommand(Action.HealthCheck,msoRequestId,vnfId,null) + break + case Action.Start: + execution.setVariable('workStep', "StartVNF") + appcStatus = appcClient.runCommand(Action.Start,msoRequestId,vnfId,null) + break + case Action.Stop: + execution.setVariable('workStep', "StopVNF") + appcStatus = appcClient.runCommand(Action.Stop,msoRequestId,vnfId,null) + break + default: + break + } + msoLogger.debug("Completed AppC request") + int appcCode = appcStatus.getCode() + msoLogger.debug("AppC status code is: " + appcCode) + msoLogger.debug("AppC status message is: " + appcStatus.getMessage()) + if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { + execution.setVariable("errorCode", Integer.toString(appcCode)) + execution.setVariable("errorText", appcStatus.getMessage()) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } catch (java.lang.NoSuchMethodError e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } + } + + + + /** + * Prepare DoDeleteVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoDeleteVnfAndModules(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoDeleteVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("workStep", "doDeleteVnfAndModules") + execution.setVariable("failedActivity", "MSO Delete VNF") + msoLogger.trace('Exited ' + method) + + } + + /** + * Prepare DoCreateVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoCreateVnfAndModules(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoReplaceVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("workStep", "doCreateVnfAndModules") + execution.setVariable("failedActivity", "MSO Create VNF") + msoLogger.trace('Exited ' + method) + + } + + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def errorText = execution.getVariable("errorText") + def errorCode = execution.getVariable("errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + /** + * Handle Manual disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void manualProcessing(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.manualProcessing(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def taskId = execution.getVariable("taskId") + + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Processing halted - manual task created: " + taskId) + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy new file mode 100644 index 0000000000..d729c770ca --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.onap.so.bpmn.common.scripts.ExceptionUtil +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.VidUtils; +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.client.aai.* + +import org.onap.so.client.appc.ApplicationControllerClient; +import org.onap.so.client.appc.ApplicationControllerSupport; +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.appc.client.lcm.model.Action; + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +public class RollbackVnf extends VnfCmBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, RollbackVnf.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "VnfIPU_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'RVnf_') + + execution.setVariable('rollbackSuccessful', false) + execution.setVariable('currentActivity', 'RVnf') + execution.setVariable('workStep', null) + execution.setVariable('failedActivity', null) + execution.setVariable('errorCode', "0") + execution.setVariable('actionUnlock', Action.Unlock) + execution.setVariable('actionStart', Action.Start) + execution.setVariable('actionResumeTraffic', Action.ResumeTraffic) + + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + + msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + try { + + execution.setVariable("rollbackErrorCode", "0") + + if (execution.getVariable("rollbackSetClosedLoopDisabledFlag") == true) { + msoLogger.debug("Will call setClosedLoopDisabledFlag") + } + + + msoLogger.trace('Exited ' + method) + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("rollbackErrorCode", "1") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Determine success of rollback execution. + * + * @param execution The flow's execution instance. + */ + public void setRollbackResult(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.setRollbackResult(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + + msoLogger.trace('Entered ' + method) + + def rollbackErrorCode = execution.getVariable('rollbackErrorCode') + if (rollbackErrorCode == "0") { + execution.setVariable('rollbackSuccessful', true) + msoLogger.debug("rollback successful") + } + else { + execution.setVariable('rollbackSuccessful', false) + msoLogger.debug("rollback unsuccessful") + } + + msoLogger.trace('Exited ' + method) + + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy new file mode 100644 index 0000000000..3a309cf5a2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy @@ -0,0 +1,296 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import static org.apache.commons.lang3.StringUtils.* + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.utils.UUIDChecker +import org.springframework.web.util.UriUtils + + +/** + * This groovy class supports the ScaleCustomE2EServiceInstance.bpmn process. + * + */ +public class ScaleCustomE2EServiceInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ScaleCustomE2EServiceInstance.class); + + String Prefix = "CRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest(DelegateExecution execution) { + execution.setVariable("prefix", Prefix) + String msg = "" + msoLogger.trace("preProcessRequest() ") + + try { + + String siRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(siRequest) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + msoLogger.debug("Input Request:" + siRequest + " reqId:" + requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + serviceInstanceId = "NULL".toString() + } + msoLogger.debug("Generated new Service Instance:" + serviceInstanceId) + serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + // service instance ID is also service ID + execution.setVariable("serviceId", serviceInstanceId) + // service instance name + String serviceInstanceName = jsonUtil.getJsonValue(siRequest, "service.serviceInstanceName") + execution.setVariable("serviceInstanceName", serviceInstanceName) + + // service instance name + String serviceType = jsonUtil.getJsonValue(siRequest, "service.serviceType") + execution.setVariable("serviceType", serviceType) + + // operationa ID (key) + //String operationKey = UUIDChecker.generateUUID(msoLogger) + String operationId = jsonUtil.getJsonValue(siRequest, "operationId") + execution.setVariable("operationId", operationId) + msoLogger.debug("Input Request:" + siRequest + " operationId:" + operationId) + + + String resources = jsonUtil.getJsonValue(siRequest, "service.resources") + execution.setVariable("resources", resources) + + // node template UUID + String nodeTemplateUUID = UUIDChecker.generateUUID(msoLogger) + execution.setVariable("nodeTemplateUUID", nodeTemplateUUID) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "service.globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + String requestDescription = "request description for test" + execution.setVariable("requestDescription", requestDescription) + execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit preProcessRequest ") + } + + public void sendSyncResponse(DelegateExecution execution) { + msoLogger.trace("sendSyncResponse ") + + try { + String operationId = execution.getVariable("operationId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + // RESTResponse for API Handler (APIH) Reply Task + String scaleServiceRestRequest = """{"operationId":"${operationId}"}""".trim() + msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + scaleServiceRestRequest) + sendWorkflowResponse(execution, 202, scaleServiceRestRequest) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit sendSyncResopnse ") + } + + + public void sendSyncError(DelegateExecution execution) { + msoLogger.trace("sendSyncError ") + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + msoLogger.debug(" Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + + } + + public void prepareCompletionRequest(DelegateExecution execution) { + msoLogger.trace("prepareCompletion ") + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + SCALE + ${MsoUtils.xmlEscape(source)} + + Service Instance was scaled successfully. + ${MsoUtils.xmlEscape(serviceInstanceId)} + ScaleGenericALaCarteServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("CompleteMsoProcessRequest", xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit prepareCompletionRequest ") + } + + public void prepareFalloutRequest(DelegateExecution execution) { + msoLogger.trace("prepareFalloutRequest ") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug(" Input Workflow Exception: " + wfex.toString()) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + SCALE + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.debug("Exception prepareFalloutRequest:" + ex.getMessage()) + String errorException = " Bpmn error encountered in ScaleGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + SCALE + UUI + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + msoLogger.trace("Exit prepareFalloutRequest ") + } + + + /** + * Init the service Operation Status + */ + public void prepareInitServiceOperationStatus(DelegateExecution execution){ + msoLogger.trace("STARTED prepareInitServiceOperationStatus Process ") + try{ + String serviceId = execution.getVariable("serviceInstanceId") + //String serviceName = execution.getVariable("serviceInstanceName") + String operationId = execution.getVariable("operationId") + String operationType = "SCALE" + String userId = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service scaling" + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(serviceName)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(userId)} + ${MsoUtils.xmlEscape(result)} + ${MsoUtils.xmlEscape(operationContent)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(reason)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + msoLogger.info("Outgoing updateServiceOperStatusRequest: \n" + payload) + msoLogger.debug("Scale network service updateServiceOperStatusRequest Request: " + payload) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + } + msoLogger.trace("COMPLETED prepareInitServiceOperationStatus Process ") + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy new file mode 100644 index 0000000000..538f882c2b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy @@ -0,0 +1,570 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.Resource +import org.onap.so.bpmn.core.json.JsonUtils +import org.springframework.web.util.UriUtils + +import groovy.json.* + +/** + * This groovy class supports the UpdateCustomE2EServiceInstance.bpmn process. + * AlaCarte flow for 1702 ServiceInstance Update + * + */ +public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor { + String Prefix="UPDSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + utils.log("INFO", " *** preProcessRequest() *** ", isDebugEnabled) + + try { + + String siRequest = execution.getVariable("bpmnRequest") + utils.logAudit(siRequest) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + utils.log("INFO", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + msg = "Input serviceInstanceId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + //subscriberInfo for aai + String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestDetails + execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source")) + execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName")) + execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback")) + String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") + if (isBlank(productFamilyId)) + { + msg = "Input productFamilyId is null" + utils.log("INFO", msg, isDebugEnabled) + } else { + execution.setVariable("productFamilyId", productFamilyId) + } + + //user params + String userParams = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams") + utils.log("INFO", "userParams:" + userParams, isDebugEnabled) + List paramList = jsonUtil.StringArrayToList(execution, userParams) + String uuiRequest = jsonUtil.getJsonValue(paramList.get(0), "UUIRequest") + if (isBlank(uuiRequest)) { + msg = "Input uuiRequest is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("uuiRequest", uuiRequest) + } + + utils.log("INFO", "uuiRequest:\n" + uuiRequest, isDebugEnabled) + + //serviceType for aai + String serviceType = jsonUtil.getJsonValue(uuiRequest, "service.serviceType") + if (isBlank(serviceType)) { + msg = "Input serviceType is null" + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("serviceType", serviceType) + } + + // target model info + String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") + utils.log("INFO","modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled) + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + execution.setVariable("model-invariant-id-target", modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") + utils.log("INFO","modelUuid: " + modelUuid, isDebugEnabled) + execution.setVariable("modelUuid", modelUuid) + execution.setVariable("model-version-id-target", modelUuid) + + String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName") + utils.log("INFO","serviceModelName: " + serviceModelName, isDebugEnabled) + if(serviceModelName == null) { + serviceModelName = "" + } + execution.setVariable("serviceModelName", serviceModelName) + + //operationId + String operationId = jsonUtil.getJsonValue(siRequest, "operationId") + if (isBlank(operationId)) { + operationId = UUID.randomUUID().toString() + } + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", "update") + execution.setVariable("hasResourcetoUpdate", false) + + execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + + public void postProcessAAIGET(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) + String msg = "" + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + String serviceType = "" + + if(foundInAAI){ + utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) + + String siData = execution.getVariable("GENGS_service") + utils.log("INFO", "SI Data", isDebugEnabled) + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI, Id:" + serviceInstanceId + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + utils.log("INFO", "SI Data" + siData, isDebugEnabled) + + // serviceInstanceName + String serviceInstanceName = execution.getVariable("serviceInstanceName") + if(isBlank(serviceInstanceName) && utils.nodeExists(siData, "service-instance-name")) { + serviceInstanceName = utils.getNodeText(siData, "service-instance-name") + execution.setVariable("serviceInstanceName", serviceInstanceName) + } + + // Get Template uuid and version + if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { + utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled) + + def modelInvariantId = utils.getNodeText(siData, "model-invariant-id") + def modelVersionId = utils.getNodeText(siData, "model-version-id") + + // Set Original Template info + execution.setVariable("model-invariant-id-original", modelInvariantId) + execution.setVariable("model-version-id-original", modelVersionId) + } + + //get related service instances (vnf/network or volume) for delete + if (utils.nodeExists(siData, "relationship-list")) { + utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled) + + JSONArray jArray = new JSONArray() + + XmlParser xmlParser = new XmlParser() + Node root = xmlParser.parseText(siData) + def relation_list = utils.getChildNode(root, 'relationship-list') + def relationships = utils.getIdenticalChildren(relation_list, 'relationship') + + for (def relation: relationships) { + def jObj = getRelationShipData(relation, isDebugEnabled) + jArray.put(jObj) + } + + execution.setVariable("serviceRelationShip", jArray.toString()) + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(!succInAAI){ + utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + + utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) + } + }catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) + } + + private JSONObject getRelationShipData(node, isDebugEnabled){ + JSONObject jObj = new JSONObject() + + def relation = utils.nodeToString(node) + def rt = utils.getNodeText(relation, "related-to") + + def rl = utils.getNodeText(relation, "related-link") + utils.log("INFO", "ServiceInstance Related NS/Configuration :" + rl, isDebugEnabled) + + def rl_datas = utils.getIdenticalChildren(node, "relationship-data") + for(def rl_data : rl_datas) { + def eKey = utils.getChildNodeText(rl_data, "relationship-key") + def eValue = utils.getChildNodeText(rl_data, "relationship-value") + + if ((rt == "service-instance" && eKey.equals("service-instance.service-instance-id")) + //for overlay/underlay + || (rt == "configuration" && eKey.equals("configuration.configuration-id"))){ + jObj.put("resourceInstanceId", eValue) + } + } + + def rl_props = utils.getIdenticalChildren(node, "related-to-property") + for(def rl_prop : rl_props) { + def eKey = utils.getChildNodeText(rl_prop, "property-key") + def eValue = utils.getChildNodeText(rl_prop, "property-value") + if((rt == "service-instance" && eKey.equals("service-instance.service-instance-name")) + //for overlay/underlay + || (rt == "configuration" && eKey.equals("configuration.configuration-type"))){ + jObj.put("resourceType", eValue) + } + } + + utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) + + return jObj + } + + + public void preCompareModelVersions(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + } + + public void postCompareModelVersions(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ======== STARTED postCompareModelVersions Process ======== ", isDebugEnabled) + + def hasResourcetoUpdate = false + def hasResourcetoAdd = false + def hasResourcetoDelete = false + List addResourceList = execution.getVariable("addResourceList") + List delResourceList = execution.getVariable("delResourceList") + + if(addResourceList != null && !addResourceList.isEmpty()) { + hasResourcetoAdd = true + } + + if(delResourceList != null && !delResourceList.isEmpty()) { + hasResourcetoDelete = true + } + + hasResourcetoUpdate = hasResourcetoAdd || hasResourcetoDelete + execution.setVariable("hasResourcetoUpdate", hasResourcetoUpdate) + + utils.log("DEBUG", "======== COMPLETED postCompareModelVersions Process ======== ", isDebugEnabled) + } + + /** + * Init the service Operation Status + */ + public void prepareInitServiceOperationStatus(DelegateExecution execution){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String userId = "" + String result = "processing" + String progress = "0" + String reason = "" + String operationContent = "Prepare service updating" + utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(userId)} + ${MsoUtils.xmlEscape(result)} + ${MsoUtils.xmlEscape(operationContent)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(reason)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled) + utils.logAudit("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) + } + utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) + } + + /** + * Update the service Operation Status + */ + public void preUpdateServiceOperationStatus(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')' + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO","Entered " + method, isDebugEnabled) + + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = execution.getVariable("operationId") + String operationType = execution.getVariable("operationType") + String serviceName = execution.getVariable("serviceInstanceName") + String result = execution.getVariable("operationResult") + String progress = execution.getVariable("progress") + String reason = execution.getVariable("operationReason") + String userId = "" + utils.log("INFO", "progress: " + progress , isDebugEnabled) + + String operationContent = "Prepare service : " + execution.getVariable("operationStatus") + + utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) + + execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + String payload = + """ + + + + ${MsoUtils.xmlEscape(serviceId)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(operationType)} + ${MsoUtils.xmlEscape(userId)} + ${MsoUtils.xmlEscape(result)} + ${MsoUtils.xmlEscape(operationContent)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(reason)} + + + """ + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled) + + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage()) + } + utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled) + utils.log("INFO", "Exited " + method, isDebugEnabled) + } + + public void sendSyncResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", " *** sendSyncResponse *** ", isDebugEnabled) + + try { + String operationId = execution.getVariable("operationId") + def hasResourcetoUpdate = execution.getVariable("hasResourcetoUpdate") + + String updateServiceResp = "" + if(hasResourcetoUpdate) { + // RESTResponse for API Handler (APIH) Reply Task + updateServiceResp = """{"operationId":"${operationId}"}""".trim() + } + else { + updateServiceResp = """{"OperationResult":"No Resource to Add or Delete or Service Instance not found in AAI."}""" + } + + utils.log("INFO", " sendSyncResponse to APIH:" + "\n" + updateServiceResp, isDebugEnabled) + sendWorkflowResponse(execution, 202, updateServiceResp) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO"," ***** Exit sendSyncResopnse *****", isDebugEnabled) + } + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", " *** sendSyncError *** ", isDebugEnabled) + + try { + String errorMessage = "" + int errorCode = 7000 + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + errorCode = wfe.getErrorCode() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + """ + + utils.logAudit(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + utils.log("INFO", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) + } + + } + + public void prepareCompletionRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", " *** prepareCompletion *** ", isDebugEnabled) + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + + Service Instance was updated successfully. + ${MsoUtils.xmlEscape(serviceInstanceId)} + UpdateCustomE2EServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + utils.log("INFO", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + utils.log("INFO", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("INFO", "*** Exit prepareCompletionRequest ***", isDebugEnabled) + } + + public void prepareFalloutRequest(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO", " *** prepareFalloutRequest *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("INFO", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + utils.log("INFO", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) + String errorException = " Bpmn error encountered in UpdateCustomE2EServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + UUI + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + utils.log("INFO", "*** Exit prepareFalloutRequest ***", isDebugEnabled) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy new file mode 100644 index 0000000000..329d58aa58 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy @@ -0,0 +1,403 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts; + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MsoLogger + +import groovy.json.* + +/** + * This groovy class supports the UpdateNetworkInstance.bpmn process. + * + */ +public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateNetworkInstance.class); + + String Prefix="UPDNI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public InitializeProcessVariables(DelegateExecution execution){ + + execution.setVariable(Prefix + "source", "") + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "CompleteMsoProcessRequest", "") + execution.setVariable(Prefix + "FalloutHandlerRequest", "") + + } + + + /** + * This method is executed during the preProcessRequest task of the UpdateNetworkInstance.bpmn process. + * @param execution + */ + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the UpdateNetworkInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest() of UpdateNetworkInstance Request") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null || sdncVersion == "1610") { + // 'a-la-cart' default, sdncVersion = '1610' + execution.setVariable("sdncVersion", "1610") + String bpmnRequest = execution.getVariable("bpmnRequest") + if (bpmnRequest != null) { + String disableRollback = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.requestInfo.suppressRollback") + if (disableRollback != null) { + execution.setVariable("disableRollback", disableRollback) + msoLogger.debug("Received 'suppressRollback': " + disableRollback ) + } else { + execution.setVariable("disableRollback", false) + } + msoLogger.debug(" Set 'disableRollback' : " + execution.getVariable("disableRollback") ) + } else { + String dataErrorMessage = " Invalid 'bpmnRequest' request." + msoLogger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } else { + // 'macro' TEST ONLY, sdncVersion = '1702' + msoLogger.debug(" \'disableRollback\' : " + execution.getVariable("disableRollback") ) + } + + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + + // get/set 'requestId' + if (execution.getVariable("requestId") == null) { + execution.setVariable("requestId", requestId) + } + + //Place holder for additional code. + + // TODO ??? + // userParams??? 1) pre-loads indicator, 2) 'auto-activation' + // Tag/Value parameters + // + // Map: 'networkInputParams': 'auto-activation'' + // Sample format? + // "requestParameters": { + // "userParams": [ + // { + // "name": "someUserParam1", + // "value": "someValue1" + // } + // ] + // } + // + // String userParams = //use json util to extract "userParams"// + // execution.setVariable("networkInputParams", userParams) + // else: execution.setVariable("networkInputParams", null) + // + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in UpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + } + + public void sendSyncResponse (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside sendSyncResponse() of UpdateNetworkInstance") + + try { + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // RESTResponse (for API Handler (APIH) Reply Task) + String updateNetworkRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + + msoLogger.debug(" sendSyncResponse to APIH - " + "\n" + updateNetworkRestRequest) + sendWorkflowResponse(execution, 202, updateNetworkRestRequest) + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstance flow. sendSyncResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + public void getNetworkModelInfo (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside getNetworkModelInfo() of UpdateNetworkInstance") + + try { + + // 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() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void sendSyncError (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside sendSyncError() of UpdateNetworkInstance") + + try { + + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // REST Error (for API Handler (APIH) Reply Task) + String syncError = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + + sendWorkflowResponse(execution, 500, syncError) + + } catch (Exception ex) { + msoLogger.debug(" Bpmn error encountered in UpdateNetworkInstance flow. sendSyncError() - " + ex.getMessage()) + } + + } + + public void prepareCompletion (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside prepareCompletion() of UpdateNetworkInstance") + + try { + + String requestId = execution.getVariable("mso-request-id") + String source = execution.getVariable(Prefix + "source") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + VID + + Network has been updated successfully. + BPMN Network action: UPDATE + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + // normal path + execution.setVariable(Prefix + "Success", true) + execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + msoLogger.debug(" Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + + + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void postProcessResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside postProcessResponse() of UpdateNetworkInstance") + + try { + + if (execution.getVariable("CMSO_ResponseCode") == "200") { + execution.setVariable(Prefix + "Success", true) + msoLogger.trace("UpdateNetworkInstance Success ") + // Place holder for additional code. + + } else { + execution.setVariable(Prefix + "Success", false) + msoLogger.trace("UpdateNetworkInstance Failed in CompletionMsoProces flow!. ") + + } + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + public void processRollbackData (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside processRollbackData() of UpdateNetworkInstance") + + try { + //execution.getVariable("orchestrationStatus") + //execution.getVariable("networkId") + //execution.getVariable("networkName") + //networkOutputParams + //rollbackData + //rolledBack + + } catch (Exception ex) { + msoLogger.debug(" Bpmn error encountered in UpdateNetworkInstance flow. callDBCatalog() - " + ex.getMessage()) + } + + } + + // Prepare for FalloutHandler + public void buildErrorResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. ") + + 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() + falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + VID + + + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + + """ + + msoLogger.debug(falloutHandlerRequest) + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + msoLogger.debug(" Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest) + + } catch (Exception ex) { + String errorException = " Bpmn error encountered in UpdateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + msoLogger.debug("Exception error in UpdateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage()) + falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + VID + + + ${MsoUtils.xmlEscape(errorException)} + 7000 + + """ + + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + msoLogger.debug(" Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest) + + } + + } + + public void processJavaException(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a Java Exception in " + Prefix) + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + msoLogger.debug("Completed processJavaException Method in " + Prefix) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy new file mode 100644 index 0000000000..b1aaf5ea5f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy @@ -0,0 +1,326 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + + +public class UpdateVfModule extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModule.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'UPDVfMod_') + execution.setVariable('UPDVfMod_Request', null) + execution.setVariable('UPDVfMod_requestInfo', null) + execution.setVariable('UPDVfMod_requestId', null) + execution.setVariable('UPDVfMod_source', null) + execution.setVariable('UPDVfMod_vnfInputs', null) + execution.setVariable('UPDVfMod_vnfId', null) + execution.setVariable('UPDVfMod_vfModuleId', null) + execution.setVariable('UPDVfMod_tenantId', null) + execution.setVariable('UPDVfMod_volumeGroupId', null) + execution.setVariable('UPDVfMod_vnfParams', null) + execution.setVariable('UPDVfMod_updateInfraRequest', null) + execution.setVariable('UpdateVfModuleSuccessIndicator', false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + initProcessVariables(execution) + String request = validateRequest(execution) + + msoLogger.debug("UpdateVfModule request: " + request) + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') + execution.setVariable('UPDVfMod_requestInfo', requestInfo) + execution.setVariable('UPDVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) + execution.setVariable('UPDVfMod_source', getNodeTextForce(requestInfo, 'source')) + + def vnfInputs = getRequiredNodeXml(execution, request, 'vnf-inputs') + execution.setVariable('UPDVfMod_vnfInputs', vnfInputs) + execution.setVariable('UPDVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) + execution.setVariable('UPDVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) + execution.setVariable('UPDVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) + execution.setVariable('UPDVfMod_volumeGroupId', getNodeTextForce(vnfInputs, 'volume-group-id')) + + def vnfParams = utils.getNodeXml(request, 'vnf-params') + execution.setVariable('UPDVfMod_vnfParams', vnfParams) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Prepare and send the synchronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = execution.getVariable('UPDVfMod_requestInfo') + def requestId = execution.getVariable('UPDVfMod_requestId') + def source = execution.getVariable('UPDVfMod_source') + def progress = getNodeTextForce(requestInfo, 'progress') + if (progress.isEmpty()) { + progress = '0' + } + def startTime = getNodeTextForce(requestInfo, 'start-time') + if (startTime.isEmpty()) { + startTime = System.currentTimeMillis() + } + def vnfInputs = execution.getVariable('UPDVfMod_vnfInputs') + + String synchResponse = """ + + + ${MsoUtils.xmlEscape(requestId)} + UPDATE_VF_MODULE + IN_PROGRESS + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(startTime)} + ${MsoUtils.xmlEscape(source)} + + ${vnfInputs} + + """ + + synchResponse = utils.formatXml(synchResponse) + sendWorkflowResponse(execution, 200, synchResponse) + + msoLogger.debug("UpdateVfModule Synch Response: " + synchResponse) + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendSynchResponse(): ' + e.getMessage()) + } + } + + /** + * Prepare the Request for invoking the DoUpdateVfModule subflow. + * + * NOTE: Currently, the method just logs passing through as the + * incoming Request to this main flow is used as the Request to + * the DoUpdateVfModule subflow. No preparation processing is + * necessary. + * + * @param execution The flow's execution instance. + */ + public void prepDoUpdateVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) + } + } + + /** + * Prepare the Request for updating the DB for this Infra Request. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateInfraRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateInfraRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestId = execution.getVariable('UPDVfMod_requestId') + def vnfId = execution.getVariable('UPDVfMod_vnfId') + def vfModuleId = execution.getVariable('UPDVfMod_vfModuleId') + def tenantId = execution.getVariable('UPDVfMod_tenantId') + def volumeGroupId = execution.getVariable('UPDVfMod_volumeGroupId') + + String updateInfraRequest = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPEL + COMPLETE + 100 + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(volumeGroupId)} + + + + + """ + + updateInfraRequest = utils.formatXml(updateInfraRequest) + execution.setVariable('UPDVfMod_updateInfraRequest', updateInfraRequest) + msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) + + msoLogger.debug("UpdateVfModule Infra Request: " + updateInfraRequest) + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateInfraRequest(): ' + 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = getVariable(execution, 'UPDVfMod_requestInfo') + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.debug("UpdateVfModule CompletionHandler Request: " + content) + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def prefix = execution.getVariable('prefix') + def request = getVariable(execution, prefix+'Request') + def requestInformation = utils.getNodeXml(request, 'request-information', false) + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInformation} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.debug("UpdateVfModule fallOutHandler Request: " + content) + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy new file mode 100644 index 0000000000..416d0d6e60 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy @@ -0,0 +1,504 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class UpdateVfModuleInfra extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleInfra.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution 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_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(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + def prefix = "UPDVfModI_" + + def incomingRequest = execution.getVariable('bpmnRequest') + + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + 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 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.toString()) + } + } + + msoLogger.debug('Processed user params: ' + userParamsMap) + + 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) + + + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable(prefix + "source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable(prefix + "requestInfo", requestInfo) + + //backoutOnFailure + + msoLogger.debug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo")) + + msoLogger.trace('Exited ' + method) + + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + + 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) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + /** + * Prepare the Request for invoking the DoUpdateVfModule subflow. + * + * NOTE: Currently, the method just logs passing through as the + * incoming Request to this main flow is used as the Request to + * the DoUpdateVfModule subflow. No preparation processing is + * necessary. + * + * @param execution The flow's execution instance. + */ + public void prepDoUpdateVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) + } + } + + /** + * Prepare the Request for updating the DB for this Infra Request. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateInfraRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateInfraRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestId = execution.getVariable('UPDVfModI_requestId') + def vnfId = execution.getVariable('UPDVfModI_vnfId') + def vfModuleId = execution.getVariable('UPDVfModI_vfModuleId') + def tenantId = execution.getVariable('UPDVfModI_tenantId') + def volumeGroupId = execution.getVariable('UPDVfModI_volumeGroupId') + + String updateInfraRequest = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPEL + COMPLETE + 100 + + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vfModuleId)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(volumeGroupId)} + + + + + """ + + updateInfraRequest = utils.formatXml(updateInfraRequest) + execution.setVariable('UPDVfModI_updateInfraRequest', updateInfraRequest) + msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateInfraRequest(): ' + 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = getVariable(execution, 'UPDVfModI_requestInfo') + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def prefix = execution.getVariable('prefix') + def request = getVariable(execution, prefix+'Request') + def requestInformation = execution.getVariable(prefix + "requestInfo") + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInformation} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Validates the request, request id and service instance id. If a problem is found, + * a WorkflowException is generated and an MSOWorkflowException event is thrown. This + * method also sets up the log context for the workflow. + * @param execution the execution + * @return the validated request + */ + public String validateInfraRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateInfraRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + String processKey = getProcessKey(execution); + def prefix = execution.getVariable("prefix") + + if (prefix == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null") + } + + try { + def request = execution.getVariable(prefix + 'Request') + + if (request == null) { + request = execution.getVariable(processKey + 'Request') + + if (request == null) { + request = execution.getVariable('bpmnRequest') + } + + setVariable(execution, processKey + 'Request', null); + setVariable(execution, 'bpmnRequest', null); + setVariable(execution, prefix + 'Request', request); + } + + if (request == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null") + } + + /* + + def requestId = execution.getVariable("mso-request-id") + + if (requestId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") + } + + setVariable(execution, prefix + 'requestId', requestId) + + def serviceInstanceId = execution.getVariable("mso-service-instance-id") + + if (serviceInstanceId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") + } + + utils.logContext(requestId, serviceInstanceId) + */ + msoLogger.debug('Incoming message: ' + System.lineSeparator() + request) + msoLogger.trace('Exited ' + method) + return request + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy new file mode 100644 index 0000000000..a926030924 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy @@ -0,0 +1,468 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIValidatorImpl +import org.onap.so.client.appc.ApplicationControllerClient +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class UpdateVfModuleInfraV2 { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleInfraV2.class); + + 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(DelegateExecution 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(DelegateExecution execution) { + System.out.print("*****************************PreProcessRequest**************************") + + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + //msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + def prefix = "UPDVfModI_" + + def incomingRequest = execution.getVariable('bpmnRequest') + + //msoLogger.debug("Incoming Infra Request: " + incomingRequest) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + //msoLogger.debug(" Request is in JSON format.") + + 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.toString()) + } + } + + //msoLogger.debug('Processed user params: ' + userParamsMap) + + 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) + + + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable(prefix + "source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable(prefix + "requestInfo", requestInfo) + + //backoutOnFailure + + //msoLogger.debug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo")) + + //msoLogger.trace('Exited ' + method) + + } + catch(groovy.json.JsonException je) { + //msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + //msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the synchronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + System.out.print("*****************************SendSynchResponse**************************") + + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + //msoLogger.trace('Entered ' + method) + + + 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) + //msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + //msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + //check to see if the Pserver Flag is locked + public void checkPserverFlag(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution execution) { + + System.out.print("*****************************lockAppC*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("Lock",vfModuleId) + + + } + //run health check + public void healthCheckAppC(DelegateExecution execution) { + + System.out.print("*****************************healthCheckAppC*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("HealthCheck",vfModuleId) + + } + //SDNO health diagnostic + public void healthDiagnosticSDNO(DelegateExecution execution) { + + System.out.print("*****************************healthDiagnosticSDNO is currently ignored*************************") + //SDNOValidatorImpl.healthDiagnostic("",""); + + } + //stop VF module controller + public void stopVfModuleController(DelegateExecution execution) { + + System.out.print("*****************************stopVfModuleController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("Stop",vfModuleId) + + + } + + public void doUpdateVfModulePrep(DelegateExecution execution) { + + System.out.print("*****************************doUpdateVfModulePrep*************************") + def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' + + 'execution=' + execution.getId() + + ')' + + //msoLogger.trace('Entered ' + method) + + try { + + //msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + //msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) + + } + + } + + public void completionHandlerPrep(DelegateExecution execution,String resultVar) { + + System.out.print("*****************************completionHandlerPrep*************************") + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + //msoLogger.trace('Entered ' + method) + + try { + def requestInfo = getVariable(execution, 'UPDVfModI_requestInfo') + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + //msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + //msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + //msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + + } + + } + + public void healthCheckController(DelegateExecution execution) { + + System.out.print("*****************************healthCheckController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("HealthCheck",vfModuleId) + + } + + public void startVfModuleController(DelegateExecution execution) { + + System.out.print("*****************************startVfModuleController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("Start",vfModuleId) + + } + + public void vFFlagUnset(DelegateExecution 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(DelegateExecution execution) { + + System.out.print("*****************************unlockAppC*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("Unlock",vfModuleId) + + } + + public void postUpgradeHealthCheckController(DelegateExecution execution) { + + System.out.print("*****************************postUpgradeHealthCheckController*************************") + def vfModuleId = "" + ApplicationControllerClient aCC = new ApplicationControllerClient(getLCMProperties()) + def status = aCC.runCommand("HealthCheck",vfModuleId) + + } + + Properties getLCMProperties() { + Properties properties = new Properties() + + properties.put("topic.read", UrnPropertiesReader.getVariable("appc.client.topic.read.name")) + properties.put("topic.read.timeout", UrnPropertiesReader.getVariable("appc.client.topic.read.timeout")) + properties.put("client.response.timeout", UrnPropertiesReader.getVariable("appc.client.response.timeout")) + properties.put("topic.write", UrnPropertiesReader.getVariable("appc.client.topic.write")) + properties.put("poolMembers", UrnPropertiesReader.getVariable("appc.client.poolMembers")) + properties.put("client.key", UrnPropertiesReader.getVariable("appc.client.key")) + properties.put("client.secret", UrnPropertiesReader.getVariable("appc.client.secret")) + properties.put("client.name", "MSO") + properties.put("service", UrnPropertiesReader.getVariable("appc.client.service")) + return properties + } + +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy new file mode 100644 index 0000000000..b7f31d7823 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -0,0 +1,445 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +class UpdateVfModuleVolume extends VfModuleBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolume.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + private void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'UPDVfModVol_') + execution.setVariable('UPDVfModVol_Request', null) + execution.setVariable('UPDVfModVol_requestInfo', null) + execution.setVariable('UPDVfModVol_requestId', null) + execution.setVariable('UPDVfModVol_source', null) + execution.setVariable('UPDVfModVol_volumeInputs', null) + execution.setVariable('UPDVfModVol_volumeGroupId', null) + execution.setVariable('UPDVfModVol_vnfType', null) + execution.setVariable('UPDVfModVol_serviceId', null) + execution.setVariable('UPDVfModVol_aicCloudRegion', null) + execution.setVariable('UPDVfModVol_tenantId', null) + execution.setVariable('UPDVfModVol_volumeParams', null) + execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', null) + execution.setVariable('UPDVfModVol_volumeGroupTenantId', null) + execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + @Override + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + initProcessVariables(execution) + String request = validateRequest(execution) + + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') + execution.setVariable('UPDVfModVol_requestInfo', requestInfo) + execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) + execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source')) + + def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs') + execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs) + execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id')) + execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type')) + execution.setVariable('UPDVfModVol_serviceId', getRequiredNodeText(execution, volumeInputs, 'service-id')) + execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region')) + execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) + + def volumeParams = utils.getNodeXml(request, 'volume-params') + execution.setVariable('UPDVfModVol_volumeParams', volumeParams) + + msoLogger.trace('Exited ' + method) + msoLogger.debug("UpdateVfModuleVolume request: " + request) + } catch (BpmnError bpmnError) { + throw bpmnError + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * Prepare and send the synchronous response. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') + def requestId = execution.getVariable('UPDVfModVol_requestId') + def source = execution.getVariable('UPDVfModVol_source') + def progress = getNodeTextForce(requestInfo, 'progress') + if (progress.isEmpty()) { + progress = '0' + } + def startTime = getNodeTextForce(requestInfo, 'start-time') + if (startTime.isEmpty()) { + startTime = System.currentTimeMillis() + } + def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') + + String synchResponse = """ + + + ${MsoUtils.xmlEscape(requestId)} + UPDATE_VF_MODULE_VOL + IN_PROGRESS + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(startTime)} + ${MsoUtils.xmlEscape(source)} + + ${volumeInputs} + + """ + + synchResponse = utils.formatXml(synchResponse) + sendWorkflowResponse(execution, 200, synchResponse) + msoLogger.debug("UpdateVfModuleVolume Synch Response: " + synchResponse) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendSynchResponse(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for querying AAI for Volume Group information using the + * Volume Group Id and Aic Cloud Region. + * + * @param execution The flow's execution instance. + */ + public void queryAAIForVolumeGroup(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.queryAAIForVolumeGroup(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + + '/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/' + UriUtils.encode(aicCloudRegion, "UTF-8") + + '/volume-groups/volume-group/' + UriUtils.encode(volumeGroupId, "UTF-8") + + msoLogger.debug('Sending GET to AAI endpoint \'' + endPoint + '\'') + msoLogger.debug("UpdateVfModuleVolume sending GET for quering AAI endpoint: " + endPoint) + + AaiUtil aaiUtil = new AaiUtil(this) + APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) + def int statusCode = response.getStatusCode() + def responseData = response.getResponseBodyAsString() + msoLogger.debug('Response code:' + statusCode) + msoLogger.debug('Response:' + System.lineSeparator() + responseData) + msoLogger.debug("UpdateVfModuleVolume response data: " + responseData) + + def volumeGroup = responseData + def heatStackId = getNodeTextForce(volumeGroup, 'heat-stack-id') + execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId) + if ((statusCode == 200) || (statusCode == 204)) { + def volumeGroupTenantId = getTenantIdFromVolumeGroup(volumeGroup) + if (volumeGroupTenantId == null) { + throw new Exception('Could not find Tenant Id element in Volume Group with Volume Group Id \'' + volumeGroupId + '\'' + + '\', AIC Cloud Region \'' + aicCloudRegion + '\'') + } + execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) + msoLogger.debug('Received Tenant Id \'' + volumeGroupTenantId + '\' from AAI for Volume Group with Volume Group Id \'' + volumeGroupId + '\'' + + '\', AIC Cloud Region \'' + aicCloudRegion + '\'') + } else if (statusCode == 404) { + throw new Exception('Volume Group \'' + volumeGroupId + '\' not found at AAI') + } else { + throw new Exception('Bad status code ' + statusCode + ' received from AAI; Response data: ' + responseData) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVolumeGroup(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the VnfAdapterRest subflow to do + * a Volume Group update. + * + * @param execution The flow's execution instance. + */ + public void prepVnfAdapterRest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + def tenantId = execution.getVariable('UPDVfModVol_tenantId') + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') + def volumeGroupHeatStackId = execution.getVariable('UPDVfModVol_volumeGroupHeatStackId') + def vnfType = execution.getVariable('UPDVfModVol_vnfType') + + def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams') + def volumeGroupParams = transformParamsToEntries(volumeParamsXml) + + def requestId = execution.getVariable('UPDVfModVol_requestId') + def serviceId = execution.getVariable('UPDVfModVol_serviceId') + + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String vnfAdapterRestRequest = """ + + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupHeatStackId)} + ${MsoUtils.xmlEscape(vnfType)} + + + + ${volumeGroupParams} + + true + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest) + msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) + + msoLogger.debug("UpdateVfModuleVolume Request for VNFAdapter Rest: " + vnfAdapterRestRequest) + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for updating the DB for this Infra request. + * + * @param execution The flow's execution instance. + */ + public void prepDbInfraDbRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDbInfraDbRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestId = execution.getVariable('UPDVfMod_requestId') + + String updateInfraRequest = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPEL + COMPLETE + 100 + + + + """ + + updateInfraRequest = utils.formatXml(updateInfraRequest) + execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest) + msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) + + msoLogger.debug("UpdateVfModuleVolume Request for Updating DB for Infra: " + updateInfraRequest) + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 1002, 'Error in prepDbInfraDbRequest(): ' + e.getMessage()) + } + } + + /** + * Build a "CompletionHandler" request. + * + * @param execution The flow's execution instance. + */ + public void prepCompletionHandlerRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepCompletionHandlerRequest(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') + + String content = """ + + ${requestInfo} + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + msoLogger.debug('Request for Completion Handler:\n' + content) + msoLogger.debug("UpdateVfModuleVolume Completion Handler request: " + content) + execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepCompletionHandlerRequest(): ' + e.getMessage()) + } + } + + /** + * Build a "FalloutHandler" request. + * + * @param execution The flow's execution instance. + */ + public void prepFalloutHandler(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepFalloutHandler(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInfo} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + content = utils.formatXml(content) + msoLogger.debug('Request for Fallout Handler:\n' + content) + msoLogger.debug("UpdateVfModuleVolume Fallout request: " + content) + execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 1002, 'Error in prepFalloutHandler(): ' + e.getMessage()) + } + } + + /** + * Create a WorkflowException for the error case where the Tenant Id from + * AAI did not match the Tenant Id in the incoming request. + * + * @param execution The flow's execution instance. + */ + public void handleTenantIdMismatch(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.handleTenantIdMismatch(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + String processKey = getProcessKey(execution); + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + def tenantId = execution.getVariable('UPDVfModVol_tenantId') + def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId') + + def String errorMessage = 'TenantId \'' + tenantId + '\' in incoming request does not match Tenant Id \'' + volumeGroupTenantId + + '\' retrieved from AAI for Volume Group Id \'' + volumeGroupId + '\', AIC Cloud Region \'' + aicCloudRegion + '\'' + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + + WorkflowException exception = new WorkflowException(processKey, 5000, errorMessage); + execution.setVariable("WorkflowException", exception); + + msoLogger.trace('Exited ' + method) + msoLogger.debug("UpdateVfModuleVolume workflowException in Tenant Mismatch: " + errorMessage) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy new file mode 100644 index 0000000000..7b2d1b78e4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -0,0 +1,561 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VfModuleBase; +import org.onap.so.bpmn.common.scripts.VidUtils; +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils + +import groovy.json.JsonSlurper + +class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolumeInfraV1.class); + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + private void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'UPDVfModVol_') + execution.setVariable('UPDVfModVol_Request', null) + execution.setVariable('UPDVfModVol_requestInfo', null) + execution.setVariable('UPDVfModVol_requestId', null) + execution.setVariable('UPDVfModVol_source', null) + execution.setVariable('UPDVfModVol_volumeInputs', null) + execution.setVariable('UPDVfModVol_volumeGroupId', null) + execution.setVariable('UPDVfModVol_vnfType', null) + execution.setVariable('UPDVfModVol_serviceId', null) + execution.setVariable('UPDVfModVol_aicCloudRegion', null) + execution.setVariable('UPDVfModVol_tenantId', null) + execution.setVariable('UPDVfModVol_volumeParams', null) + execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', null) + execution.setVariable('UPDVfModVol_volumeGroupTenantId', null) + execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false) + } + + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) { + + initProcessVariables(execution) + String jsonRequest = validateRequest(execution) + + def request = "" + + try { + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(jsonRequest) + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def volumeGroupId = execution.getVariable('volumeGroupId') + //def vnfId = execution.getVariable('vnfId') + + def vidUtils = new VidUtils(this) + request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId) + + execution.setVariable('UPDVfModVol_Request', request) + execution.setVariable("UPDVfModVol_isVidRequest", true) + + //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI + + def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: '' + execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId) + + msoLogger.debug("modelInvariantId from request: " + modelInvariantId) + msoLogger.debug("XML request:\n" + request) + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is in XML format.") + // assume request is in XML format - proceed as usual to process XML request + } + + def requestId = execution.getVariable('mso-request-id') + + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') + execution.setVariable('UPDVfModVol_requestInfo', requestInfo) + execution.setVariable('UPDVfModVol_requestId', requestId) + //execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) + execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source')) + + def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs') + execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs) + execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id')) + execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type')) + execution.setVariable('UPDVfModVol_vnfVersion', getRequiredNodeText(execution, volumeInputs, 'asdc-service-model-version')) + execution.setVariable('UPDVfModVol_serviceId', utils.getNodeText(volumeInputs, 'service-id')) + execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region')) + execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) + //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id')) + + setBasicDBAuthHeader(execution, isDebugLogEnabled) + + def volumeParams = utils.getNodeXml(request, 'volume-params') + execution.setVariable('UPDVfModVol_volumeParams', volumeParams) + } + + /** + * Prepare and send the synchronous response. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) { + + def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') + def requestId = execution.getVariable('UPDVfModVol_requestId') + def source = execution.getVariable('UPDVfModVol_source') + def progress = getNodeTextForce(requestInfo, 'progress') + if (progress.isEmpty()) { + progress = '0' + } + def startTime = getNodeTextForce(requestInfo, 'start-time') + if (startTime.isEmpty()) { + startTime = System.currentTimeMillis() + } + def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') + + String xmlSyncResponse = """ + + + ${MsoUtils.xmlEscape(requestId)} + UPDATE_VF_MODULE_VOL + IN_PROGRESS + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(startTime)} + ${MsoUtils.xmlEscape(source)} + + ${volumeInputs} + + """ + + def syncResponse = '' + def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest') + + if(isVidRequest) { + def volumeGroupId = execution.getVariable('volumeGroupId') + syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() + } + else { + syncResponse = utils.formatXml(xmlSyncResponse) + } + + msoLogger.debug('Sync response: ' + syncResponse) + execution.setVariable('UPDVfModVol_syncResponseSent', true) + sendWorkflowResponse(execution, 200, syncResponse) + } + + /** + * Prepare a Request for querying AAI for Volume Group information using the + * Volume Group Id and Aic Cloud Region. + * @param execution The flow's execution instance. + */ + public void queryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) { + + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) + String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(aicCloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query volume group by id return code: " + returnCode) + msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString) + + msoLogger.debug("AAI Volume Group return code: " + returnCode) + msoLogger.debug("AAI Volume Group response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if ((returnCode == '200') || (returnCode == '204')) { + + execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', aaiResponseAsString) + //def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id') + //execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId) + + def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) + if (volumeGroupTenantId == null) { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId + + ", AIC Cloud Region " + aicCloudRegion) + } + execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) + msoLogger.debug("Received Tenant Id " + volumeGroupTenantId + " from AAI for Volume Group with Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion) + + def relatedVfModuleLink = getRelatedVfModuleRelatedLink(aaiResponseAsString) + msoLogger.debug("Related VF Module link: " + relatedVfModuleLink) + execution.setVariable('UPDVfModVol_relatedVfModuleLink', relatedVfModuleLink) + + } + else if (returnCode == '404') { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI") + } + else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + + /** + * Query AAI service instance + * @param execution + * @param isDebugEnabled + */ + public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) { + + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) + def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") + + msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query generic vnf return code: " + returnCode) + msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode=='200') { + msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.') + execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', aaiResponseAsString) + } else { + if (returnCode=='404') { + def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.' + msoLogger.debug(message) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } + + /** + * Query AAI for VF Module using vf-module-id + * @param execution + * @param isDebugLogEnabled + */ + public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) { + + AaiUtil aaiUtil = new AaiUtil(this) + String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink') + execution.setVariable('UPDVfModVol_personaModelId', '') + + msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest) + msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest) + + def aaiUrl = UrnPropertiesReader.getVariable("aai.endpoint", execution) + msoLogger.debug('A&AI URL: ' + aaiUrl) + + def requestEndpoint = aaiUrl + queryAAIVfModuleRequest + msoLogger.debug('A&AI request endpoint: ' + requestEndpoint) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + + msoLogger.debug("AAI query vf-module: " + returnCode) + msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString) + + msoLogger.debug("AAI query vf-module:: " + returnCode) + msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if ((returnCode == '200') || (returnCode == '204')) { + def personaModelId = utils.getNodeText(aaiResponseAsString, 'model-invariant-id') + if(personaModelId == null) { + //check old attribute name + personaModelId = utils.getNodeText(aaiResponseAsString, 'persona-model-id') + } + msoLogger.debug("vfModule personaModelId: " + personaModelId) + execution.setVariable('UPDVfModVol_personaModelId', personaModelId) + } + else if (returnCode == '404') { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "VF Module not found at AAI") + } + else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + /** + * + */ + public String getRelatedVfModuleRelatedLink(xml) { + def list = new XmlSlurper().parseText(xml) + def vfModuleRelationship = list.'**'.find { node -> node.'related-to'.text() == 'vf-module' } + return vfModuleRelationship?.'related-link'?.text() ?: '' + } + + /** + * Prepare a Request for invoking the VnfAdapterRest subflow to do + * a Volume Group update. + * + * @param execution The flow's execution instance. + */ + public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) { + + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + def tenantId = execution.getVariable('UPDVfModVol_tenantId') + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') + + def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse') + def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id') + def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name') + 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') + + def aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse') + def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id') + def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name') + + + def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams') + def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml) + + def requestId = execution.getVariable('UPDVfModVol_requestId') + def serviceId = execution.getVariable('UPDVfModVol_serviceId') + + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String vnfAdapterRestRequest = """ + + ${MsoUtils.xmlEscape(aicCloudRegion)} + ${MsoUtils.xmlEscape(tenantId)} + ${MsoUtils.xmlEscape(vnfId)} + ${MsoUtils.xmlEscape(vnfName)} + ${MsoUtils.xmlEscape(volumeGroupId)} + ${MsoUtils.xmlEscape(volumeGroupName)} + ${MsoUtils.xmlEscape(volumeGroupHeatStackId)} + ${MsoUtils.xmlEscape(vnfType)} + ${MsoUtils.xmlEscape(vnfVersion)} + + ${MsoUtils.xmlEscape(modelCustomizationId)} + + + vnf_id + ${MsoUtils.xmlEscape(vnfId)} + + + vnf_name + ${MsoUtils.xmlEscape(vnfName)} + + + vf_module_id + ${MsoUtils.xmlEscape(volumeGroupId)} + + + vf_module_name + ${MsoUtils.xmlEscape(volumeGroupName)} + + ${volumeGroupParams} + + true + + ${MsoUtils.xmlEscape(requestId)} + ${MsoUtils.xmlEscape(serviceId)} + + ${MsoUtils.xmlEscape(messageId)} + ${MsoUtils.xmlEscape(notificationUrl)} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest) + msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) + } + + /** + * Prepare a Request for updating the DB for this Infra request. + * + * @param execution The flow's execution instance. + */ + public void prepDbInfraDbRequest(DelegateExecution execution, isDebugLogEnabled) { + + def requestId = execution.getVariable('UPDVfModVol_requestId') + ExceptionUtil exceptionUtil = new ExceptionUtil(); + + String updateInfraRequest = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPEL + COMPLETE + 100 + + + + """ + + updateInfraRequest = utils.formatXml(updateInfraRequest) + execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest) + msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) + } + + /** + * Build a "CompletionHandler" request. + * @param execution The flow's execution instance. + */ + public void prepCompletionHandlerRequest(DelegateExecution execution, requestId, action, source, isDebugLogEnabled) { + + String content = """ + + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + + BPMN VF Module Volume action: UPDATE + + """ + + content = utils.formatXml(content) + msoLogger.debug('Request for Completion Handler:\n' + content) + execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content) + } + + + /** + * Build a "FalloutHandler" request. + * @param execution The flow's execution instance. + */ + public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) { + def requestId = execution.getVariable('UPDVfModVol_requestId') + def source = execution.getVariable('UPDVfModVol_source') + + String requestInfo = """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInfo} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + content = utils.formatXml(content) + msoLogger.debug('Request for Fallout Handler:\n' + content) + execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content) + } + + /** + * Create a WorkflowException for the error case where the Tenant Id from + * AAI did not match the Tenant Id in the incoming request. + * @param execution The flow's execution instance. + */ + public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) { + + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') + def tenantId = execution.getVariable('UPDVfModVol_tenantId') + def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId') + + def String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId + + " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion + + ExceptionUtil exceptionUtil = new ExceptionUtil() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + + /** + * Create a WorkflowException for the error case where the Personal Model Id from + * AAI did not match the model invariant ID in the incoming request. + * @param execution The flow's execution instance. + */ + public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) { + + def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId') + def personaModelId = execution.getVariable('UPDVfModVol_personaModelId') + + def String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId + + " retrieved from AAI for Volume Group Id " + + ExceptionUtil exceptionUtil = new ExceptionUtil() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy new file mode 100644 index 0000000000..f251dc46f8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -0,0 +1,481 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.* +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class UpdateVnfInfra extends VnfCmBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVnfInfra.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "UPDVnfI_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'UPDVnfI_') + execution.setVariable('Request', null) + execution.setVariable('source', null) + execution.setVariable('vnfInputs', null) + execution.setVariable('tenantId', null) + execution.setVariable('vnfParams', null) + execution.setVariable('controllerType', null) + execution.setVariable('UpdateVnfSuccessIndicator', false) + execution.setVariable('serviceType', null) + execution.setVariable('nfRole', null) + execution.setVariable('currentActivity', 'UPDVnfI') + execution.setVariable('workStep', null) + execution.setVariable('failedActivity', null) + execution.setVariable('errorCode', "0") + execution.setVariable('errorText', null) + execution.setVariable('healthCheckIndex0', 0) + execution.setVariable('healthCheckIndex1', 1) + execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) + execution.setVariable("rollbackVnfStop", false) + execution.setVariable("rollbackVnfLock", false) + execution.setVariable("rollbackQuiesceTraffic", false) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + + msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + def incomingRequest = execution.getVariable('bpmnRequest') + + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + execution.setVariable("isVidRequest", "true") + execution.setVariable('serviceType', 'Mobility') + execution.setVariable('actionLock', Action.Lock) + execution.setVariable('actionUnlock', Action.Unlock) + execution.setVariable('actionHealthCheck', Action.HealthCheck) + execution.setVariable('actionStart', Action.Start) + execution.setVariable('actionStop', Action.Stop) + + def asdcServiceModelVersion = '' + def serviceModelInfo = null + + def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + msoLogger.debug("PROCESSING SERVICE INFO") + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + msoLogger.debug("ServiceModelInfo: " + serviceModelInfo) + def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid") + msoLogger.debug("modelInvariant: " + modelInvariant) + } + + } + } + + execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion) + execution.setVariable('serviceModelInfo', serviceModelInfo) + def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable('vnfModelInfo', vnfModelInfo) + def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid") + execution.setVariable('vnfModelInvariantUuid', vnfModelInvariantUuid) + msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid) + + def vnfType = execution.getVariable('vnfType') + execution.setVariable('vnfType', vnfType) + + + def controllerType = reqMap.requestDetails?.requestParameters?.controllerType + execution.setVariable('controllerType', controllerType) + + msoLogger.debug('Controller Type: ' + controllerType) + + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value.toString()) + } + } + + msoLogger.debug('Processed user params: ' + userParamsMap) + + execution.setVariable('vfModuleInputParams', userParamsMap) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable('requestId', requestId) + execution.setVariable('msoRequestId', requestId) + + + def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null + execution.setVariable('vnfName', vnfName) + + def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null + execution.setVariable('requestorId', requestorId) + + def usePreload = reqMap.requestDetails?.requestParameters?.usePreload + execution.setVariable('usePreload', usePreload) + + def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration + def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def tenantId = cloudConfiguration.tenantId + execution.setVariable('tenantId', tenantId) + + def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' + execution.setVariable('globalSubscriberId', globalSubscriberId) + + execution.setVariable('sdncVersion', '1702') + + execution.setVariable("UpdateVnfInfraSuccessIndicator", false) + + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("requestInfo", requestInfo) + + msoLogger.debug('RequestInfo: ' + execution.getVariable("requestInfo")) + + msoLogger.trace('Exited ' + method) + + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + + try { + def requestInfo = execution.getVariable('requestInfo') + def requestId = execution.getVariable('requestId') + def source = execution.getVariable('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) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + + /** + * Get VnfResource decomposition object for this VNF. + * + * + * @param execution The flow's execution instance. + */ + public void getVnfResourceDecomposition(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid') + msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid) + List vnfResources = serviceDecomposition.getVnfResources() + + for (i in 0..vnfResources.size()-1) { + ModelInfo modelInfo = vnfResources[i].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition) + + if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + VnfResource vnfResourceDecomposition = vnfResources[i] + execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition) + def nfRole = vnfResourceDecomposition.getNfRole() + execution.setVariable('nfRole', nfRole) + msoLogger.debug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString()) + break + } + else { + //exception! + } + + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, '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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkIfVnfInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + 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) + msoLogger.debug("isInMaint result: " + isInMaint) + execution.setVariable('isVnfInMaintenance', isInMaint) + + if (isInMaint) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "VNF is in maintenance in A&AI") + } + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("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) + msoLogger.debug("areLocked result: " + areLocked) + execution.setVariable('arePserversLocked', areLocked) + + if (areLocked) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "pServers are locked in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + if (inMaint) { + execution.setVariable("workStep", "setVnfInMaintFlagInAAI") + } + else { + execution.setVariable("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) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) + } + } + + + + /** + * Prepare DoUpdateVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoUpdateVnfAndModules(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoUpdateVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("workStep", "doUpdateVnfAndModules") + execution.setVariable("failedActivity", "MSO Update VNF") + msoLogger.trace('Exited ' + method) + + } + + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def errorText = execution.getVariable("errorText") + def errorCode = execution.getVariable("errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy new file mode 100644 index 0000000000..fd9d9cc8a3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -0,0 +1,835 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray +import org.json.JSONObject +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers +import org.onap.appc.client.lcm.model.Flags +import org.onap.appc.client.lcm.model.Status +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.* +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.Relationships +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.appc.ApplicationControllerClient; +import org.onap.so.client.appc.ApplicationControllerSupport; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonSlurper + +public abstract class VnfCmBase extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfCmBase.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "VnfIPU_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + + try { + def requestInfo = execution.getVariable('requestInfo') + def requestId = execution.getVariable('requestId') + def source = execution.getVariable('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) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + + /** + * Get VnfResource decomposition object for this VNF. + * + * + * @param execution The flow's execution instance. + */ + public void getVnfResourceDecomposition(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' + + 'execution=' + execution.getId() + + ')' + msoLogger.trace('Entered ' + method) + + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid') + msoLogger.debug("vnfModelInvariantUuid: " + vnfModelInvariantUuid) + List vnfResources = serviceDecomposition.getVnfResources() + + for (i in 0..vnfResources.size()-1) { + ModelInfo modelInfo = vnfResources[i].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition) + + if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + VnfResource vnfResourceDecomposition = vnfResources[i] + execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition) + def nfRole = vnfResourceDecomposition.getNfRole() + execution.setVariable('nfRole', nfRole) + msoLogger.debug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString()) + break + } + else { + //exception! + } + + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, '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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkIfVnfInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + 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) + msoLogger.debug("isInMaint result: " + isInMaint) + execution.setVariable('isVnfInMaintenance', isInMaint) + + if (isInMaint) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "VNF is in maintenance in A&AI") + } + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) + } + } + + /** + * Get VNF info from A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void queryAAIForVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.queryAAIForVnf(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + msoLogger.debug("vnfId is: " + vnfId) + def cloudRegionId = execution.getVariable("lcpCloudRegionId") + msoLogger.debug("cloudRegionId is: " + cloudRegionId) + + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + // Check if this VNF exists + if (!client.exists(genericVnfUri)) { + msoLogger.debug("VNF with vnfId " + vnfId + " does not exist in A&AI") + exceptionUtil.buildAndThrowWorkflowException(execution, 404, "VNF with vnfId " + vnfId + " does not exist in A&AI") + } + + AAIResultWrapper aaiRW = client.get(genericVnfUri) + + Map result = aaiRW.asMap() + + String vnfName = result.get("vnf-name") + msoLogger.debug("vnfName from A&AI is: " + vnfName) + execution.setVariable("vnfName", vnfName) + String nfRole = result.get("nf-role") + msoLogger.debug("nfRole from A&AI is: " + nfRole) + execution.setVariable("nfRole", nfRole) + String vnfHostIpAddress = result.get("ipv4-oam-address") + msoLogger.debug("vnfHostIpAddress from A&AI is: " + vnfHostIpAddress) + execution.setVariable("vnfHostIpAddress", vnfHostIpAddress) + execution.setVariable("vmIdList", null) + if (aaiRW.getRelationships() != null) { + Relationships relationships = aaiRW.getRelationships().get() + if (relationships != null) { + + List vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER) + JSONArray vserverIds = new JSONArray() + JSONArray vserverSelfLinks = new JSONArray() + + for (AAIResourceUri j in vserverUris) { + + String vserverId = j.getURIKeys().get('vserver-id') + String vserverJson = client.get(j).getJson() + msoLogger.debug("Retrieved vserverJson from AAI: " + vserverJson) + String vserverSelfLink = jsonUtils.getJsonValue(vserverJson, "vserver-selflink") + + vserverIds.put(vserverId) + vserverSelfLinks.put(vserverSelfLink) + } + + JSONObject vmidsArray = new JSONObject() + JSONObject vserveridsArray = new JSONObject() + vmidsArray.put("vmIds", vserverSelfLinks.toString()) + vserveridsArray.put("vserverIds", vserverIds.toString()) + + msoLogger.debug("vmidsArray is: " + vmidsArray.toString()) + msoLogger.debug("vserveridsArray is: " + vserveridsArray.toString()) + + execution.setVariable("vmIdList", vmidsArray.toString()) + execution.setVariable("vserverIdList", vserveridsArray.toString()) + } + } + + if (cloudRegionId != null) { + AAIUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIObjectType.DEFAULT_CLOUD_REGION, cloudRegionId) + // Check if this client region exists + if (!client.exists(cloudRegionUri)) { + msoLogger.debug("Cloud Region with cloudRegionId " + cloudRegionId + " does not exist in A&AI") + exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Cloud Region with cloudRegionId " + cloudRegionId + " does not exist in A&AI") + } + + AAIResultWrapper aaiRWCloud = client.get(cloudRegionUri) + + Map resultCloud = aaiRWCloud.asMap() + + String aicIdentity = resultCloud.get("identity-url") + msoLogger.debug("aicIdentity from A&AI is: " + aicIdentity) + execution.setVariable("aicIdentity", aicIdentity) + } + // preserve relationships if exist + Optional relationships = aaiRW.getRelationships() + + if(relationships.isPresent()) { + msoLogger.debug("relationships are present") + String rs = relationships.get().getJson() + def jsonSlurper = new JsonSlurper() + def map = jsonSlurper.parseText(rs) + if (map instanceof Map) { + List> relationshipsList = (List>)map.get("relationship"); + for (Map relationship : relationshipsList) { + final String relatedTo = (String)relationship.get("related-to"); + if (relatedTo.equals("platform")) { + List> relationshipDataList = (List>)relationship.get("relationship-data") + msoLogger.debug("Found platform entry") + for (Map relationshipData : relationshipDataList) { + String relationshipKey = (String)relationshipData.get("relationship-key"); + if (relationshipKey.equals("platform.platform-name")) { + String platformName = (String) relationshipData.get("relationship-value") + msoLogger.debug("platform from A&AI is: " + platformName) + execution.setVariable("platform", platformName) + break + } + } + } + if (relatedTo.equals("line-of-business")) { + List> relationshipDataList = (List>)relationship.get("relationship-data") + msoLogger.debug("Found line-of-business entry") + for (Map relationshipData : relationshipDataList) { + String relationshipKey = (String)relationshipData.get("relationship-key"); + if (relationshipKey.equals("line-of-business.line-of-business-name")) { + String lineOfBusinessName = (String) relationshipData.get("relationship-value") + msoLogger.debug("lineOfBusiness from A&AI is: " + lineOfBusinessName) + execution.setVariable("lineOfBusiness", lineOfBusinessName) + break + } + } + } + } + + } + + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVnf(): ' + e.getMessage()) + } + } + + + + /** + * Check if this VNF's pservers are locked in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfPserversInMaintInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("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) + msoLogger.debug("areLocked result: " + areLocked) + execution.setVariable('arePserversLocked', areLocked) + + if (areLocked) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "pServers are locked in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + if (inMaint) { + execution.setVariable("workStep", "setVnfInMaintFlagInAAI") + } + else { + execution.setVariable("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) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) + } + } + + /** + * Check if VF Closed Loop Disabled in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + msoLogger.debug("vnfId is: " + vnfId) + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResultWrapper aaiRW = client.get(genericVnfUri) + Map result = aaiRW.asMap() + boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) + + msoLogger.debug("isClosedLoopDisabled result: " + isClosedLoopDisabled) + execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled) + + if (isClosedLoopDisabled) { + execution.setVariable("errorCode", "1004") + execution.setVariable("errorText", "closedLoop is disabled in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } + } + + /** + * Set VF Closed Loop Disabled Flag in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) { + def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + if (setDisabled) { + execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI") + execution.setVariable("rollbackSetClosedLoopDisabledFlag", true) + } + else { + execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI") + execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) + } + + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + + Map request = new HashMap<>() + request.put("is-closed-loop-disabled", setDisabled) + client.update(genericVnfUri, request) + msoLogger.debug("set isClosedLoop to: " + setDisabled) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", 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(DelegateExecution execution, Action action) { + def method = getClass().getSimpleName() + '.runAppcCommand(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + + ApplicationControllerClient appcClient = null + + try { + msoLogger.debug("Running APP-C action: " + action.toString()) + String vnfId = execution.getVariable('vnfId') + String msoRequestId = execution.getVariable('requestId') + execution.setVariable('msoRequestId', msoRequestId) + execution.setVariable("failedActivity", "APP-C") + + appcClient = new ApplicationControllerClient() + ApplicationControllerSupport support = new ApplicationControllerSupport() + appcClient.appCSupport=support + org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.onap.appc.client.lcm.model"); + Flags flags = new Flags(); + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + Status appcStatus + switch(action) { + case Action.Lock: + execution.setVariable('workStep', "LockVNF") + appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,null,msoRequestId) + break + case Action.Unlock: + execution.setVariable('workStep', "UnlockVNF") + appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,null,msoRequestId) + break + case Action.HealthCheck: + def healthCheckIndex = execution.getVariable('healthCheckIndex') + execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex) + execution.setVariable('healthCheckIndex', healthCheckIndex + 1) + appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,null,msoRequestId) + break + case Action.Start: + execution.setVariable('workStep', "StartVNF") + appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,null,msoRequestId) + break + case Action.Stop: + execution.setVariable('workStep', "StopVNF") + appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,null,msoRequestId) + break + default: + break + } + msoLogger.debug("Completed AppC request") + int appcCode = appcStatus.getCode() + msoLogger.debug("AppC status code is: " + appcCode) + msoLogger.debug("AppC status message is: " + appcStatus.getMessage()) + if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { + execution.setVariable("errorCode", Integer.toString(appcCode)) + execution.setVariable("errorText", appcStatus.getMessage()) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + + } catch (java.lang.NoSuchMethodError e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + + } + } + + /** + * Placeholder for a call to 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 runAppcCommandPlaceholder(DelegateExecution execution, String action) { + def method = getClass().getSimpleName() + '.runAppcCommandPlaceholder(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("failedActivity", "APP-C") + execution.setVariable("workStep", action) + } + + + + + + + + /** + * 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.completionHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace('Entered ' + method) + + try { + + def requestInfo = execution.getVariable('requestInfo') + + String content = """ + + ${requestInfo} + Vnf has been updated successfully. + MSO_ACTIVATE_BPEL + + """ + + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Prepare DoUpdateVnfAndModules call. + * + * + * @param execution The flow's execution instance. + */ + public void prepDoUpdateVnfAndModules(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepDoUpdateVnfAndModules(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("workStep", "doUpdateVnfAndModules") + execution.setVariable("failedActivity", "MSO Update VNF") + msoLogger.trace('Exited ' + method) + + } + + /** + * 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(DelegateExecution execution, String resultVar) { + def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + + 'execution=' + execution.getId() + + ', resultVar=' + resultVar + + ')' + + msoLogger.trace('Entered ' + method) + + try { + def prefix = execution.getVariable('prefix') + def requestInformation = execution.getVariable("requestInfo") + + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def errorResponseCode = workflowException.getErrorCode() + def errorResponseMsg = workflowException.getErrorMessage() + def encErrorResponseMsg = "" + if (errorResponseMsg != null) { + encErrorResponseMsg = errorResponseMsg + } + + String content = """ + + ${requestInformation} + + ${MsoUtils.xmlEscape(encErrorResponseMsg)} + ${MsoUtils.xmlEscape(errorResponseCode)} + + + """ + content = utils.formatXml(content) + msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content) + execution.setVariable(resultVar, content) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') + } + } + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def errorText = execution.getVariable("errorText") + def errorCode = execution.getVariable("errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + /** + * Increment Retry Count for Current Work Step + * + * @param execution The flow's execution instance. + */ + public void incrementRetryCount(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.incrementRetryCount(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + String retryCountVariableName = execution.getVariable("workStep") + "RetryCount" + execution.setVariable("retryCountVariableName", retryCountVariableName) + + def retryCountVariable = execution.getVariable(retryCountVariableName) + int retryCount = 0 + + if (retryCountVariable != null) { + retryCount = (int) retryCountVariable + } + + retryCount += 1 + + execution.setVariable(retryCountVariableName, retryCount) + + msoLogger.debug("value of " + retryCountVariableName + " is " + retryCount) + msoLogger.trace('Exited ' + method) + + + } + + + public void preProcessRollback (DelegateExecution execution) { + msoLogger.trace("preProcessRollback ") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit preProcessRollback ") + } + + public void postProcessRollback (DelegateExecution execution) { + msoLogger.trace("postProcessRollback ") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit postProcessRollback ") + } + + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy new file mode 100644 index 0000000000..8ca2871916 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy @@ -0,0 +1,483 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.* +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class VnfConfigUpdate extends VnfCmBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfConfigUpdate.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "VnfIPU_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'VnfCU_') + execution.setVariable('Request', null) + execution.setVariable('source', null) + execution.setVariable('controllerType', null) + execution.setVariable('UpdateVnfSuccessIndicator', false) + execution.setVariable('serviceType', null) + execution.setVariable('nfRole', null) + execution.setVariable('currentActivity', 'VnfCU') + execution.setVariable('workStep', null) + execution.setVariable('failedActivity', null) + execution.setVariable('errorCode', "0") + execution.setVariable('errorText', null) + execution.setVariable('healthCheckIndex0', 0) + execution.setVariable('healthCheckIndex1', 1) + execution.setVariable('maxRetryCount', 3) + execution.setVariable('retryCount', 0) + execution.setVariable("lcpCloudRegionId", null) + execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) + execution.setVariable("rollbackVnfStop", false) + execution.setVariable("rollbackVnfLock", false) + execution.setVariable("rollbackQuiesceTraffic", false) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + + msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + def incomingRequest = execution.getVariable('bpmnRequest') + + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + execution.setVariable('serviceInstanceId', serviceInstanceId) + execution.setVariable('vnfId', vnfId) + execution.setVariable('serviceType', 'Mobility') + execution.setVariable('payload', "") + execution.setVariable('actionHealthCheck', Action.HealthCheck) + execution.setVariable('actionConfigModify', Action.ConfigModify) + + + def controllerType = reqMap.requestDetails?.requestParameters?.controllerType + execution.setVariable('controllerType', controllerType) + + msoLogger.debug('Controller Type: ' + controllerType) + + def payload = reqMap.requestDetails?.requestParameters?.payload + execution.setVariable('payload', payload) + + msoLogger.debug('Processed payload: ' + payload) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable('requestId', requestId) + execution.setVariable('msoRequestId', requestId) + + def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null + execution.setVariable('requestorId', requestorId) + + execution.setVariable('sdncVersion', '1702') + + execution.setVariable("UpdateVnfInfraSuccessIndicator", false) + + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("requestInfo", requestInfo) + + msoLogger.debug('RequestInfo: ' + execution.getVariable("requestInfo")) + + msoLogger.trace('Exited ' + method) + + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + + try { + def requestInfo = execution.getVariable('requestInfo') + def requestId = execution.getVariable('requestId') + def source = execution.getVariable('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) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + /** + * Check if this VNF is already in maintenance in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfVnfInMaintInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkIfVnfInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + 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) + msoLogger.debug("isInMaint result: " + isInMaint) + execution.setVariable('isVnfInMaintenance', isInMaint) + + if (isInMaint) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "VNF is in maintenance in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("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) + msoLogger.debug("areLocked result: " + areLocked) + execution.setVariable('arePserversLocked', areLocked) + + if (areLocked) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "pServers are locked in A&AI") + } + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + if (inMaint) { + execution.setVariable("workStep", "setVnfInMaintFlagInAAI") + execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) + } + else { + execution.setVariable("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) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) + } + } + + /** + * Check if VF Closed Loop Disabled in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + msoLogger.debug("vnfId is: " + vnfId) + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResultWrapper aaiRW = client.get(genericVnfUri) + Map result = aaiRW.asMap() + boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) + + msoLogger.debug("isClosedLoopDisabled result: " + isClosedLoopDisabled) + execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled) + + if (isClosedLoopDisabled) { + execution.setVariable("errorCode", "1004") + execution.setVariable("errorText", "closedLoop is disabled in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) + } + } + + /** + * Set VF Closed Loop Disabled Flag in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) { + def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + if (setDisabled) { + execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI") + execution.setVariable("rollbackSetClosedLoopDisabledFlag", true) + } + else { + execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI") + } + + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + + Map request = new HashMap<>() + request.put("is-closed-loop-disabled", setDisabled) + client.update(genericVnfUri, request) + msoLogger.debug("set isClosedLoop to: " + setDisabled) + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) + } + } + + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def errorText = execution.getVariable("errorText") + def errorCode = execution.getVariable("errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + /** + * Increment Retry Count for Current Work Step + * + * @param execution The flow's execution instance. + */ + public void incrementRetryCount(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.incrementRetryCount(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + String retryCountVariableName = execution.getVariable("workStep") + "RetryCount" + execution.setVariable("retryCountVariableName", retryCountVariableName) + + def retryCountVariable = execution.getVariable(retryCountVariableName) + int retryCount = 0 + + if (retryCountVariable != null) { + retryCount = (int) retryCountVariable + } + + retryCount += 1 + + execution.setVariable(retryCountVariableName, retryCount) + + msoLogger.debug("value of " + retryCountVariableName + " is " + retryCount) + msoLogger.trace('Exited ' + method) + + + } + + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy new file mode 100644 index 0000000000..68d5c19b80 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -0,0 +1,599 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.appc.client.lcm.model.Action +import org.onap.appc.client.lcm.model.ActionIdentifiers +import org.onap.appc.client.lcm.model.Flags +import org.onap.appc.client.lcm.model.Status +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.* +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.appc.ApplicationControllerClient; +import org.onap.so.client.appc.ApplicationControllerSupport; +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +import groovy.json.JsonOutput +import groovy.json.JsonSlurper + +public class VnfInPlaceUpdate extends VnfCmBase { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfInPlaceUpdate.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "VnfIPU_" + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable('prefix', 'VnfIPU_') + execution.setVariable('Request', null) + execution.setVariable('requestInfo', null) + execution.setVariable('source', null) + execution.setVariable('vnfInputs', null) + execution.setVariable('tenantId', null) + execution.setVariable('vnfParams', null) + execution.setVariable('controllerType', null) + execution.setVariable('UpdateVnfSuccessIndicator', false) + execution.setVariable('serviceType', null) + execution.setVariable('nfRole', null) + execution.setVariable('currentActivity', 'VnfIPU') + execution.setVariable('workStep', null) + execution.setVariable('failedActivity', null) + execution.setVariable('errorCode', "0") + execution.setVariable('errorText', null) + execution.setVariable('healthCheckIndex0', 0) + execution.setVariable('healthCheckIndex1', 1) + execution.setVariable('maxRetryCount', 3) + execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) + execution.setVariable("rollbackVnfStop", false) + execution.setVariable("rollbackVnfLock", false) + execution.setVariable("rollbackQuiesceTraffic", false) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) + } + + /** + * Check for missing elements in the received request. + * + * @param execution The flow's execution instance. + */ + public void preProcessRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + initProcessVariables(execution) + + msoLogger.trace('Entered ' + method) + + initProcessVariables(execution) + + def incomingRequest = execution.getVariable('bpmnRequest') + + msoLogger.debug("Incoming Infra Request: " + incomingRequest) + try { + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + Map reqMap = jsonSlurper.parseText(incomingRequest) + msoLogger.debug(" Request is in JSON format.") + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + execution.setVariable('serviceInstanceId', serviceInstanceId) + execution.setVariable('vnfId', vnfId) + execution.setVariable("isVidRequest", "true") + execution.setVariable('serviceType', 'Mobility') + execution.setVariable('payload', "") + execution.setVariable('actionSnapshot', Action.Snapshot) + execution.setVariable('actionLock', Action.Lock) + execution.setVariable('actionUnlock', Action.Unlock) + execution.setVariable('actionUpgradePreCheck', Action.UpgradePreCheck) + execution.setVariable('actionUpgradePostCheck', Action.UpgradePostCheck) + execution.setVariable('actionQuiesceTraffic', Action.QuiesceTraffic) + execution.setVariable('actionUpgradeBackup', Action.UpgradeBackup) + execution.setVariable('actionUpgradeSoftware', Action.UpgradeSoftware) + execution.setVariable('actionResumeTraffic', Action.ResumeTraffic) + + + def controllerType = reqMap.requestDetails?.requestParameters?.controllerType + execution.setVariable('controllerType', controllerType) + + msoLogger.debug('Controller Type: ' + controllerType) + + def payload = reqMap.requestDetails?.requestParameters?.payload + execution.setVariable('payload', payload) + + msoLogger.debug('Processed payload: ' + payload) + + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable('requestId', requestId) + execution.setVariable('msoRequestId', requestId) + + def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null + execution.setVariable('requestorId', requestorId) + + def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration + def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def tenantId = cloudConfiguration.tenantId + execution.setVariable('tenantId', tenantId) + + execution.setVariable("UpdateVnfInfraSuccessIndicator", false) + + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + UPDATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable("requestInfo", requestInfo) + + msoLogger.debug('RequestInfo: ' + execution.getVariable("requestInfo")) + + msoLogger.trace('Exited ' + method) + + } + catch(groovy.json.JsonException je) { + msoLogger.debug(" Request is not in JSON format.") + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") + } + catch(Exception e) { + String restFaultMessage = e.getMessage() + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) + } + } + + /** + * Prepare and send the sychronous response for this flow. + * + * @param execution The flow's execution instance. + */ + public void sendSynchResponse(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendSynchResponse(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + + try { + def requestInfo = execution.getVariable('requestInfo') + def requestId = execution.getVariable('requestId') + def source = execution.getVariable('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) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) + } + } + + + /** + * Check if this VNF is already in maintenance in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfVnfInMaintInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkIfVnfInMaintInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + 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) + msoLogger.debug("isInMaint result: " + isInMaint) + execution.setVariable('isVnfInMaintenance', isInMaint) + + if (isInMaint) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "VNF is in maintenance in A&AI") + } + + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("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) + msoLogger.debug("areLocked result: " + areLocked) + execution.setVariable('arePserversLocked', areLocked) + + if (areLocked) { + execution.setVariable("errorCode", "1003") + execution.setVariable("errorText", "pServers are locked in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("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(DelegateExecution execution, boolean inMaint) { + def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + if (inMaint) { + execution.setVariable("workStep", "setVnfInMaintFlagInAAI") + } + else { + execution.setVariable("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) + execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) + } + else { + aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) + } + } + + /** + * Check if VF Closed Loop Disabled in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI") + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + msoLogger.debug("vnfId is: " + vnfId) + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResultWrapper aaiRW = client.get(genericVnfUri) + Map result = aaiRW.asMap() + boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) + + msoLogger.debug("isClosedLoopDisabled result: " + isClosedLoopDisabled) + execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled) + + if (isClosedLoopDisabled) { + execution.setVariable("errorCode", "1004") + execution.setVariable("errorText", "closedLoop is disabled in A&AI") + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } + } + + /** + * Set VF Closed Loop Disabled Flag in A&AI. + * + * + * @param execution The flow's execution instance. + */ + public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) { + def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + if (setDisabled) { + execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI") + execution.setVariable("rollbackSetClosedLoopDisabledFlag", true) + } + else { + execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI") + } + + execution.setVariable("failedActivity", "AAI") + msoLogger.trace('Entered ' + method) + + try { + def transactionLoggingUuid = UUID.randomUUID().toString() + def vnfId = execution.getVariable("vnfId") + AAIResourcesClient client = new AAIResourcesClient() + AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + + Map request = new HashMap<>() + request.put("is-closed-loop-disabled", setDisabled) + client.update(genericVnfUri, request) + msoLogger.debug("set isClosedLoop to: " + setDisabled) + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", 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(DelegateExecution execution, Action action) { + def method = getClass().getSimpleName() + '.runAppcCommand(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + + ApplicationControllerClient appcClient = null + + try { + msoLogger.debug("Running APP-C action: " + action.toString()) + String vnfId = execution.getVariable('vnfId') + String msoRequestId = execution.getVariable('requestId') + execution.setVariable('msoRequestId', msoRequestId) + execution.setVariable("failedActivity", "APP-C") + + appcClient = new ApplicationControllerClient() + ApplicationControllerSupport support = new ApplicationControllerSupport() + appcClient.appCSupport=support + org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.onap.appc.client.lcm.model"); + Flags flags = new Flags(); + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + Status appcStatus + switch(action) { + case Action.Lock: + execution.setVariable('workStep', "LockVNF") + appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,null,msoRequestId) + break + case Action.Unlock: + execution.setVariable('workStep', "UnlockVNF") + appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,null,msoRequestId) + break + case Action.HealthCheck: + def healthCheckIndex = execution.getVariable('healthCheckIndex') + execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex) + execution.setVariable('healthCheckIndex', healthCheckIndex + 1) + appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,null,msoRequestId) + break + case Action.Start: + execution.setVariable('workStep', "StartVNF") + appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,null,msoRequestId) + break + case Action.Stop: + execution.setVariable('workStep', "StopVNF") + appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,null,msoRequestId) + break + default: + break + } + msoLogger.debug("Completed AppC request") + int appcCode = appcStatus.getCode() + msoLogger.debug("AppC status code is: " + appcCode) + msoLogger.debug("AppC status message is: " + appcStatus.getMessage()) + if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { + execution.setVariable("errorCode", Integer.toString(appcCode)) + execution.setVariable("errorText", appcStatus.getMessage()) + } + + msoLogger.trace('Exited ' + method) + } catch (BpmnError e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } catch (java.lang.NoSuchMethodError e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + execution.setVariable("errorCode", "1002") + execution.setVariable("errorText", e.getMessage()) + } + } + + /** + * Placeholder for a call to 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 runAppcCommandPlaceholder(DelegateExecution execution, String action) { + def method = getClass().getSimpleName() + '.runAppcCommandPlaceholder(' + + 'execution=' + execution.getId() + + ')' + + execution.setVariable('errorCode', "0") + msoLogger.trace('Entered ' + method) + execution.setVariable("failedActivity", "APP-C") + execution.setVariable("workStep", action) + } + + + + /** + * Handle Abort disposition from RainyDayHandler + * + * @param execution The flow's execution instance. + */ + public void abortProcessing(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.abortProcessing(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + def errorText = execution.getVariable("errorText") + def errorCode = execution.getVariable("errorCode") + + exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) + } + + /** + * Increment Retry Count for Current Work Step + * + * @param execution The flow's execution instance. + */ + public void incrementRetryCount(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.incrementRetryCount(' + + 'execution=' + execution.getId() + + ')' + + msoLogger.trace('Entered ' + method) + + String retryCountVariableName = execution.getVariable("workStep") + "RetryCount" + execution.setVariable("retryCountVariableName", retryCountVariableName) + + def retryCountVariable = execution.getVariable(retryCountVariableName) + int retryCount = 0 + + if (retryCountVariable != null) { + retryCount = (int) retryCountVariable + } + + retryCount += 1 + + execution.setVariable(retryCountVariableName, retryCount) + + msoLogger.debug("value of " + retryCountVariableName + " is " + retryCount) + msoLogger.trace('Exited ' + method) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy new file mode 100644 index 0000000000..86c5f65e8c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -0,0 +1,814 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.vcpe.scripts; + +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.* +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.springframework.web.util.UriUtils; + +import groovy.json.* + + + +/** + * This groovy class supports the CreateVcpeResCustService.bpmn process. + * + * @author ek1439 + * + */ +public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVcpeResCustService.class); + + private static final String DebugFlag = "isDebugLogEnabled" + + String Prefix = "CVRCS_" + 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(DelegateExecution execution) { + /* Initialize all the process variables in this block */ + + execution.setVariable("createVcpeServiceRequest", "") + execution.setVariable("globalSubscriberId", "") + execution.setVariable("serviceInstanceName", "") + execution.setVariable("msoRequestId", "") + execution.setVariable(Prefix + "VnfsCreatedCount", 0) + execution.setVariable("productFamilyId", "") + execution.setVariable("brgWanMacAddress", "") + execution.setVariable("customerLocation", "") + execution.setVariable("homingService", "") + execution.setVariable("cloudOwner", "") + execution.setVariable("cloudRegionId", "") + execution.setVariable("homingModelIds", "") + + //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(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside preProcessRequest CreateVcpeResCustService Request ") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + //Config Inputs + String aaiDistDelay = execution.getVariable('URN_mso_workflow_aai_distribution_delay') + if (isBlank(aaiDistDelay)) { + msg = "URN_mso_workflow_aai_distribution_delay is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("aaiDistDelay", aaiDistDelay) + msoLogger.debug("AAI distribution delay: " + aaiDistDelay) + + // check for incoming json message/input + String createVcpeServiceRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(createVcpeServiceRequest) + execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest); + println 'createVcpeServiceRequest - ' + createVcpeServiceRequest + + // 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() + msoLogger.debug(" Generated new Service Instance: " + serviceInstanceId) + } else { + msoLogger.debug("Using provided Service Instance ID: " + serviceInstanceId) + } + + serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + utils.log("DEBUG", "Incoming serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + + String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName") + execution.setVariable("serviceInstanceName", serviceInstanceName) + utils.log("DEBUG", "Incoming serviceInstanceName is: " + serviceInstanceName, isDebugEnabled) + + String requestAction = execution.getVariable("requestAction") + execution.setVariable("requestAction", requestAction) + + setBasicDBAuthHeader(execution, isDebugEnabled) + + String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + source = "VID" + } + execution.setVariable("source", source) + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "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(createVcpeServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + msoLogger.debug("Incoming subscriptionServiceType is: " + subscriptionServiceType) + + String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + msoLogger.debug("Incoming Suppress/Disable Rollback is: " + suppressRollback) + + String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + msoLogger.debug("Incoming productFamilyId is: " + productFamilyId) + + String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo") + execution.setVariable("subscriberInfo", subscriberInfo) + msoLogger.debug("Incoming subscriberInfo is: " + subscriberInfo) + + // extract cloud configuration, split vid_ID into cloudOwner and cloudRegionId + String vimId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.cloudConfiguration.lcpCloudRegionId") + def cloudRegion = vimId.split("_") + def cloudOwner = cloudRegion[0].toString() + def cloudRegionId = cloudRegion[1].toString() + execution.setVariable("cloudOwner", cloudOwner) + utils.log("DEBUG","cloudOwner: " + cloudOwner, isDebugEnabled) + execution.setVariable("cloudRegionId", cloudRegionId) + utils.log("DEBUG","cloudRegionId: " + cloudRegionId, isDebugEnabled) + + /* + * Extracting User Parameters from incoming Request and converting into a Map + */ + def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() + + Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest) + + //InputParams + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map inputMap = [:] + if (userParams) { + userParams.each { + userParam -> + if ("Customer_Location".equals(userParam?.name)) { + execution.setVariable("customerLocation", userParam.value) + userParam.value.each { + param -> + inputMap.put(param.key, param.value) + } + } + if ("Homing_Model_Ids".equals(userParam?.name)) { + utils.log("DEBUG", "Homing_Model_Ids: " + userParam.value.toString() + " ---- Type is:" + + userParam.value.getClass() , isDebugEnabled) + def modelIdLst = [] + userParam.value.each { + param -> + def valueMap = [:] + param.each { + entry -> + valueMap.put(entry.key, entry.value) + } + modelIdLst.add(valueMap) + utils.log("DEBUG", "Param: " + param.toString() + " ---- Type is:" + + param.getClass() , isDebugEnabled) + } + execution.setVariable("homingModelIds", modelIdLst) + } + if ("BRG_WAN_MAC_Address".equals(userParam?.name)) { + execution.setVariable("brgWanMacAddress", userParam.value) + inputMap.put("BRG_WAN_MAC_Address", userParam.value) + } + if ("Homing_Solution".equals(userParam?.name)) { + execution.setVariable("homingService", userParam.value) + inputMap.put("Homing_Solution", userParam.value) + } + } + } + + if (execution.getVariable("homingService") == "") { + // Set Default Homing to OOF if not set + execution.setVariable("homingService", "oof") + } + + msoLogger.debug("User Input Parameters map: " + userParams.toString()) + execution.setVariable("serviceInputParams", inputMap) + + msoLogger.debug("Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress')) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable(Prefix + "requestInfo", requestInfo) + + msoLogger.trace("Completed preProcessRequest CreateVcpeResCustService Request ") + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + msoLogger.trace("Inside sendSyncResponse of CreateVcpeResCustService ") + + 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() + + msoLogger.debug(" sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareDecomposeService(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + try { + msoLogger.trace("Inside prepareDecomposeService of CreateVcpeResCustService ") + + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + + //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB + String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.modelInfo") + execution.setVariable("serviceModelInfo", serviceModelInfo) + + msoLogger.trace("Completed prepareDecomposeService of CreateVcpeResCustService ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareCreateServiceInstance(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + try { + msoLogger.trace("Inside prepareCreateServiceInstance of CreateVcpeResCustService ") + + /* + * 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 createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") +// String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters") +// execution.setVariable("serviceInputParams", serviceInputParams) + + + String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName") + execution.setVariable("serviceInstanceName", serviceInstanceName) + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonStringNoRootName()) + + msoLogger.trace("Completed prepareCreateServiceInstance of CreateVcpeResCustService ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void postProcessServiceInstanceCreate(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' + 'execution=' + execution.getId() + ')' + def isDebugLogEnabled = execution.getVariable(DebugFlag) + msoLogger.trace('Entered ' + method) + + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + + try { + + String payload = """ + + + + + ${MsoUtils.xmlEscape(requestId)} + BPEL + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceInstanceName)} + + + + """ + execution.setVariable(Prefix + "setUpdateDbInstancePayload", payload) + msoLogger.debug(Prefix + "setUpdateDbInstancePayload: " + payload) + msoLogger.trace('Exited ' + method) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + } + + + public void processDecomposition(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + msoLogger.trace("Inside processDecomposition() of CreateVcpeResCustService ") + + try { + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + // VNFs + List vnfList = serviceDecomposition.getVnfResources() + filterVnfs(vnfList) + serviceDecomposition.setVnfResources(vnfList) + + execution.setVariable("vnfList", vnfList) + execution.setVariable("vnfListString", vnfList.toString()) + + String vnfModelInfoString = "" + if (vnfList != null && vnfList.size() > 0) { + execution.setVariable(Prefix + "VNFsCount", vnfList.size()) + msoLogger.debug("vnfs to create: " + vnfList.size()) + ModelInfo vnfModelInfo = vnfList[0].getModelInfo() + + vnfModelInfoString = vnfModelInfo.toString() + String vnfModelInfoWithRoot = vnfModelInfo.toString() + vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") + } else { + execution.setVariable(Prefix + "VNFsCount", 0) + msoLogger.debug("no vnfs to create based upon serviceDecomposition content") + } + + execution.setVariable("vnfModelInfo", vnfModelInfoString) + execution.setVariable("vnfModelInfoString", vnfModelInfoString) + msoLogger.debug(" vnfModelInfoString :" + vnfModelInfoString) + + msoLogger.trace("Completed processDecomposition() of CreateVcpeResCustService ") + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. processDecomposition() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + private void filterVnfs(List vnfList) { + if (vnfList == null) { + return + } + + // remove BRG & TXC from VNF list + + Iterator it = vnfList.iterator() + while (it.hasNext()) { + VnfResource vr = it.next() + + String role = vr.getNfRole() + if (role == "BRG" || role == "TunnelXConn" || role == "Tunnel XConn") { + it.remove() + } + } + } + + + public void prepareCreateAllottedResourceTXC(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + try { + msoLogger.trace("Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ") + + /* + * 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 createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + //allottedResourceModelInfo + //allottedResourceRole + //The model Info parameters are a JSON structure as defined in the Service Instantiation API. + //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB. + List allottedResources = serviceDecomposition.getAllottedResources() + if (allottedResources != null) { + Iterator iter = allottedResources.iterator(); + while (iter.hasNext()) { + AllottedResource allottedResource = (AllottedResource) iter.next(); + + msoLogger.debug(" getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName()) + msoLogger.debug(" allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType()) + if ("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType()) || "Tunnel XConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())) { + //set create flag to true + execution.setVariable("createTXCAR", true) + ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() + execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonStringNoRootName()) + execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole()) + execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType()) + //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the TXC, + //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing BB would have populated). + execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId()) + } + } + } + + //unit test only + String allottedResourceId = execution.getVariable("allottedResourceId") + execution.setVariable("allottedResourceIdTXC", allottedResourceId) + msoLogger.debug("setting allottedResourceId CreateVcpeResCustService " + allottedResourceId) + + msoLogger.trace("Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareCreateAllottedResourceBRG(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + try { + msoLogger.trace("Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ") + + /* + * 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 createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + //allottedResourceModelInfo + //allottedResourceRole + //The model Info parameters are a JSON structure as defined in the Service Instantiation API. + //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB. + List allottedResources = serviceDecomposition.getAllottedResources() + if (allottedResources != null) { + Iterator iter = allottedResources.iterator(); + while (iter.hasNext()) { + AllottedResource allottedResource = (AllottedResource) iter.next(); + + msoLogger.debug(" getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName()) + msoLogger.debug(" allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType()) + if ("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())) { + //set create flag to true + execution.setVariable("createBRGAR", true) + ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() + execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonStringNoRootName()) + execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole()) + execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType()) + //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG, + //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing BB would have populated). + execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId()) + } + } + } + + //unit test only + String allottedResourceId = execution.getVariable("allottedResourceId") + execution.setVariable("allottedResourceIdBRG", allottedResourceId) + msoLogger.debug("setting allottedResourceId CreateVcpeResCustService " + allottedResourceId) + + msoLogger.trace("Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareVnfAndModulesCreate(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + try { + msoLogger.trace("Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ") + + // String disableRollback = execution.getVariable("disableRollback") + // def backoutOnFailure = "" + // if(disableRollback != null){ + // if ( disableRollback == true) { + // backoutOnFailure = "false" + // } else if ( disableRollback == false) { + // backoutOnFailure = "true" + // } + // } + //failIfExists - optional + + String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") + String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + msoLogger.debug("productFamilyId: " + productFamilyId) + + List vnfList = execution.getVariable("vnfList") + + Integer vnfsCreatedCount = execution.getVariable(Prefix + "VnfsCreatedCount") + String vnfModelInfoString = null; + + if (vnfList != null && vnfList.size() > 0) { + msoLogger.debug("getting model info for vnf # " + vnfsCreatedCount) + ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo() + msoLogger.debug("got 0 ") + ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo() + vnfModelInfoString = vnfModelInfo.toString() + } else { + //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored + vnfModelInfoString = execution.getVariable("vnfModelInfo") + } + + msoLogger.debug(" vnfModelInfoString :" + vnfModelInfoString) + + // extract cloud configuration + String vimId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.cloudConfiguration.lcpCloudRegionId") + def cloudRegion = vimId.split("_") + execution.setVariable("cloudOwner", cloudRegion[0]) + msoLogger.debug("cloudOwner: "+ cloudRegion[0]) + execution.setVariable("cloudRegionId", cloudRegion[1]) + msoLogger.debug("cloudRegionId: "+ cloudRegion[1]) + execution.setVariable("lcpCloudRegionId", cloudRegion[1]) + msoLogger.debug("lcpCloudRegionId: "+ cloudRegion[1]) + String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, + "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + msoLogger.debug("tenantId: " + tenantId) + + String sdncVersion = execution.getVariable("sdncVersion") + msoLogger.debug("sdncVersion: " + sdncVersion) + + msoLogger.trace("Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfCreate(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + try { + msoLogger.trace("Inside validateVnfCreate of CreateVcpeResCustService ") + + Integer vnfsCreatedCount = execution.getVariable(Prefix + "VnfsCreatedCount") + vnfsCreatedCount++ + + execution.setVariable(Prefix + "VnfsCreatedCount", vnfsCreatedCount) + + msoLogger.debug(" ***** Completed validateVnfCreate of CreateVcpeResCustService ***** " + " vnf # " + vnfsCreatedCount) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + msoLogger.trace("Inside postProcessResponse of CreateVcpeResCustService ") + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + CREATE + ${MsoUtils.xmlEscape(source)} + + Service Instance has been created successfully via macro orchestration + ${MsoUtils.xmlEscape(serviceInstanceId)} + BPMN macro create + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + msoLogger.debug(xmlMsoCompletionRequest) + execution.setVariable(Prefix + "Success", true) + execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + msoLogger.debug(" SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void preProcessRollback(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + msoLogger.trace("preProcessRollback of CreateVcpeResCustService ") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch (Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit preProcessRollback of CreateVcpeResCustService ") + } + + public void postProcessRollback(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + msoLogger.trace("postProcessRollback of CreateVcpeResCustService ") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch (Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("Exit postProcessRollback of CreateVcpeResCustService ") + } + + public void prepareFalloutRequest(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + + msoLogger.trace("STARTED CreateVcpeResCustService prepareFalloutRequest Process ") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug(" Incoming Workflow Exception: " + wfex.toString()) + String requestInfo = execution.getVariable(Prefix + "requestInfo") + msoLogger.debug(" Incoming Request Info: " + requestInfo) + + //TODO. hmmm. there is no way to UPDATE error message. +// String errorMessage = wfex.getErrorMessage() +// boolean successIndicator = execution.getVariable("DCRESI_rolledBack") +// if (successIndicator){ +// errorMessage = errorMessage + ". Rollback successful." +// } else { +// errorMessage = errorMessage + ". Rollback not completed." +// } + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable(Prefix + "falloutRequest", falloutRequest) + + } catch (Exception ex) { + msoLogger.debug("Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process") + } + msoLogger.trace("COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ") + } + + + public void sendSyncError(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + execution.setVariable("prefix", Prefix) + + msoLogger.trace("Inside sendSyncError() of CreateVcpeResCustService ") + + try { + String errorMessage = "" + def wfe = execution.getVariable("WorkflowException") + if (wfe instanceof WorkflowException) { + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + } catch (Exception ex) { + msoLogger.debug(" Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + } + + public void processJavaException(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable(DebugFlag) + execution.setVariable("prefix", Prefix) + try { + msoLogger.debug("Caught a Java Exception") + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable(Prefix + "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) { + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + throw b + } catch (Exception e) { + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable(Prefix + "unexpectedError", "Exception in processJavaException method") + // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") + } + msoLogger.debug("Completed processJavaException Method") + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy new file mode 100644 index 0000000000..eaf3631441 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -0,0 +1,461 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.vcpe.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.NetworkUtils +import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse + +import static org.apache.commons.lang3.StringUtils.isBlank + + +/** + * This groovy class supports the DeleteVcpeResCustService.bpmn process. + * + * @author dm4252 + * + */ +public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteVcpeResCustService.class); + + private static final String DebugFlag = "isDebugLogEnabled" + + String Prefix = "DVRCS_" + 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 DeleteVcpeResCustService.bpmn process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable("DeleteVcpeResCustServiceRequest", "") + execution.setVariable("msoRequestId", "") + execution.setVariable(Prefix+"vnfsDeletedCount", 0) + execution.setVariable(Prefix+"vnfsCount", 0) + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + execution.setVariable("prefix",Prefix) + + msoLogger.trace("Inside preProcessRequest DeleteVcpeResCustService Request ") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // check for incoming json message/input + String DeleteVcpeResCustServiceRequest = execution.getVariable("bpmnRequest") + msoLogger.debug(DeleteVcpeResCustServiceRequest) + execution.setVariable("DeleteVcpeResCustServiceRequest", DeleteVcpeResCustServiceRequest); + println 'DeleteVcpeResCustServiceRequest - ' + DeleteVcpeResCustServiceRequest + + // 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(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + source = "VID" + } + execution.setVariable("source", source) + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") + + // global-customer-id is optional on Delete + + execution.setVariable("globalSubscriberId", globalSubscriberId) + execution.setVariable("globalCustomerId", globalSubscriberId) + + String suppressRollback = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + msoLogger.debug("Incoming Suppress/Disable Rollback is: " + suppressRollback) + + String productFamilyId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + msoLogger.debug("Incoming productFamilyId is: " + productFamilyId) + + // extract subscriptionServiceType + String subscriptionServiceType = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + msoLogger.debug("Incoming subscriptionServiceType is: " + subscriptionServiceType) + + // extract cloud configuration + String cloudConfiguration = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration") + execution.setVariable("cloudConfiguration", cloudConfiguration) + msoLogger.debug("cloudConfiguration: "+ cloudConfiguration) + String lcpCloudRegionId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + msoLogger.debug("lcpCloudRegionId: "+ lcpCloudRegionId) + String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") + execution.setVariable("tenantId", tenantId) + msoLogger.debug("tenantId: "+ tenantId) + + String sdncVersion = "1707" + execution.setVariable("sdncVersion", sdncVersion) + msoLogger.debug("sdncVersion: "+ sdncVersion) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + """ + + execution.setVariable(Prefix+"requestInfo", requestInfo) + + //Setting for Generic Sub Flows + execution.setVariable("GENGS_type", "service-instance") + + msoLogger.trace("Completed preProcessRequest DeleteVcpeResCustServiceRequest Request ") + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + + msoLogger.trace("Inside sendSyncResponse of DeleteVcpeResCustService ") + + 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() + + msoLogger.debug(" sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + sendWorkflowResponse(execution, 202, syncResponse) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareServiceDelete(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + msoLogger.trace("Inside prepareServiceDelete() of DeleteVcpeResCustService ") + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // confirm if ServiceInstance was found + if ( !execution.getVariable("GENGS_FoundIndicator") ) + { + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + // get variable within incoming json + String DeleteVcpeResCustServiceRequest = execution.getVariable("DeleteVcpeResCustServiceRequest"); + + // get SI extracted by GenericGetService + String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); + + msoLogger.debug("serviceInstanceAaiRecord: "+serviceInstanceAaiRecord) + serviceInstanceAaiRecord = utils.removeXmlNamespaces(serviceInstanceAaiRecord) + + def (TXC_found, TXC_id) = new Tuple(false, null) + def (BRG_found, BRG_id) = new Tuple(false, null) + List relatedVnfIdList = [] + + for(Node rel: utils.getMultNodeObjects(serviceInstanceAaiRecord, "relationship")) { + def relto = utils.getChildNodeText(rel, "related-to") + def relink = utils.getChildNodeText(rel, "related-link") + msoLogger.debug("check: "+relto+" link: "+relink) + + if(isBlank(relto) || isBlank(relink)) { + + } else if(relto == "generic-vnf") { + def id = relink.substring(relink.indexOf("/generic-vnf/")+13) + if(id.endsWith("/")) { + id = id.substring(0, id.length()-1) + } + + relatedVnfIdList.add(id) + + } else if(relto == "allotted-resource") { + def (type, id) = getAaiAr(execution, relink) + + if(isBlank(type) || isBlank(id)) { + + } else if(type == "TunnelXConn" || type == "Tunnel XConn") { + msoLogger.debug("TunnelXConn AR found") + TXC_found = true + TXC_id = id + + } else if(type == "BRG") { + msoLogger.debug("BRG AR found") + BRG_found = true + BRG_id = id + } + } + } + + execution.setVariable(Prefix+"TunnelXConn", TXC_found) + execution.setVariable("TXC_allottedResourceId", TXC_id) + msoLogger.debug("TXC_allottedResourceId: " + TXC_id) + + execution.setVariable(Prefix+"BRG", BRG_found) + execution.setVariable("BRG_allottedResourceId", BRG_id) + msoLogger.debug("BRG_allottedResourceId: " + BRG_id) + + int vnfsCount = relatedVnfIdList.size() + execution.setVariable(Prefix+"vnfsCount", vnfsCount) + msoLogger.debug(" "+Prefix+"vnfsCount : " + vnfsCount) + if(vnfsCount > 0) { + execution.setVariable(Prefix+"relatedVnfIdList", relatedVnfIdList) + } + + msoLogger.trace("Completed prepareServiceDelete() of DeleteVcpeResCustService ") + } catch (BpmnError e){ + throw e; + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. prepareServiceDelete() - " + ex.getMessage() + msoLogger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + private getAaiAr(DelegateExecution execution, String relink) { + def isDebugEnabled = execution.getVariable(DebugFlag) + AaiUtil aaiUtil = new AaiUtil(this) + String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + relink + + msoLogger.debug("get AR info " + aaiEndpoint) + APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint) + + int responseCode = response.getStatusCode() + msoLogger.debug("get AR info responseCode:" + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + msoLogger.debug("get AR info " + aaiResponse) + + if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) { + return new Tuple2(null, null) + } + + def type = utils.getNodeText(aaiResponse, "type") + def id = utils.getNodeText(aaiResponse, "id") + + return new Tuple2(type, id) + } + + + // ******************************* + // + // ******************************* + public void prepareVnfAndModulesDelete (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + msoLogger.trace("Inside prepareVnfAndModulesDelete of DeleteVcpeResCustService ") + + try { + List vnfList = execution.getVariable(Prefix+"relatedVnfIdList") + int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount") + String vnfModelInfoString = "" + String vnfId = "" + if (vnfList.size() > 0 ) { + vnfId = vnfList.get(vnfsDeletedCount.intValue()) + } + + execution.setVariable("vnfId", vnfId) + msoLogger.debug("need to delete vnfId:" + vnfId) + + msoLogger.trace("Completed prepareVnfAndModulesDelete of DeleteVcpeResCustService ") + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfDelete (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + msoLogger.trace("Inside validateVnfDelete of DeleteVcpeResCustService ") + + try { + int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount") + vnfsDeletedCount++ + + execution.setVariable(Prefix+"vnfsDeletedCount", vnfsDeletedCount) + + msoLogger.debug(" ***** Completed validateVnfDelete of DeleteVcpeResCustService ***** "+" vnf # "+vnfsDeletedCount) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + msoLogger.trace("Inside postProcessResponse of DeleteVcpeResCustService ") + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("msoRequestId") + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + DELETE + ${MsoUtils.xmlEscape(source)} + + vCPE Res Cust Service Instance has been deleted successfully. + BPMN Service Instance macro action: DELETE + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + msoLogger.debug(xmlMsoCompletionRequest) + execution.setVariable(Prefix+"Success", true) + execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest) + msoLogger.debug(" SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest) + } 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(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable(DebugFlag) + msoLogger.trace("STARTED DeleteVcpeResCustService prepareFalloutRequest Process ") + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + msoLogger.debug(" Incoming Workflow Exception: " + wfex.toString()) + String requestInfo = execution.getVariable(Prefix+"requestInfo") + msoLogger.debug(" Incoming Request Info: " + requestInfo) + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable(Prefix+"falloutRequest", falloutRequest) + } catch (Exception ex) { + msoLogger.debug("Error Occured in DeleteVcpeResCustService prepareFalloutRequest Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVcpeResCustService prepareFalloutRequest Process") + } + msoLogger.trace("COMPLETED DeleteVcpeResCustService prepareFalloutRequest Process ") + } + + + public void sendSyncError (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) + msoLogger.trace("Inside sendSyncError() of DeleteVcpeResCustService ") + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${MsoUtils.xmlEscape(errorMessage)} + 7000 + """ + + msoLogger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + } catch (Exception ex) { + msoLogger.debug(" Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + } + + public void processJavaException(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable(DebugFlag) + execution.setVariable("prefix",Prefix) + try{ + msoLogger.debug("Caught a Java Exception") + msoLogger.debug("Started processJavaException Method") + msoLogger.debug("Variables List: " + execution.getVariables()) + execution.setVariable(Prefix+"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){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + throw b + }catch(Exception e){ + msoLogger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") + } + msoLogger.debug("Completed processJavaException Method") + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy new file mode 100644 index 0000000000..8a8aa2b2ad --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -0,0 +1,678 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import org.onap.so.bpmn.common.scripts.*; +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoCreateAllottedResourceBRG.bpmn process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDEbugLogEnabled + * @param - disableRollback + * @param - failExists - O + * @param - serviceInstanceId + * @param - globalCustomerId - O + * @param - subscriptionServiceType - O + * @param - parentServiceInstanceId + * @param - allottedReourceId - O + * @param - allottedResourceModelInfo + * @param - allottedResourceRole + * @param - allottedResourceType + * @param - brgWanMacAddress + * @param - vni + * @param - vgmuxBearerIP + * + * Outputs: + * @param - rollbackData (localRB->null) + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * @param - WorkflowException - O + * @param - allottedResourceId + * @param - allottedResourceName + * + */ +public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateAllottedResourceBRG.class); + + String Prefix="DCARBRG_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessRequest") + + try { + execution.setVariable("prefix", Prefix) + + //Config Inputs + String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (isBlank(sdncCallbackUrl)) { + msg = "mso.workflow.sdncadapter.callback is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + + String sdncReplDelay = UrnPropertiesReader.getVariable("mso.workflow.sdnc.replication.delay",execution) + if (isBlank(sdncReplDelay)) { + msg = "mso.workflow.sdnc.replication.delay is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncReplDelay", sdncReplDelay) + msoLogger.debug("SDNC replication delay: " + sdncReplDelay) + + //Request Inputs + if (isBlank(execution.getVariable("serviceInstanceId"))){ + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("parentServiceInstanceId"))) { + msg = "Input parentServiceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceModelInfo"))) { + msg = "Input allottedResourceModelInfo is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("vni"))) { + msg = "Input vni is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("vgmuxBearerIP"))) { + msg = "Input vgmuxBearerIP is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("brgWanMacAddress"))) { + msg = "Input brgWanMacAddress is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceRole"))) { + msg = "Input allottedResourceRole is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceType"))) { + msg = "Input allottedResourceType is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessRequest") + } + + public void getAaiAR (DelegateExecution execution) { + + + msoLogger.trace("start getAaiAR") + + String arType = execution.getVariable("allottedResourceType") + String arRole = execution.getVariable("allottedResourceRole") + + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String orchStatus = arUtils.getAROrchStatus(execution) + + String errorMsg = "" + + if (orchStatus != null) // AR was found + { + if ("true".equals(execution.getVariable("failExists"))) + { + errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists" + } + else + { + if ("Active".equals(orchStatus)) + { + execution.setVariable("foundActiveAR", true) + } + else // blanks included + { + errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus + } + } + } + if (!isBlank(errorMsg)) { + msoLogger.debug(errorMsg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) + } + msoLogger.trace("end getAaiAR") + } + + public void createAaiAR(DelegateExecution execution) { + + + msoLogger.trace("start createAaiAR") + String msg = "" + + String allottedResourceId = execution.getVariable("allottedResourceId") + if (isBlank(allottedResourceId)) + { + allottedResourceId = UUID.randomUUID().toString() + execution.setVariable("allottedResourceId", allottedResourceId) + } + String arUrl = "" + try { + + //AAI PUT + AaiUtil aaiUriUtil = new AaiUtil(this) + String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + String siResourceLink= execution.getVariable("PSI_resourceLink") + + String siUri = "" + msoLogger.debug("PSI_resourceLink:" + siResourceLink) + + if(!isBlank(siResourceLink)) { + msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink) + String[] split = siResourceLink.split("/aai/") + siUri = "/aai/" + split[1] + } + else + { + msg = "Parent Service Link in AAI is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + execution.setVariable("aaiARPath", arUrl) + msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl) + + String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) + + String arType = execution.getVariable("allottedResourceType") + String arRole = execution.getVariable("allottedResourceRole") + String CSI_resourceLink = execution.getVariable("CSI_resourceLink") + String arModelInfo = execution.getVariable("allottedResourceModelInfo") + String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") + String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") + String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") + + if (modelInvariantId == null) { + modelInvariantId = "" + } + if (modelVersionId == null) { + modelVersionId = "" + } + if (modelCustomizationId == null) { + modelCustomizationId = "" + } + + String payload = + """ + ${MsoUtils.xmlEscape(allottedResourceId)} + + ${MsoUtils.xmlEscape(arType)} + ${MsoUtils.xmlEscape(arRole)} + + ${MsoUtils.xmlEscape(modelInvariantId)} + ${MsoUtils.xmlEscape(modelVersionId)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + PendingCreate + + + + service-instance + ${MsoUtils.xmlEscape(CSI_resourceLink)} + + + """.trim() + + execution.setVariable("AaiARPayload", payload) + msoLogger.debug(" payload to create AllottedResource in AAI:" + "\n" + payload) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload) + int responseCode = response.getStatusCode() + msoLogger.debug("AllottedResource AAI PUT responseCode:" + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + msoLogger.debug("AllottedResource AAI PUT responseStr:" + aaiResponse) + + //200 OK 201 CREATED 202 ACCEPTED + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + { + msoLogger.debug("AAI PUT AllottedResource received a Good Response") + } + else{ + msoLogger.debug("AAI Put AllottedResouce received a Bad Response Code: " + responseCode) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex) { + msg = "Exception in createAaiAR " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put(Prefix, "disableRollback", disableRollback.toString()) + rollbackData.put(Prefix, "rollbackAAI", "true") + rollbackData.put(Prefix, "allottedResourceId", allottedResourceId) + rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId")) + rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId")) + rollbackData.put(Prefix, "aaiARPath", arUrl) + execution.setVariable("rollbackData", rollbackData) + msoLogger.trace("end createAaiAR") + } + + public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { + + + String msg = "" + msoLogger.trace("start buildSDNCRequest") + String sdncReq = null + + try { + + String allottedResourceId = execution.getVariable("allottedResourceId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String globalCustomerId = execution.getVariable("globalCustomerId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") + String callbackUrl = execution.getVariable("sdncCallbackUrl") + String requestId = execution.getVariable("msoRequestId") + + String brgWanMacAddress = execution.getVariable("brgWanMacAddress") + String vni = execution.getVariable("vni") + String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP") + + String arModelInfo = execution.getVariable("allottedResourceModelInfo") + String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") + String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion") + String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") + String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") + String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName") + + if (modelInvariantId == null) { + modelInvariantId = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUUId == null) { + modelUUId = "" + } + if (modelName == null) { + modelName = "" + } + if (modelCustomizationId == null) { + modelCustomizationId = "" + } + + sdncReq = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(action)} + brg-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + CreateBRGInstance + MSO + + + + + + + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalCustomerId)} + + + ${MsoUtils.xmlEscape(allottedResourceId)} + brg + ${MsoUtils.xmlEscape(parentServiceInstanceId)} + + ${MsoUtils.xmlEscape(modelInvariantId)} + ${MsoUtils.xmlEscape(modelUUId)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + ${MsoUtils.xmlEscape(brgWanMacAddress)} + ${MsoUtils.xmlEscape(vni)} + ${MsoUtils.xmlEscape(vgmuxBearerIP)} + + + """ + + msoLogger.debug("sdncRequest:\n" + sdncReq) + sdncReq = utils.formatXml(sdncReq) + + } catch(Exception ex) { + msg = "Exception in buildSDNCRequest. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end buildSDNCRequest") + return sdncReq + } + + public void preProcessSDNCAssign(DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessSDNCAssign") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId) + execution.setVariable("sdncAssignRequest", sdncAssignReq) + msoLogger.debug("sdncAssignRequest: " + sdncAssignReq) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("sdncAssignRollbackReq:\n" + sdncAssignRollbackReq) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCAssign. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCAssign") + } + + public void preProcessSDNCCreate(DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessSDNCCreate") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId) + execution.setVariable("sdncCreateRequest", sdncCreateReq) + msoLogger.debug("sdncCreateReq: " + sdncCreateReq) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("sdncCreateRollbackReq:\n" + sdncCreateRollbackReq) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCCreate. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCCreate") + } + + public void preProcessSDNCActivate(DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessSDNCActivate") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId) + execution.setVariable("sdncActivateRequest", sdncActivateReq) + msoLogger.debug("sdncActivateReq: " + sdncActivateReq) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("sdncActivateRollbackReq:\n" + sdncActivateRollbackReq) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCActivate. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCActivate") + } + + public void validateSDNCResp(DelegateExecution execution, String response, String method){ + + + msoLogger.trace("ValidateSDNCResponse Process") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response) + + if (!"get".equals(method)) + { + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true") + execution.setVariable("rollbackData", rollbackData) + } + + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in validateSDNCResp. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("End ValidateSDNCResp Process") + } + + public void preProcessSDNCGet(DelegateExecution execution){ + + msoLogger.trace("start preProcessSDNCGet") + try{ + + def callbackUrl = execution.getVariable("sdncCallbackUrl") + // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI + // or from "object-path" in SDNC response for assign when AR does not exist in AA + + String serviceOperation = "" + + if (execution.getVariable("foundActiveAR")) { + def aaiQueryResponse = execution.getVariable("aaiARGetResponse") + serviceOperation = utils.getNodeText(aaiQueryResponse, "selflink") + msoLogger.debug("AR service operation/aaiARSelfLink: " + serviceOperation) + } + else + { + String response = execution.getVariable("sdncAssignResponse") + String data = utils.getNodeXml(response, "response-data") + msoLogger.debug("Assign responseData: " + data) + serviceOperation = utils.getNodeText(data, "object-path") + msoLogger.debug("AR service operation:" + serviceOperation) + } + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String sdncRequestId = UUID.randomUUID().toString() + + //neeed the same url as used by vfmodules + String SDNCGetRequest = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + query + ${MsoUtils.xmlEscape(serviceOperation)} + ${MsoUtils.xmlEscape(callbackUrl)} + vfmodule + + + """ + + execution.setVariable("sdncGetRequest", SDNCGetRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage()) + } + msoLogger.trace("end preProcessSDNCGet") + } + + public void updateAaiAROrchStatus(DelegateExecution execution, String status){ + + msoLogger.trace("start updateAaiAROrchStatus") + String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) + msoLogger.trace("end updateAaiAROrchStatus") + } + + public void generateOutputs(DelegateExecution execution) + { + + msoLogger.trace("start generateOutputs") + try { + String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped + msoLogger.debug("resp:" + sdncGetResponse) + String arData = utils.getNodeXml(sdncGetResponse, "brg-topology") + arData = utils.removeXmlNamespaces(arData) + + String brga = utils.getNodeXml(arData, "brg-assignments") + String ari = utils.getNodeXml(arData, "allotted-resource-identifiers") + execution.setVariable("allotedResourceName", utils.getNodeText(ari, "allotted-resource-name")) + } catch (BpmnError e) { + msoLogger.debug("BPMN Error in generateOutputs ") + } catch(Exception ex) { + String msg = "Exception in generateOutputs " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("end generateOutputs") + + } + + public void preProcessRollback (DelegateExecution execution) { + + msoLogger.trace("start preProcessRollback") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("end preProcessRollback") + } + + public void postProcessRollback (DelegateExecution execution) { + + msoLogger.trace("start postProcessRollback") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("end postProcessRollback") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy new file mode 100644 index 0000000000..4d4f11c3e5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy @@ -0,0 +1,279 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import org.onap.so.bpmn.common.scripts.*; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the CreateAllottedResourceBRGRollback.bpmn process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDebugLogEnabled + * @param - disableRollback - O + * @param - rollbackData + * + * Outputs: + * @param - rollbackError + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * + */ +public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateAllottedResourceBRGRollback.class); + + String Prefix="DCARBRGRB_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void preProcessRequest (DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessRequest") + execution.setVariable("prefix", Prefix) + String rbType = "DCARBRG_" + try { + + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("RollbackData:" + rollbackData) + + if (rollbackData != null) { + if (rollbackData.hasType(rbType)) { + + execution.setVariable("serviceInstanceId", rollbackData.get(rbType, "serviceInstanceId")) + execution.setVariable("parentServiceInstanceId", rollbackData.get(rbType, "parentServiceInstanceId")) + execution.setVariable("allottedResourceId", rollbackData.get("SERVICEINSTANCE", "allottedResourceId")) + + + def rollbackAAI = rollbackData.get(rbType, "rollbackAAI") + if ("true".equals(rollbackAAI)) + { + execution.setVariable("rollbackAAI",true) + execution.setVariable("aaiARPath", rollbackData.get(rbType, "aaiARPath")) + + } + def rollbackSDNC = rollbackData.get(rbType, "rollbackSDNCassign") + if ("true".equals(rollbackSDNC)) + { + execution.setVariable("rollbackSDNC", true) + execution.setVariable("deactivateSdnc", rollbackData.get(rbType, "rollbackSDNCactivate")) + execution.setVariable("deleteSdnc", rollbackData.get(rbType, "rollbackSDNCcreate")) + execution.setVariable("unassignSdnc", rollbackData.get(rbType, "rollbackSDNCassign")) + + msoLogger.debug("sdncDeactivate:\n" + execution.getVariable("deactivateSdnc") ) + msoLogger.debug("sdncDelete:\n" + execution.getVariable("deleteSdnc")) + msoLogger.debug("sdncUnassign:\n" + execution.getVariable("unassignSdnc")) + + execution.setVariable("sdncDeactivateRequest", rollbackData.get(rbType, "sdncActivateRollbackReq")) + execution.setVariable("sdncDeleteRequest", rollbackData.get(rbType, "sdncCreateRollbackReq")) + execution.setVariable("sdncUnassignRequest", rollbackData.get(rbType, "sdncAssignRollbackReq")) + } + + if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true) + { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessRequest") + } + + // aaiARPath set during query (existing AR) + public void updateAaiAROrchStatus(DelegateExecution execution, String status){ + + String msg = null; + msoLogger.trace("start updateAaiAROrchStatus") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String aaiARPath = execution.getVariable("aaiARPath") + msoLogger.debug(" aaiARPath:" + aaiARPath) + String ar = null; //need this for getting resourceVersion for delete + if (!isBlank(aaiARPath)) + { + ar = arUtils.getARbyLink(execution, aaiARPath, "") + } + if (isBlank(ar)) + { + msg = "AR not found in AAI at:" + aaiARPath + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) + msoLogger.trace("end updateAaiAROrchStatus") + } + + public void validateSDNCResp(DelegateExecution execution, String response, String method){ + + + msoLogger.trace("start ValidateSDNCResponse Process") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response) + + }else{ + + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + if ("404".contentEquals(e.getErrorCode())) + { + msg = "SDNC rollback " + method + " returned a 404. Proceding with rollback" + msoLogger.debug(msg) + } + else { + throw e; + } + } catch(Exception ex) { + msg = "Exception in validateSDNCResp. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end ValidateSDNCResp Process") + } + + public void deleteAaiAR(DelegateExecution execution){ + + try{ + msoLogger.trace("start deleteAaiAR") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String ar = null //need to get resource-version + String arLink = execution.getVariable("aaiARPath") + if (!isBlank(arLink)) + { + ar = arUtils.getARbyLink(execution, arLink, "") + } + arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) + } catch (BpmnError e) { + throw e; + }catch(Exception ex){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) + } + msoLogger.trace("end deleteAaiAR") + } + + public void postProcessRequest(DelegateExecution execution) { + + msoLogger.trace("start postProcessRequest") + String msg = "" + try { + execution.setVariable("rollbackData", null) + boolean skipRollback = execution.getVariable("skipRollback") + if (skipRollback != true) + { + execution.setVariable("rolledBack", true) + msoLogger.debug("rolledBack") + } + msoLogger.trace("end postProcessRequest") + + } catch (BpmnError e) { + msg = "Bpmn Exception in postProcessRequest. " + msoLogger.debug(msg) + } catch (Exception ex) { + msg = "Exception in postProcessRequest. " + ex.getMessage() + msoLogger.debug(msg) + } + + } + + public void processRollbackException(DelegateExecution execution){ + + msoLogger.trace("start processRollbackException") + try{ + msoLogger.debug("Caught an Exception in DoCreateAllottedResourceRollback") + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + execution.setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") + execution.setVariable("WorkflowException", null) + + }catch(BpmnError b){ + msoLogger.debug("BPMN Error during processRollbackExceptions Method: ") + }catch(Exception e){ + msoLogger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage()) + } + + msoLogger.trace("end processRollbackException") + } + + public void processRollbackJavaException(DelegateExecution execution){ + + msoLogger.trace("start processRollbackJavaException") + try{ + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + execution.setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") + msoLogger.debug("Caught Exception in processRollbackJavaException") + + }catch(Exception e){ + msoLogger.debug("Caught Exception in processRollbackJavaException " + e.getMessage()) + } + msoLogger.trace("end processRollbackJavaException") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy new file mode 100644 index 0000000000..5f9b4b8ecd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -0,0 +1,674 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import org.onap.so.bpmn.common.scripts.*; +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoCreateAllottedResourceTXC.bpmn process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDEbugLogEnabled + * @param - disableRollback + * @param - failExists - O + * @param - serviceInstanceId + * @param - globalCustomerId - O + * @param - subscriptionServiceType - O + * @param - parentServiceInstanceId + * @param - allottedReourceId - O + * @param - allottedResourceModelInfo + * @param - allottedResourceRole + * @param - allottedResourceType + * @param - brgWanMacAddress + * + * Outputs: + * @param - rollbackData (localRB->null) + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * @param - WorkflowException - O + * @param - allottedResourceId + * @param - allottedResourceName + * @param - vni + * @param - vgmuxBearerIP + * @param - vgmuxLanIP + * + */ +public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateAllottedResourceTXC.class); + + String Prefix="DCARTXC_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void preProcessRequest (DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessRequest") + + try { + String msoRequestId = execution.getVariable("msoRequestId") + msoLogger.debug(" msoRequestId = " + msoRequestId) + + execution.setVariable("prefix", Prefix) + + //Config Inputs + String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (isBlank(sdncCallbackUrl)) { + msg = "mso.workflow.sdncadapter.callback is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + + String sdncReplDelay = UrnPropertiesReader.getVariable("mso.workflow.sdnc.replication.delay",execution) + if (isBlank(sdncReplDelay)) { + msg = "mso.workflow.sdnc.replication.delay is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncReplDelay", sdncReplDelay) + msoLogger.debug("SDNC replication delay: " + sdncReplDelay) + + //Request Inputs + if (isBlank(execution.getVariable("serviceInstanceId"))){ + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("parentServiceInstanceId"))) { + msg = "Input parentServiceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceModelInfo"))) { + msg = "Input allottedResourceModelInfo is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("brgWanMacAddress"))) { + msg = "Input brgWanMacAddress is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceRole"))) { + msg = "Input allottedResourceRole is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceType"))) { + msg = "Input allottedResourceType is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessRequest") + } + + public void getAaiAR (DelegateExecution execution) { + + + msoLogger.trace("start getAaiAR") + + String arType = execution.getVariable("allottedResourceType") + String arRole = execution.getVariable("allottedResourceRole") + + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String orchStatus = arUtils.getAROrchStatus(execution) + + String errorMsg = "" + + if (orchStatus != null) // AR was found + { + if ("true".equals(execution.getVariable("failExists"))) + { + errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists" + } + else + { + if ("Active".equals(orchStatus)) + { + execution.setVariable("foundActiveAR", true) + } + else // blanks included + { + errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus + } + } + } + if (!isBlank(errorMsg)) { + msoLogger.debug(errorMsg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) + } + msoLogger.trace("end getAaiAR") + } + + public void createAaiAR(DelegateExecution execution) { + + + msoLogger.trace("start createAaiAR") + String msg = "" + + String allottedResourceId = execution.getVariable("allottedResourceId") + if (isBlank(allottedResourceId)) + { + allottedResourceId = UUID.randomUUID().toString() + execution.setVariable("allottedResourceId", allottedResourceId) + } + String arUrl = "" + try { + + //AAI PUT + AaiUtil aaiUriUtil = new AaiUtil(this) + String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + String siResourceLink= execution.getVariable("PSI_resourceLink") + + String siUri = "" + msoLogger.debug("PSI_resourceLink:" + siResourceLink) + + if(!isBlank(siResourceLink)) { + msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink) + String[] split = siResourceLink.split("/aai/") + siUri = "/aai/" + split[1] + } + else + { + msg = "Parent Service Link in AAI is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + execution.setVariable("aaiARPath", arUrl) + msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl) + + String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) + + String arType = execution.getVariable("allottedResourceType") + String arRole = execution.getVariable("allottedResourceRole") + String CSI_resourceLink = execution.getVariable("CSI_resourceLink") + String arModelInfo = execution.getVariable("allottedResourceModelInfo") + msoLogger.debug("arModelInfo is:\n" + arModelInfo) + String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") + String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") + String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") + + if (modelInvariantId == null) { + modelInvariantId = "" + } + if (modelVersionId == null) { + modelVersionId = "" + } + if (modelCustomizationId == null) { + modelCustomizationId = "" + } + + String payload = + """ + ${MsoUtils.xmlEscape(allottedResourceId)} + + ${MsoUtils.xmlEscape(arType)} + ${MsoUtils.xmlEscape(arRole)} + + ${MsoUtils.xmlEscape(modelInvariantId)} + ${MsoUtils.xmlEscape(modelVersionId)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + PendingCreate + + + + service-instance + ${MsoUtils.xmlEscape(CSI_resourceLink)} + + + """.trim() + + execution.setVariable("AaiARPayload", payload) + msoLogger.debug(" payload to create AllottedResource in AAI:" + "\n" + payload) + + APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload) + int responseCode = response.getStatusCode() + msoLogger.debug("AllottedResource AAI PUT responseCode:" + responseCode) + + String aaiResponse = response.getResponseBodyAsString() + msoLogger.debug("AllottedResource AAI PUT responseStr:" + aaiResponse) + + //200 OK 201 CREATED 202 ACCEPTED + if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) + { + msoLogger.debug("AAI PUT AllottedResource received a Good Response") + } + else{ + msoLogger.debug("AAI Put AllottedResouce received a Bad Response Code: " + responseCode) + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + throw new BpmnError("MSOWorkflowException") + } + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex) { + msg = "Exception in createAaiAR " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put(Prefix, "disableRollback", disableRollback.toString()) + rollbackData.put(Prefix, "rollbackAAI", "true") + rollbackData.put(Prefix, "allottedResourceId", allottedResourceId) + rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId")) + rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId")) + rollbackData.put(Prefix, "aaiARPath", arUrl) + execution.setVariable("rollbackData", rollbackData) + msoLogger.trace("end createAaiAR") + } + + public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { + + + String msg = "" + msoLogger.trace("start buildSDNCRequest") + String sdncReq = null + + try { + + String allottedResourceId = execution.getVariable("allottedResourceId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String globalCustomerId = execution.getVariable("globalCustomerId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") + String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId") + String callbackUrl = execution.getVariable("sdncCallbackUrl") + String requestId = execution.getVariable("msoRequestId") + + String brgWanMacAddress = execution.getVariable("brgWanMacAddress") + + String arModelInfo = execution.getVariable("allottedResourceModelInfo") + String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") + String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion") + String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") + String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") + String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName") + + if (modelInvariantId == null) { + modelInvariantId = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUUId == null) { + modelUUId = "" + } + if (modelName == null) { + modelName = "" + } + if (modelCustomizationId == null) { + modelCustomizationId = "" + } + + sdncReq = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(action)} + tunnelxconn-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + CreateTunnelXConnInstance + MSO + + + + + + + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalCustomerId)} + + + ${MsoUtils.xmlEscape(allottedResourceId)} + tunnelxconn + ${MsoUtils.xmlEscape(parentServiceInstanceId)} + + ${MsoUtils.xmlEscape(modelInvariantId)} + ${MsoUtils.xmlEscape(modelUUId)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + ${MsoUtils.xmlEscape(brgWanMacAddress)} + + + """ + + msoLogger.debug("sdncRequest:\n" + sdncReq) + sdncReq = utils.formatXml(sdncReq) + + } catch(Exception ex) { + msg = "Exception in buildSDNCRequest. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end buildSDNCRequest") + return sdncReq + } + + public void preProcessSDNCAssign(DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessSDNCAssign") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId) + execution.setVariable("sdncAssignRequest", sdncAssignReq) + msoLogger.debug("sdncAssignRequest: " + sdncAssignReq) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("sdncAssignRollbackReq:\n" + sdncAssignRollbackReq) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCAssign. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.debug("end preProcessSDNCAssign") + } + + public void preProcessSDNCCreate(DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessSDNCCreate") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId) + execution.setVariable("sdncCreateRequest", sdncCreateReq) + msoLogger.debug("sdncCreateReq: " + sdncCreateReq) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("sdncCreateRollbackReq:\n" + sdncCreateRollbackReq) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCCreate. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCCreate") + } + + public void preProcessSDNCActivate(DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessSDNCActivate") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId) + execution.setVariable("sdncActivateRequest", sdncActivateReq) + msoLogger.debug("sdncActivateReq: " + sdncActivateReq) + def sdncRequestId2 = UUID.randomUUID().toString() + String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq) + execution.setVariable("rollbackData", rollbackData) + + msoLogger.debug("sdncActivateRollbackReq:\n" + sdncActivateRollbackReq) + msoLogger.debug("rollbackData:\n" + rollbackData.toString()) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCActivate. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCActivate") + } + + public void validateSDNCResp(DelegateExecution execution, String response, String method){ + + + msoLogger.trace("start ValidateSDNCResponse Process") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response) + + if (!"get".equals(method)) + { + def rollbackData = execution.getVariable("rollbackData") + rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true") + execution.setVariable("rollbackData", rollbackData) + } + + }else{ + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in validateSDNCResp. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end ValidateSDNCResp Process") + } + + public void preProcessSDNCGet(DelegateExecution execution){ + + msoLogger.trace("start preProcessSDNCGet") + try{ + + def callbackUrl = execution.getVariable("sdncCallbackUrl") + // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI + // or from "object-path" in SDNC response for assign when AR does not exist in AA + + String serviceOperation = "" + + if (execution.getVariable("foundActiveAR")) { + def aaiQueryResponse = execution.getVariable("aaiARGetResponse") + serviceOperation = utils.getNodeText(aaiQueryResponse, "selflink") + msoLogger.debug("AR service operation/aaiARSelfLink: " + serviceOperation) + } + else + { + String response = execution.getVariable("sdncAssignResponse") + String data = utils.getNodeXml(response, "response-data") + msoLogger.debug("Assign responseData: " + data) + serviceOperation = utils.getNodeText(data, "object-path") + msoLogger.debug("AR service operation:" + serviceOperation) + } + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String sdncRequestId = UUID.randomUUID().toString() + + //neeed the same url as used by vfmodules + String SDNCGetRequest = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + query + ${MsoUtils.xmlEscape(serviceOperation)} + ${MsoUtils.xmlEscape(callbackUrl)} + vfmodule + + + """ + + execution.setVariable("sdncGetRequest", SDNCGetRequest) + + }catch(Exception e){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage()) + } + msoLogger.trace("end preProcessSDNCGet") + } + + public void updateAaiAROrchStatus(DelegateExecution execution, String status){ + + msoLogger.trace("start updateAaiAROrchStatus") + String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) + msoLogger.trace("end updateAaiAROrchStatus") + } + + public void generateOutputs(DelegateExecution execution) + { + + msoLogger.trace("start generateOutputs") + try { + String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped + msoLogger.debug("resp:" + sdncGetResponse) + String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology") + arData = utils.removeXmlNamespaces(arData) + + String txca = utils.getNodeXml(arData, "tunnelxconn-assignments") + execution.setVariable("vni", utils.getNodeText(txca, "vni")) + execution.setVariable("vgmuxBearerIP", utils.getNodeText(txca, "vgmux-bearer-ip")) + execution.setVariable("vgmuxLanIP", utils.getNodeText(txca, "vgmux-lan-ip")) + + String ari = utils.getNodeXml(arData, "allotted-resource-identifiers") + execution.setVariable("allotedResourceName", utils.getNodeText(ari, "allotted-resource-name")) + } catch (BpmnError e) { + msoLogger.debug("BPMN Error in generateOutputs ") + } catch(Exception ex) { + String msg = "Exception in generateOutputs " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("end generateOutputs") + + } + + public void preProcessRollback (DelegateExecution execution) { + + msoLogger.trace("start preProcessRollback") + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage()) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + msoLogger.debug("BPMN Error during preProcessRollback") + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("end preProcessRollback") + } + + public void postProcessRollback (DelegateExecution execution) { + + msoLogger.trace("start postProcessRollback") + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + msoLogger.debug("Setting prevException to WorkflowException: ") + execution.setVariable("WorkflowException", workflowException); + } + execution.setVariable("rollbackData", null) + } catch (BpmnError b) { + msoLogger.debug("BPMN Error during postProcessRollback") + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + msoLogger.debug(msg) + } + msoLogger.trace("end postProcessRollback") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy new file mode 100644 index 0000000000..24b919524f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy @@ -0,0 +1,278 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import org.onap.so.bpmn.common.scripts.*; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the CreateAllottedResourceTXCRollback.bpmn process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDebugLogEnabled + * @param - disableRollback - O + * @param - rollbackData + * + * Outputs: + * @param - rollbackError + * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) + * + */ +public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateAllottedResourceTXCRollback.class); + + String Prefix="DCARTXCRB_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void preProcessRequest (DelegateExecution execution) { + + + String msg = "" + msoLogger.trace("start preProcessRequest") + execution.setVariable("prefix", Prefix) + String rbType = "DCARTXC_" + try { + + def rollbackData = execution.getVariable("rollbackData") + msoLogger.debug("RollbackData:" + rollbackData) + + if (rollbackData != null) { + if (rollbackData.hasType(rbType)) { + + execution.setVariable("serviceInstanceId", rollbackData.get(rbType, "serviceInstanceId")) + execution.setVariable("parentServiceInstanceId", rollbackData.get(rbType, "parentServiceInstanceId")) + execution.setVariable("allottedResourceId", rollbackData.get("SERVICEINSTANCE", "allottedResourceId")) + + + def rollbackAAI = rollbackData.get(rbType, "rollbackAAI") + if ("true".equals(rollbackAAI)) + { + execution.setVariable("rollbackAAI",true) + execution.setVariable("aaiARPath", rollbackData.get(rbType, "aaiARPath")) + + } + def rollbackSDNC = rollbackData.get(rbType, "rollbackSDNCassign") + if ("true".equals(rollbackSDNC)) + { + execution.setVariable("rollbackSDNC", true) + execution.setVariable("deactivateSdnc", rollbackData.get(rbType, "rollbackSDNCactivate")) + execution.setVariable("deleteSdnc", rollbackData.get(rbType, "rollbackSDNCcreate")) + execution.setVariable("unassignSdnc", rollbackData.get(rbType, "rollbackSDNCassign")) + + msoLogger.debug("sdncDeactivate:\n" + execution.getVariable("deactivateSdnc") ) + msoLogger.debug("sdncDelete:\n" + execution.getVariable("deleteSdnc")) + msoLogger.debug("sdncUnassign:\n" + execution.getVariable("unassignSdnc")) + + execution.setVariable("sdncDeactivateRequest", rollbackData.get(rbType, "sdncActivateRollbackReq")) + execution.setVariable("sdncDeleteRequest", rollbackData.get(rbType, "sdncCreateRollbackReq")) + execution.setVariable("sdncUnassignRequest", rollbackData.get(rbType, "sdncAssignRollbackReq")) + } + + if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true) + { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + } + else { + execution.setVariable("skipRollback", true) + } + if (execution.getVariable("disableRollback").equals("true" )) + { + execution.setVariable("skipRollback", true) + } + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessRequest") + } + + // aaiARPath set during query (existing AR) + public void updateAaiAROrchStatus(DelegateExecution execution, String status){ + + String msg = null; + msoLogger.trace("start updateAaiAROrchStatus") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String aaiARPath = execution.getVariable("aaiARPath") + msoLogger.debug(" aaiARPath:" + aaiARPath) + String ar = null; //need this for getting resourceVersion for delete + if (!isBlank(aaiARPath)) + { + ar = arUtils.getARbyLink(execution, aaiARPath, "") + } + if (isBlank(ar)) + { + msg = "AR not found in AAI at:" + aaiARPath + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) + msoLogger.trace("end updateAaiAROrchStatus") + } + + public void validateSDNCResp(DelegateExecution execution, String response, String method){ + + + msoLogger.trace("start ValidateSDNCResponse Process") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response) + + }else{ + + msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + } catch (BpmnError e) { + if ("404".contentEquals(e.getErrorCode())) + { + msg = "SDNC rollback " + method + " returned a 404. Proceding with rollback" + msoLogger.debug(msg) + } + else { + throw e; + } + } catch(Exception ex) { + msg = "Exception in validateSDNCResp. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("Exit ValidateSDNCResp Process") + } + + public void deleteAaiAR(DelegateExecution execution){ + + try{ + msoLogger.trace("start deleteAaiAR") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String ar = null //need to get resource-version + String arLink = execution.getVariable("aaiARPath") + if (!isBlank(arLink)) + { + ar = arUtils.getARbyLink(execution, arLink, "") + } + arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) + } catch (BpmnError e) { + throw e; + }catch(Exception ex){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) + } + msoLogger.trace("end deleteAaiAR") + } + + public void postProcessRequest(DelegateExecution execution) { + + msoLogger.trace("start postProcessRequest") + String msg = "" + try { + execution.setVariable("rollbackData", null) + boolean skipRollback = execution.getVariable("skipRollback") + if (skipRollback != true) + { + execution.setVariable("rolledBack", true) + msoLogger.debug("rolledBack") + } + msoLogger.trace("end postProcessRequest") + + } catch (BpmnError e) { + msoLogger.debug(msg) + } catch (Exception ex) { + msg = "Exception in postProcessRequest. " + ex.getMessage() + msoLogger.debug(msg) + } + + } + + public void processRollbackException(DelegateExecution execution){ + + msoLogger.trace("start processRollbackException") + try{ + msoLogger.debug("Caught an Exception in DoCreateAllottedResourceRollback") + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + execution.setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") + execution.setVariable("WorkflowException", null) + + }catch(BpmnError b){ + msoLogger.debug("BPMN Error during processRollbackExceptions Method: ") + }catch(Exception e){ + msoLogger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage()) + } + + msoLogger.trace("end processRollbackException") + } + + public void processRollbackJavaException(DelegateExecution execution){ + + msoLogger.trace("start processRollbackJavaException") + try{ + execution.setVariable("rollbackData", null) + execution.setVariable("rolledBack", false) + execution.setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") + msoLogger.debug("Caught Exception in processRollbackJavaException") + + }catch(Exception e){ + msoLogger.debug("Caught Exception in processRollbackJavaException " + e.getMessage()) + } + msoLogger.trace("end processRollbackJavaException") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy new file mode 100644 index 0000000000..a5125fea73 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy @@ -0,0 +1,368 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import org.onap.so.bpmn.common.scripts.*; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* +import org.onap.so.bpmn.core.UrnPropertiesReader; + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoDeleteAllottedResourceBRG.bpmn process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDebugLogEnabled + * @param - disableRollback - O ignored + * @param - failNotfound - O + * @param - serviceInstanceId + * @param - globalCustomerId - O + * @param - subscriptionServiceType - O + * @param - parentServiceInstanceId + * @param - allottedResourceId + * + * Outputs: + * @param - rollbackData - N/A + * @param - rolledBack - true if no deletions performed + * @param - WorkflowException - O + * @param - wasDeleted - O (ie not silentSuccess) + * + */ +public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteAllottedResourceBRG.class); + + String Prefix="DDARBRG_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void preProcessRequest (DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessRequest") + + try { + execution.setVariable("prefix", Prefix) + + //Config Inputs + String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (isBlank(sdncCallbackUrl)) { + msg = "mso.workflow.sdncadapter.callback is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + + //Request Inputs + if (isBlank(execution.getVariable("serviceInstanceId"))){ + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceId"))){ + msg = "Input allottedResourceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessRequest") + } + + public void getAaiAR (DelegateExecution execution) { + + msoLogger.trace("start getAaiAR end") + + String allottedResourceId = execution.getVariable("allottedResourceId") + + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String ar = arUtils.getARbyId(execution, allottedResourceId) + + String errorMsg = "" + if (isBlank(ar)) // AR was !found + { + errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId + } + else + { + String aaiARPath = execution.getVariable("aaiARPath") + String parentServiceInstanceId = arUtils.getPSIFmARLink(execution, aaiARPath) + execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) + } + if (!isBlank(errorMsg)) { + msoLogger.debug(errorMsg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) + } + msoLogger.trace("end getAaiAR") + + } + + // aaiARPath set during query (existing AR) + public void updateAaiAROrchStatus(DelegateExecution execution, String status){ + msoLogger.trace("start updateAaiAROrchStatus") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) + String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) + msoLogger.trace("end updateAaiAROrchStatus") + } + + public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { + + String msg = "" + msoLogger.trace("start buildSDNCRequest") + String sdncReq = null + + try { + + String allottedResourceId = execution.getVariable("allottedResourceId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") + String globalCustomerId = execution.getVariable("globalCustomerId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + String callbackUrl = execution.getVariable("sdncCallbackUrl") + String requestId = execution.getVariable("msoRequestId") + + String serviceChainServiceInstanceId = "" + String sourceNetworkId = "" + String sourceNetworkRole = "" + String allottedResourceRole = "" + + String arModelInfo = "" + String modelInvariantId = "" + String modelVersion = "" + String modelUUId = "" + String modelCustomizationId = "" + String modelName = "" + + + sdncReq = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(action)} + brg-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + DeleteBRGInstance + MSO + + + + + + + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalCustomerId)} + + + ${MsoUtils.xmlEscape(allottedResourceId)} + brg + ${MsoUtils.xmlEscape(parentServiceInstanceId)} + + ${MsoUtils.xmlEscape(modelInvariantId)} + ${MsoUtils.xmlEscape(modelUUId)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + + + """ + + msoLogger.debug("sdncRequest:\n" + sdncReq) + sdncReq = utils.formatXml(sdncReq) + + } catch(Exception ex) { + msg = "Exception in buildSDNCRequest. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end buildSDNCRequest") + return sdncReq + } + + public void preProcessSDNCUnassign(DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessSDNCUnassign") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncUnassignReq = buildSDNCRequest(execution, "unassign", sdncRequestId) + execution.setVariable("sdncUnassignRequest", sdncUnassignReq) + msoLogger.debug("sdncUnassignRequest: " + sdncUnassignReq) + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCUnassign. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCUnassign") + } + + public void preProcessSDNCDelete(DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessSDNCDelete") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncDeleteReq = buildSDNCRequest(execution, "delete", sdncRequestId) + execution.setVariable("sdncDeleteRequest", sdncDeleteReq) + msoLogger.debug("sdncDeleteReq: " + sdncDeleteReq) + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCDelete") + } + + public void preProcessSDNCDeactivate(DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessSDNCDeactivate") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncDeactivateReq = buildSDNCRequest(execution, "deactivate", sdncRequestId) + execution.setVariable("sdncDeactivateRequest", sdncDeactivateReq) + msoLogger.debug("sdncDeactivateReq: " + sdncDeactivateReq) + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDeactivate. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCDeactivate") + } + + public void validateSDNCResp(DelegateExecution execution, String response, String method){ + + msoLogger.trace("start ValidateSDNCResponse Process") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response) + + }else{ + String sdncRespCode = execution.getVariable(Prefix + 'sdncRequestDataResponseCode') + msoLogger.debug(method + " AllottedResource received error response from SDNC. ResponseCode:" + sdncRespCode) + if (sdncRespCode.equals("404") && "deactivate".equals(method)) + { + execution.setVariable("ARNotFoundInSDNC", true) + if ("true".equals(execution.getVariable("failNotFound"))) + { + msg = "Allotted Resource Not found in SDNC" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + else + { + execution.setVariable("wasDeleted", false) + } + } + else + { + throw new BpmnError("MSOWorkflowException") + } + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in validateSDNCResp. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end ValidateSDNCResp Process") + } + + public void deleteAaiAR(DelegateExecution execution){ + msoLogger.trace("start deleteAaiAR") + + try{ + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String ar = null //need to get resource-version again + String arLink = execution.getVariable("aaiARPath") + if (!isBlank(arLink)) + { + ar = arUtils.getARbyLink(execution, arLink, "") + } + arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) + } catch (BpmnError e) { + throw e; + }catch(Exception ex){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest." + ex, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:" + ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) + } + msoLogger.trace("end deleteAaiAR") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy new file mode 100644 index 0000000000..7ce606e685 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy @@ -0,0 +1,369 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import org.onap.so.bpmn.common.scripts.*; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.AaiUtil +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.rest.APIResponse + +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.apache.commons.lang3.* +import org.springframework.web.util.UriUtils; +import static org.apache.commons.lang3.StringUtils.* +import org.onap.so.bpmn.core.UrnPropertiesReader; + +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger + +/** + * This groovy class supports the DoDeleteAllottedResourceTXC.bpmn process. + * + * @author + * + * Inputs: + * @param - msoRequestId + * @param - isDebugLogEnabled + * @param - disableRollback - O ignored + * @param - failNotfound - O + * @param - serviceInstanceId + * @param - globalCustomerId - O + * @param - subscriptionServiceType - O + * @param - parentServiceInstanceId + * @param - allottedResourceId + * + * Outputs: + * @param - rollbackData - N/A + * @param - rolledBack - true if no deletions performed + * @param - WorkflowException - O + * @param - wasDeleted - O (ie not silentSuccess) + * + */ +public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteAllottedResourceTXC.class); + + String Prefix="DDARTXC_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void preProcessRequest (DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessRequest") + + try { + execution.setVariable("prefix", Prefix) + + //Config Inputs + String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (isBlank(sdncCallbackUrl)) { + msg = "mso.workflow.sdncadapter.callback is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl) + + //Request Inputs + if (isBlank(execution.getVariable("serviceInstanceId"))){ + msg = "Input serviceInstanceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + if (isBlank(execution.getVariable("allottedResourceId"))){ + msg = "Input allottedResourceId is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + + }catch(BpmnError b){ + msoLogger.debug("Rethrowing MSOWorkflowException") + throw b + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessRequest") + } + + public void getAaiAR (DelegateExecution execution) { + + msoLogger.trace("start getAaiAR") + + String allottedResourceId = execution.getVariable("allottedResourceId") + + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String ar = arUtils.getARbyId(execution, allottedResourceId) + + String errorMsg = "" + if (isBlank(ar)) // AR was !found + { + errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId + } + else + { + String aaiARPath = execution.getVariable("aaiARPath") + String parentServiceInstanceId = arUtils.getPSIFmARLink(execution, aaiARPath) + execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) + } + if (!isBlank(errorMsg)) { + msoLogger.debug(errorMsg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) + } + msoLogger.trace("end getAaiAR") + + } + + // aaiARPath set during query (existing AR) + public void updateAaiAROrchStatus(DelegateExecution execution, String status){ + msoLogger.trace("start updateAaiAROrchStatus") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) + String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) + msoLogger.trace("end updateAaiAROrchStatus") + } + + public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { + + String msg = "" + msoLogger.trace("start buildSDNCRequest") + String sdncReq = null + + try { + + String allottedResourceId = execution.getVariable("allottedResourceId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") + String globalCustomerId = execution.getVariable("globalCustomerId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + String callbackUrl = execution.getVariable("sdncCallbackUrl") + String requestId = execution.getVariable("msoRequestId") + + String serviceChainServiceInstanceId = "" + String sourceNetworkId = "" + String sourceNetworkRole = "" + String allottedResourceRole = "" + + String arModelInfo = "" + String modelInvariantId = "" + String modelVersion = "" + String modelUUId = "" + String modelCustomizationId = "" + String modelName = "" + + + sdncReq = + """ + + ${MsoUtils.xmlEscape(sdncRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(action)} + tunnelxconn-topology-operation + ${MsoUtils.xmlEscape(callbackUrl)} + + + + ${MsoUtils.xmlEscape(requestId)} + DeleteTunnelXConnInstance + MSO + + + + + + + ${MsoUtils.xmlEscape(subscriptionServiceType)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + + ${MsoUtils.xmlEscape(globalCustomerId)} + + + ${MsoUtils.xmlEscape(allottedResourceId)} + tunnelxconn + ${MsoUtils.xmlEscape(parentServiceInstanceId)} + + ${MsoUtils.xmlEscape(modelInvariantId)} + ${MsoUtils.xmlEscape(modelUUId)} + ${MsoUtils.xmlEscape(modelCustomizationId)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + + + """ + + msoLogger.debug("sdncRequest:\n" + sdncReq) + sdncReq = utils.formatXml(sdncReq) + + } catch(Exception ex) { + msg = "Exception in buildSDNCRequest. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end buildSDNCRequest") + return sdncReq + } + + public void preProcessSDNCUnassign(DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessSDNCUnassign") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncUnassignReq = buildSDNCRequest(execution, "unassign", sdncRequestId) + execution.setVariable("sdncUnassignRequest", sdncUnassignReq) + msoLogger.debug("sdncUnassignRequest: " + sdncUnassignReq) + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCUnassign. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCUnassign") + } + + public void preProcessSDNCDelete(DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessSDNCDelete") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncDeleteReq = buildSDNCRequest(execution, "delete", sdncRequestId) + execution.setVariable("sdncDeleteRequest", sdncDeleteReq) + msoLogger.debug("sdncDeleteReq: " + sdncDeleteReq) + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCDelete") + } + + public void preProcessSDNCDeactivate(DelegateExecution execution) { + + String msg = "" + msoLogger.trace("start preProcessSDNCDeactivate") + + try { + String sdncRequestId = UUID.randomUUID().toString() + String sdncDeactivateReq = buildSDNCRequest(execution, "deactivate", sdncRequestId) + execution.setVariable("sdncDeactivateRequest", sdncDeactivateReq) + msoLogger.debug("sdncDeactivateReq: " + sdncDeactivateReq) + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDeactivate. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end preProcessSDNCDeactivate") + } + + public void validateSDNCResp(DelegateExecution execution, String response, String method){ + + msoLogger.trace("start ValidateSDNCResponse Process") + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + msoLogger.debug("workflowException: " + workflowException) + + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + msoLogger.debug("SDNCResponse: " + response) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response) + + }else{ + String sdncRespCode = execution.getVariable(Prefix + 'sdncRequestDataResponseCode') + msoLogger.debug(method + " AllottedResource received error response from SDNC. ResponseCode:" + sdncRespCode) + if (sdncRespCode.equals("404") && "deactivate".equals(method)) + { + execution.setVariable("ARNotFoundInSDNC", true) + if ("true".equals(execution.getVariable("failNotFound"))) + { + msg = "Allotted Resource Not found in SDNC" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + else + { + execution.setVariable("wasDeleted", false) + } + } + else + { + throw new BpmnError("MSOWorkflowException") + } + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in validateSDNCResp. " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.trace("end Exit ValidateSDNCResp Process") + } + + public void deleteAaiAR(DelegateExecution execution){ + msoLogger.trace("start deleteAaiAR") + + try{ + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + String ar = null //need to get resource-version again + String arLink = execution.getVariable("aaiARPath") + if (!isBlank(arLink)) + { + ar = arUtils.getARbyLink(execution, arLink, "") + } + arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) + } catch (BpmnError e) { + throw e; + }catch(Exception ex){ + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) + } + msoLogger.trace("end deleteAaiAR") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/META-INF/processes.xml b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/META-INF/processes.xml new file mode 100644 index 0000000000..13a24c8b8b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/META-INF/processes.xml @@ -0,0 +1,37 @@ + + + + + + + + + false + true + + 06:00 + 09:00 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CompareModelofE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CompareModelofE2EServiceInstance.bpmn new file mode 100644 index 0000000000..086171ec98 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CompareModelofE2EServiceInstance.bpmn @@ -0,0 +1,335 @@ + + + + + SequenceFlow_0s2spoq + + + + SequenceFlow_1dsbjjb + SequenceFlow_1yay321 + + + + SequenceFlow_1dsbjjb + + + + SequenceFlow_1yay321 + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0tm7z1o + SequenceFlow_0klbpxx + + + SequenceFlow_0yayvrf + + + SequenceFlow_0s2spoq + SequenceFlow_0tm7z1o + + + + + SequenceFlow_0e1r62n + + + + SequenceFlow_1ysapam + + + SequenceFlow_0n9pexp + SequenceFlow_01umodj + + + + + + + + + + + + SequenceFlow_01umodj + SequenceFlow_1ysapam + + + SequenceFlow_0e1r62n + SequenceFlow_0n9pexp + + + + + + + + + SequenceFlow_0klbpxx + SequenceFlow_12jdmq5 + + + + SequenceFlow_12jdmq5 + SequenceFlow_1fueo69 + SequenceFlow_0y8s0kd + + + SequenceFlow_1fueo69 + + + + + + + + + + + + + + + + + + SequenceFlow_0a01ez6 + SequenceFlow_0yayvrf + + + + + SequenceFlow_0y8s0kd + SequenceFlow_0a01ez6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn new file mode 100644 index 0000000000..8f2bf67b71 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn @@ -0,0 +1,325 @@ + + + + + + + + + + + + + + + + + + #{!aaiContainsInfoAboutPnf} + + + + + + + + + #{!aaiContainsInfoAboutIp} + + + #{aaiContainsInfoAboutPnf} + + + #{aaiContainsInfoAboutIp} + + + SequenceFlow_0p09qgm + + + SequenceFlow_1miyzfe + + + + SequenceFlow_1h6yz62 + + + SequenceFlow_0j5ksz1 + + + + SequenceFlow_0967g8p + SequenceFlow_1j4r3zt + + + SequenceFlow_1j4r3zt + SequenceFlow_1l1t6ak + SequenceFlow_0v5ffpe + + + SequenceFlow_0v5ffpe + SequenceFlow_1qr6cmf + + + SequenceFlow_1l1t6ak + SequenceFlow_1h6yz62 + SequenceFlow_1ls8pua + + + SequenceFlow_1qr6cmf + SequenceFlow_1ls8pua + SequenceFlow_17s9025 + + + SequenceFlow_17s9025 + SequenceFlow_1o8od8e + + + SequenceFlow_1o8od8e + SequenceFlow_0p09qgm + + + SequenceFlow_1kc34bc + + #{timeoutForPnfEntryNotification} + + + + SequenceFlow_1kc34bc + SequenceFlow_1miyzfe + + + SequenceFlow_0j5ksz1 + SequenceFlow_0967g8p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn new file mode 100644 index 0000000000..6f73b46e2e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn @@ -0,0 +1,391 @@ + + + + + SequenceFlow_0s2spoq + + + + SequenceFlow_1dsbjjb + SequenceFlow_1yay321 + + + + SequenceFlow_1dsbjjb + + + + SequenceFlow_1yay321 + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_19eilro + SequenceFlow_0klbpxx + + + SequenceFlow_0yayvrf + + + SequenceFlow_0s2spoq + SequenceFlow_0z4faf9 + + + + SequenceFlow_14zu6wr + SequenceFlow_0je30si + + + + + + + + + + + + SequenceFlow_0je30si + SequenceFlow_0yayvrf + + + + SequenceFlow_0e1r62n + + + + SequenceFlow_1ysapam + + + SequenceFlow_0n9pexp + SequenceFlow_01umodj + + + + + + + + + + + + SequenceFlow_01umodj + SequenceFlow_1ysapam + + + SequenceFlow_0e1r62n + SequenceFlow_0n9pexp + + + + + + + + + SequenceFlow_081z8l2 + SequenceFlow_19eilro + + + + SequenceFlow_0klbpxx + SequenceFlow_14zu6wr + SequenceFlow_1fueo69 + + + SequenceFlow_1fueo69 + + + + + + + + + + + + + + + + + SequenceFlow_0z4faf9 + SequenceFlow_1euqjsp + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1euqjsp + SequenceFlow_081z8l2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn new file mode 100644 index 0000000000..3d08fdb1d4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn @@ -0,0 +1,452 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + SequenceFlow_1hjh5zy + SequenceFlow_1lj31zp + + + SequenceFlow_095crcd + + + + SequenceFlow_0lp2z7l + SequenceFlow_0ktadna + + + + + SequenceFlow_1o4wwba + SequenceFlow_0xxvjxq + + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_14eadeb + SequenceFlow_1reso2f + + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + SequenceFlow_0n4umjf + SequenceFlow_14eadeb + + + + + + + SequenceFlow_0ktadna + SequenceFlow_16vhtu8 + + + + + SequenceFlow_1lj31zp + SequenceFlow_1o4wwba + SequenceFlow_1mdnv3l + + + SequenceFlow_1mdnv3l + + + + + + + + + + SequenceFlow_16vhtu8 + + + + + SequenceFlow_1tfe975 + + + + SequenceFlow_1hjh5zy + + + + SequenceFlow_14ajbme + + + + SequenceFlow_1tfe975 + SequenceFlow_0xhu1k3 + + + + + + + + + + + + SequenceFlow_0xhu1k3 + SequenceFlow_1o3ihrh + + + SequenceFlow_1o3ihrh + SequenceFlow_14ajbme + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn new file mode 100644 index 0000000000..9b21b9309f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn @@ -0,0 +1,340 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + SequenceFlow_1lj31zp + + + SequenceFlow_0x3znm5 + + + SequenceFlow_095crcd + SequenceFlow_0x3znm5 + + + + + + SequenceFlow_0lp2z7l + SequenceFlow_1ablr60 + + + + + + SequenceFlow_1lj31zp + SequenceFlow_0xxvjxq + + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_0n4umjf + SequenceFlow_1s5niqb + + + + SequenceFlow_1s5niqb + SequenceFlow_1reso2f + + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + + + + + + SequenceFlow_1ablr60 + SequenceFlow_0rt8wax + + + + SequenceFlow_0rt8wax + SequenceFlow_0eto8sn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn new file mode 100644 index 0000000000..29207131b6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn @@ -0,0 +1,287 @@ + + + + + SequenceFlow_1qo2pln + + + + + SequenceFlow_18l3crb + SequenceFlow_0khtova + import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new CreateSDNCNetworkResource() +dcsi.prepareSDNCRequest(execution) + + + SequenceFlow_0auvfvm + + + + + + + + + + + + + SequenceFlow_15mvedq + SequenceFlow_1ex9ov6 + + + SequenceFlow_1ex9ov6 + SequenceFlow_1kzj1j5 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new CreateSDNCNetworkResource() +dcsi.postCreateSDNCCall(execution) + + + + + SequenceFlow_1qo2pln + SequenceFlow_0w2es8j + String recipeParamXsdDemo="""{"operationType":"GRE"}""" +String recipeParamXsd="" +execution.setVariable("recipeParamXsd", recipeParamXsd) + + + SequenceFlow_0w2es8j + SequenceFlow_18l3crb + import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new CreateSDNCNetworkResource() +dcsi.preProcessRequest(execution) + + + + + SequenceFlow_0khtova + SequenceFlow_1mz0vdx + import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new CreateSDNCNetworkResource() +dcsi.prepareUpdateBeforeCreateSDNCResource(execution) + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1mz0vdx + SequenceFlow_15mvedq + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1kzj1j5 + SequenceFlow_0o7h0ag + + + SequenceFlow_1cd8ujq + SequenceFlow_0auvfvm + import org.onap.so.bpmn.infrastructure.scripts.* +def csi = new CreateSDNCNetworkResource() +csi.sendSyncResponse(execution) + + + SequenceFlow_0o7h0ag + SequenceFlow_1dww8ye + SequenceFlow_05m2j56 + + + #{(execution.getVariable("isActivateRequired") == "true")} + + + + + + SequenceFlow_05m2j56 + SequenceFlow_05niqbf + SequenceFlow_1cd8ujq + import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new CreateSDNCNetworkResource() +dcsi.prepareUpdateAfterCreateSDNCResource(execution) + + + + + + + SequenceFlow_1dww8ye + SequenceFlow_05niqbf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVFCNSResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVFCNSResource.bpmn new file mode 100644 index 0000000000..9724a9313d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVFCNSResource.bpmn @@ -0,0 +1,277 @@ + + + + + SequenceFlow_1qo2pln + + + + + + SequenceFlow_0khtova + SequenceFlow_1uiz85h + + + + SequenceFlow_1qo2pln + SequenceFlow_0khtova + + + + createNSSuccess_SequenceFlow + SequenceFlow_1ywe21t + + + + SequenceFlow_1uiz85h + createNSSuccess_SequenceFlow + createNSFailed_SequenceFlow + + + + + + + + + SequenceFlow_1ywe21t + instantiateFailed_SequenceFlow + instantiateSuccess_SequenceFlow + + + + + + + + + + SequenceFlow_0xqo13p + operationFinished_SequenceFlow + operationProcessing_SequenceFlow + + + + + + + + + + createNSFailed_SequenceFlow + + + instantiateFailed_SequenceFlow + + + SequenceFlow_1lwqmo9 + + + instantiateSuccess_SequenceFlow + SequenceFlow_1gsbpxj + SequenceFlow_0xqo13p + + + + operationFinished_SequenceFlow + SequenceFlow_0cq2q6g + + + + + operationProcessing_SequenceFlow + SequenceFlow_1gsbpxj + + + + + SequenceFlow_0cq2q6g + SequenceFlow_1lwqmo9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn new file mode 100644 index 0000000000..9ea6a9b5c4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn @@ -0,0 +1,1539 @@ + + + + + SequenceFlow_7 + SequenceFlow_3 + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + SequenceFlow_1eu60rt + + + + 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_0j6sjye + SequenceFlow_1ky2sv9 + + + SequenceFlow_3 + + + + + SequenceFlow_0zq7i3q + SequenceFlow_0zpbskl + SequenceFlow_0dhf2js + + + SequenceFlow_0zq7i3q + + + + SequenceFlow_0zpbskl + SequenceFlow_1sx5llu + SequenceFlow_02o4yqx + + + SequenceFlow_0t3mtod + SequenceFlow_19mxskt + SequenceFlow_1sl79hn + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_0jg47xm + SequenceFlow_0807ukc + + + + + + + + + + + + + + + + + + + + SequenceFlow_1a7e8l1 + SequenceFlow_1f1hd3l + + + SequenceFlow_1sx5llu + SequenceFlow_0dhf2js + SequenceFlow_1rabks0 + SequenceFlow_0jg47xm + + + + + + + SequenceFlow_19mxskt + SequenceFlow_17cz98f + SequenceFlow_0sezboq + SequenceFlow_1a7e8l1 + + + + + SequenceFlow_1f1hd3l + SequenceFlow_0sezboq + SequenceFlow_1mbymcu + SequenceFlow_00by7l7 + SequenceFlow_1lv5ld6 + + + SequenceFlow_02o4yqx + SequenceFlow_0ftzjjm + + + + SequenceFlow_0dvsqpp + SequenceFlow_1rabks0 + + + + + SequenceFlow_12dakwh + SequenceFlow_0orpdrl + SequenceFlow_0ya1cr3 + + + + + + + + + + SequenceFlow_0orpdrl + SequenceFlow_1t3cnnx + + + SequenceFlow_0ya1cr3 + SequenceFlow_1sim44y + SequenceFlow_027lz43 + + + + + + + + SequenceFlow_027lz43 + SequenceFlow_1kpdu1j + SequenceFlow_007p8k3 + + + SequenceFlow_1kpdu1j + SequenceFlow_1quvahv + SequenceFlow_0t3mtod + + + + SequenceFlow_1t3cnnx + SequenceFlow_1sim44y + SequenceFlow_0dr2fem + + + + + + + SequenceFlow_1mpsdaj + SequenceFlow_1quvahv + SequenceFlow_1mbymcu + + + + + + + SequenceFlow_0ftzjjm + SequenceFlow_12dakwh + SequenceFlow_09nn9a9 + + + + + SequenceFlow_1lv5ld6 + SequenceFlow_09nn9a9 + SequenceFlow_0dr2fem + SequenceFlow_0dvsqpp + + + + + + + + + + + + + + + + + SequenceFlow_1sl79hn + SequenceFlow_0ne9n0g + + + + + + SequenceFlow_0ne9n0g + SequenceFlow_00by7l7 + SequenceFlow_17cz98f + + + + + + + + + + + + + + + + + + SequenceFlow_007p8k3 + SequenceFlow_1mpsdaj + + + + + + + + SequenceFlow_15odbkz + SequenceFlow_0j6sjye + + + + SequenceFlow_12ilko1 + SequenceFlow_0afe2pg + + + + + + SequenceFlow_1jbuf1t + + + + + + + + + + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + + soap-http-connector + + + SequenceFlow_0vj46ej + SequenceFlow_0sjpja4 + + + SequenceFlow_1ky2sv9 + SequenceFlow_0vj46ej + + + + + + + + + + + + + + SequenceFlow_00h6hmd + SequenceFlow_17g05fd + + + SequenceFlow_1eu60rt + SequenceFlow_00h6hmd + + + + + + SequenceFlow_0x9pjgm + SequenceFlow_1kgaq0j + + + + SequenceFlow_0x9pjgm + + + + + SequenceFlow_1kgaq0j + SequenceFlow_0ofjahh + SequenceFlow_16qob4p + + + SequenceFlow_0ofjahh + SequenceFlow_1cgpklo + SequenceFlow_0o6tf9p + + + + + + + + SequenceFlow_15odbkz + + + + SequenceFlow_1db0ri1 + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_11efpvh + SequenceFlow_1jbuf1t + + + + + SequenceFlow_15vce9o + + + + SequenceFlow_0hwsm6n + + + + SequenceFlow_0yecpl2 + SequenceFlow_0loks1u + SequenceFlow_0b5ztoe + + + SequenceFlow_0loks1u + SequenceFlow_0e9e6fo + SequenceFlow_0hwsm6n + + + + + + + + SequenceFlow_15vce9o + SequenceFlow_0yecpl2 + + + + + + SequenceFlow_0o6tf9p + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0ws7fjn + SequenceFlow_1mkdhw9 + + + SequenceFlow_0p75l97 + SequenceFlow_0ws7fjn + + + + SequenceFlow_1ufio7c + + + + SequenceFlow_0aza7xq + + + + SequenceFlow_0aza7xq + SequenceFlow_0p75l97 + SequenceFlow_13iuk3s + + + SequenceFlow_13iuk3s + SequenceFlow_0k5vcuu + SequenceFlow_1ufio7c + + + + in 1702 scope only one VNF will be created + + + 0}]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_16qob4p + SequenceFlow_1cgpklo + + + + SequenceFlow_17g05fd + SequenceFlow_11efpvh + + + + + SequenceFlow_1mkdhw9 + SequenceFlow_0k5vcuu + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0b5ztoe + SequenceFlow_0e9e6fo + + + + SequenceFlow_0sjpja4 + SequenceFlow_1db0ri1 + + ${aaiDistDelay} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn new file mode 100644 index 0000000000..06c517c12d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn @@ -0,0 +1,1443 @@ + + + + + SequenceFlow_7 + SequenceFlow_3 + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + SequenceFlow_1eu60rt + + + + 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_0j6sjye + SequenceFlow_1ky2sv9 + + + SequenceFlow_3 + + + + + SequenceFlow_0zq7i3q + SequenceFlow_0zpbskl + SequenceFlow_0dhf2js + + + SequenceFlow_0zq7i3q + + + + SequenceFlow_0zpbskl + SequenceFlow_1sx5llu + SequenceFlow_02o4yqx + + + SequenceFlow_0t3mtod + SequenceFlow_19mxskt + SequenceFlow_1sl79hn + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_0jg47xm + SequenceFlow_0807ukc + + + + + + + + + + + + + + + + + + + + SequenceFlow_1a7e8l1 + SequenceFlow_1f1hd3l + + + SequenceFlow_1sx5llu + SequenceFlow_0dhf2js + SequenceFlow_1rabks0 + SequenceFlow_0jg47xm + + + + + + + SequenceFlow_19mxskt + SequenceFlow_17cz98f + SequenceFlow_0sezboq + SequenceFlow_1a7e8l1 + + + + + SequenceFlow_1f1hd3l + SequenceFlow_0sezboq + SequenceFlow_1mbymcu + SequenceFlow_00by7l7 + SequenceFlow_1lv5ld6 + + + SequenceFlow_02o4yqx + SequenceFlow_0ftzjjm + + + + SequenceFlow_0dvsqpp + SequenceFlow_1rabks0 + + + + + SequenceFlow_12dakwh + SequenceFlow_0orpdrl + SequenceFlow_0ya1cr3 + + + + + + + + + + SequenceFlow_0orpdrl + SequenceFlow_1t3cnnx + + + SequenceFlow_0ya1cr3 + SequenceFlow_1sim44y + SequenceFlow_027lz43 + + + + + + + + SequenceFlow_027lz43 + SequenceFlow_1kpdu1j + SequenceFlow_007p8k3 + + + SequenceFlow_1kpdu1j + SequenceFlow_1quvahv + SequenceFlow_0t3mtod + + + + SequenceFlow_1t3cnnx + SequenceFlow_1sim44y + SequenceFlow_0dr2fem + + + + + + + SequenceFlow_1mpsdaj + SequenceFlow_1quvahv + SequenceFlow_1mbymcu + + + + + + + SequenceFlow_0ftzjjm + SequenceFlow_12dakwh + SequenceFlow_09nn9a9 + + + + + SequenceFlow_1lv5ld6 + SequenceFlow_09nn9a9 + SequenceFlow_0dr2fem + SequenceFlow_0dvsqpp + + + + + + + + + + + + + + + + + SequenceFlow_1sl79hn + SequenceFlow_0ne9n0g + + + + + + SequenceFlow_0ne9n0g + SequenceFlow_00by7l7 + SequenceFlow_17cz98f + + + + + + + + + + + + + + + + + + SequenceFlow_007p8k3 + SequenceFlow_1mpsdaj + + + + + + + + SequenceFlow_15odbkz + SequenceFlow_0j6sjye + + + + SequenceFlow_12ilko1 + SequenceFlow_0afe2pg + + + + + + SequenceFlow_1jbuf1t + + + + + + + + ${URN_mso_adapters_db_endpoint} + + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + + soap-http-connector + + + SequenceFlow_0vj46ej + SequenceFlow_0sjpja4 + + + SequenceFlow_1ky2sv9 + SequenceFlow_0vj46ej + + + + + + + + + + + + + + SequenceFlow_00h6hmd + SequenceFlow_17g05fd + + + SequenceFlow_1eu60rt + SequenceFlow_00h6hmd + + + + + + SequenceFlow_0x9pjgm + SequenceFlow_1kgaq0j + + + + SequenceFlow_0x9pjgm + + + + + SequenceFlow_1kgaq0j + SequenceFlow_0ofjahh + SequenceFlow_16qob4p + + + SequenceFlow_0ofjahh + SequenceFlow_1cgpklo + SequenceFlow_0o6tf9p + + + + + + + + SequenceFlow_15odbkz + + + + SequenceFlow_1db0ri1 + + + + + + + + + + + + + + + + + + SequenceFlow_11efpvh + SequenceFlow_1jbuf1t + + + + + SequenceFlow_0gj4vud + + + + SequenceFlow_0clhseq + + + + SequenceFlow_0o6tf9p + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0ws7fjn + SequenceFlow_1mkdhw9 + + + SequenceFlow_0p75l97 + SequenceFlow_0ws7fjn + + + + SequenceFlow_1ufio7c + + + + SequenceFlow_0aza7xq + + + + SequenceFlow_0aza7xq + SequenceFlow_0p75l97 + SequenceFlow_13iuk3s + + + SequenceFlow_13iuk3s + SequenceFlow_0k5vcuu + SequenceFlow_1ufio7c + + + + in 1702 scope only one VNF will be created + + + 0}]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_16qob4p + SequenceFlow_1cgpklo + + + + SequenceFlow_17g05fd + SequenceFlow_11efpvh + + + + + SequenceFlow_1mkdhw9 + SequenceFlow_0k5vcuu + + + + + SequenceFlow_0sjpja4 + SequenceFlow_1db0ri1 + + ${aaiDistDelay} + + + + + + + + + + + + + SequenceFlow_0gj4vud + SequenceFlow_0clhseq + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn new file mode 100644 index 0000000000..eefc2ca12c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -0,0 +1,700 @@ + + + + + SequenceFlow_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1y7d5qk + SequenceFlow_1vx081s + SequenceFlow_4 + + + SequenceFlow_3 + SequenceFlow_1efipx3 + + + + SequenceFlow_4 + + + + + SequenceFlow_5 + + + + + SequenceFlow_5 + SequenceFlow_6 + + + + + + + + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + ${CVFMI_updateInfraRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_6 + SequenceFlow_1crl7uf + + + + SequenceFlow_0td7d9m + SequenceFlow_0u8zesf + SequenceFlow_12 + + + + + + + + + + + + + SequenceFlow_12 + SequenceFlow_14 + + + SequenceFlow_1crl7uf + updateInfraRequestResponseBad + updateInfraRequestResponseGood + + + + + + + updateInfraRequestResponseBad + + + + + SequenceFlow_0wsgnab + + + + + + + + + + SequenceFlow_10 + SequenceFlow_11 + + + + SequenceFlow_11 + + + + SequenceFlow_018p5wf + SequenceFlow_10 + + + + + + + SequenceFlow_0wsgnab + SequenceFlow_018p5wf + + + + + SequenceFlow_14 + SequenceFlow_16 + + + + SequenceFlow_16 + + + + + + SequenceFlow_15 + + + + + SequenceFlow_15 + + + + SequenceFlow_1 + SequenceFlow_3 + + + + + + SequenceFlow_1qvgrvq + SequenceFlow_1jqizzo + + + + SequenceFlow_1jqizzo + + + SequenceFlow_1qvgrvq + + + + + + + + + + + + + + + + + + + + SequenceFlow_1xggje5 + SequenceFlow_07llpjo + + + SequenceFlow_07llpjo + SequenceFlow_1vx081s + SequenceFlow_0nszq2o + + + + + SequenceFlow_0nszq2o + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_09i6f7t + SequenceFlow_1tk5ru7 + + + + SequenceFlow_1tk5ru7 + SequenceFlow_0td7d9m + SequenceFlow_0h5cld9 + + + + + SequenceFlow_0h5cld9 + + + + + + + SequenceFlow_1hk35nm + SequenceFlow_1xggje5 + SequenceFlow_1y7d5qk + + + + + + + updateInfraRequestResponseGood + SequenceFlow_020dbkp + SequenceFlow_0u8zesf + + + + + + + SequenceFlow_1efipx3 + SequenceFlow_1hk35nm + + + + + SequenceFlow_020dbkp + SequenceFlow_09i6f7t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn new file mode 100644 index 0000000000..dcdcdc9d26 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn @@ -0,0 +1,514 @@ + + + + + SequenceFlow_1 + + + + + SequenceFlow_1tfi3sp + + + + SequenceFlow_1tfi3sp + SequenceFlow_0x34g02 + SequenceFlow_1q9kksk + + + SequenceFlow_0x34g02 + SequenceFlow_22 + + + + + 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 + SequenceFlow_4 + + + + + SequenceFlow_4 + SequenceFlow_3 + + + + + SequenceFlow_3 + SequenceFlow_volGrpNamePresent + SequenceFlow_volGrpNameMissing + + + + + + + SequenceFlow_volGrpNameMissing + SequenceFlow_7 + + + + + SequenceFlow_7 + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_volGrpNamePresent + SequenceFlow_0djjra2 + + + SequenceFlow_12 + SequenceFlow_13 + + + + + + + + + + + + + SequenceFlow_11 + SequenceFlow_12 + + + + SequenceFlow_8 + SequenceFlow_11 + + + + + + + + + ${CVMVINFRAV1_createDBRequest} + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + ${response} + ${statusCode} + + http-connector + + + SequenceFlow_6 + SequenceFlow_8 + + + + SequenceFlow_13 + + + + SequenceFlow_0djjra2 + SequenceFlow_6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn new file mode 100644 index 0000000000..6af8c2248e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn @@ -0,0 +1,340 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + SequenceFlow_2 + SequenceFlow_3 + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0ed0uiq + SequenceFlow_0w0m5fr + + + + SequenceFlow_8 + SequenceFlow_9 + + + + + SequenceFlow_9 + + + SequenceFlow_8 + + + + + + + + + + + + SequenceFlow_13 + SequenceFlow_14 + + + + SequenceFlow_15 + SequenceFlow_13 + + + + + SequenceFlow_14 + + + + SequenceFlow_12 + SequenceFlow_15 + + + + + SequenceFlow_12 + + + + + + SequenceFlow_01mjjk3 + SequenceFlow_16 + + + + + SequenceFlow_17 + + + + + + + + + + SequenceFlow_16 + SequenceFlow_17 + + + + + SequenceFlow_3 + SequenceFlow_0ed0uiq + + + + + + + SequenceFlow_0w0m5fr + SequenceFlow_0s4i7px + + + + SequenceFlow_0s4i7px + SequenceFlow_01mjjk3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn new file mode 100644 index 0000000000..2d68d650c5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn @@ -0,0 +1,381 @@ + + + + + SequenceFlow_1wxumid + + + + SequenceFlow_0guajy5 + SequenceFlow_0dbt753 + + + + SequenceFlow_0guajy5 + + + + SequenceFlow_0dbt753 + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0zf2qyk + SequenceFlow_07hrbs0 + + + SequenceFlow_1ab5l2q + + + SequenceFlow_1wxumid + SequenceFlow_0yowshs + + + + SequenceFlow_04urx2e + SequenceFlow_1ii935p + + + + + + + + + + + + SequenceFlow_1ii935p + SequenceFlow_1ab5l2q + + + + SequenceFlow_0for83z + + + + SequenceFlow_0hrazlh + + + SequenceFlow_1s1cbgf + SequenceFlow_1py6yqz + + + + + + + + + + + + SequenceFlow_1py6yqz + SequenceFlow_0hrazlh + + + SequenceFlow_0for83z + SequenceFlow_1s1cbgf + + + + + + + + + SequenceFlow_1dkcu9o + SequenceFlow_0zf2qyk + + + + SequenceFlow_07hrbs0 + SequenceFlow_04urx2e + SequenceFlow_1t6ekab + + + SequenceFlow_1t6ekab + + + + + + + + + + + + + + + SequenceFlow_0yowshs + SequenceFlow_0c4t26p + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0c4t26p + SequenceFlow_1dkcu9o + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn new file mode 100644 index 0000000000..5c9a80072a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn @@ -0,0 +1,331 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + SequenceFlow_1lj31zp + + + SequenceFlow_095crcd + + + + SequenceFlow_0lp2z7l + SequenceFlow_0ktadna + + + + + SequenceFlow_1qjygj5 + SequenceFlow_0xxvjxq + + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_14eadeb + SequenceFlow_1reso2f + + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + SequenceFlow_0n4umjf + SequenceFlow_14eadeb + + + + + + + + SequenceFlow_0ktadna + SequenceFlow_0eto8sn + + + + + SequenceFlow_1lj31zp + SequenceFlow_1qjygj5 + SequenceFlow_0hgiouk + + + + + + SequenceFlow_0hgiouk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn new file mode 100644 index 0000000000..a62e16525d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn @@ -0,0 +1,372 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + SequenceFlow_1lj31zp + + + SequenceFlow_0x3znm5 + + + SequenceFlow_095crcd + SequenceFlow_0x3znm5 + + + + + + SequenceFlow_0lp2z7l + SequenceFlow_1ablr60 + + + + + + SequenceFlow_1lj31zp + SequenceFlow_0xxvjxq + + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_0n4umjf + SequenceFlow_1s5niqb + + + + + + + + ${DELNI_deleteDBRequest} + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + ${response} + ${statusCode} + + http-connector + + + SequenceFlow_1s5niqb + SequenceFlow_06s5eu4 + + + SequenceFlow_06s5eu4 + SequenceFlow_1reso2f + + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + + + + + + + SequenceFlow_1ablr60 + SequenceFlow_0rt8wax + + + + SequenceFlow_0rt8wax + SequenceFlow_0eto8sn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn new file mode 100644 index 0000000000..a1c75a8740 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn @@ -0,0 +1,258 @@ + + + + + SequenceFlow_1qo2pln + + + + + SequenceFlow_18l3crb + SequenceFlow_0khtova + + + + SequenceFlow_15wux6a + + + + + + + + + + + + + SequenceFlow_15mvedq + SequenceFlow_1xk5xed + + + + + SequenceFlow_1vnx1pp + SequenceFlow_0ow44q0 + + + + + + SequenceFlow_1qo2pln + SequenceFlow_0w2es8j + + + + SequenceFlow_0w2es8j + SequenceFlow_18l3crb + + + + + + SequenceFlow_0khtova + SequenceFlow_1mz0vdx + + + + SequenceFlow_1xk5xed + SequenceFlow_1jr6zi0 + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1mz0vdx + SequenceFlow_15mvedq + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1jr6zi0 + SequenceFlow_1vnx1pp + + + + + SequenceFlow_0ow44q0 + SequenceFlow_15wux6a + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVFCNSResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVFCNSResource.bpmn new file mode 100644 index 0000000000..bbc7ead144 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVFCNSResource.bpmn @@ -0,0 +1,166 @@ + + + + + SequenceFlow_0x2e9we + + + + + + SequenceFlow_0jvtdhv + + + + SequenceFlow_0x2e9we + SequenceFlow_00vpfm3 + + + + SequenceFlow_1s4cyms + SequenceFlow_152xb4z + + + + + + + + + + + + + + + + SequenceFlow_00vpfm3 + SequenceFlow_1s4cyms + + + + SequenceFlow_0yro7o2 + + + + SequenceFlow_0p0ayci + + + SequenceFlow_0yro7o2 + SequenceFlow_0p0ayci + + + + + + + SequenceFlow_152xb4z + SequenceFlow_0jvtdhv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn new file mode 100644 index 0000000000..a835946d1d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn @@ -0,0 +1,812 @@ + + + + + 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_10o22u2 + SequenceFlow_04ao07f + + + SequenceFlow_3 + + + + + SequenceFlow_06llof4 + + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_06llof4 + SequenceFlow_0807ukc + + + + + + + + + + SequenceFlow_04ao07f + + + + + + + + + + + + + + SequenceFlow_0jek18q + SequenceFlow_1ttswdr + + + SequenceFlow_1ttswdr + SequenceFlow_18103ca + + + + SequenceFlow_0jek18q + + + + SequenceFlow_18103ca + + + + + + + + + + + + + + + + + + + + SequenceFlow_05cjs89 + SequenceFlow_0snq0kw + + + SequenceFlow_0zaircn + + + + SequenceFlow_09i2jj0 + + + + SequenceFlow_09i2jj0 + SequenceFlow_05cjs89 + SequenceFlow_03n4wb1 + + + SequenceFlow_0snq0kw + SequenceFlow_03n4wb1 + SequenceFlow_1jjh8rv + + + SequenceFlow_0xgpd0u + SequenceFlow_0nk8vsb + SequenceFlow_0npvfo3 + + + SequenceFlow_0nk8vsb + SequenceFlow_0et9p0i + SequenceFlow_0zaircn + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0npvfo3 + SequenceFlow_0et9p0i + + + + + + + + + + + + + + + + + + SequenceFlow_128485i + SequenceFlow_04fys47 + + + SequenceFlow_1yamcyn + SequenceFlow_19cxgtm + SequenceFlow_128485i + + + + SequenceFlow_1lfph6u + + + + SequenceFlow_1ofw0fi + + + + SequenceFlow_1ofw0fi + SequenceFlow_1yamcyn + SequenceFlow_0vq7f6b + + + SequenceFlow_0vq7f6b + SequenceFlow_10scc5r + SequenceFlow_1lfph6u + + + SequenceFlow_04fys47 + SequenceFlow_1o5cutr + + + + SequenceFlow_1o5cutr + SequenceFlow_19cxgtm + SequenceFlow_10scc5r + + + + + 0}]]> + + + + + + + + + + + SequenceFlow_1jjh8rv + + + + SequenceFlow_0xgpd0u + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleInfra.bpmn new file mode 100644 index 0000000000..bfe5e02b49 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleInfra.bpmn @@ -0,0 +1,331 @@ + + + + + SequenceFlow_5 + SequenceFlow_2 + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + SequenceFlow_2 + SequenceFlow_9 + + + + + + + + + + + + + + + + + + SequenceFlow_9 + SequenceFlow_8 + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_13 + SequenceFlow_17 + + + + + + + + + + POST + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + ${DELVfModI_updateInfraRequest} + ${response} + ${statusCode} + + soap-http-connector + + + SequenceFlow_10 + SequenceFlow_13 + + + + SequenceFlow_8 + SequenceFlow_10 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn new file mode 100644 index 0000000000..b7ce608090 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn @@ -0,0 +1,568 @@ + + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + SequenceFlow_1 + + + + SequenceFlow_7 + SequenceFlow_12 + + + + + SequenceFlow_12 + SequenceFlow_6 + + + + SequenceFlow_15 + SequenceFlow_2 + + + + + SequenceFlow_22 + + + + SequenceFlow_13 + SequenceFlow_15 + SequenceFlow_21 + + + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_5 + + + + SequenceFlow_8 + SequenceFlow_13 + + + + + SequenceFlow_21 + SequenceFlow_22 + + + + + + SequenceFlow_6 + SequenceFlow_4 + SequenceFlow_8 + + + + + + + SequenceFlow_4 + + + + + SequenceFlow_23 + + + + + SequenceFlow_23 + SequenceFlow_responseNotSent + SequenceFlow_responseSent + + + SequenceFlow_responseNotSent + SequenceFlow_14 + + + + + #{DELVfModVol_syncResponseSent == true} + + + SequenceFlow_responseSent + SequenceFlow_14 + SequenceFlow_25 + + + + + + + + + + + + + + + SequenceFlow_25 + SequenceFlow_19 + + + + SequenceFlow_19 + + + + + + SequenceFlow_35 + SequenceFlow_37 + + + + + SequenceFlow_27 + SequenceFlow_29 + + + + + SequenceFlow_10 + SequenceFlow_24 + + + + + + + + + + + + + + + SequenceFlow_29 + SequenceFlow_10 + + + + SequenceFlow_24 + + + + + + + + ${DELVfModVol_updateInfraRequest} + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + ${response} + ${statusCode} + + http-connector + + + SequenceFlow_37 + SequenceFlow_27 + + + + SequenceFlow_vnfAdapterCallOK + SequenceFlow_35 + + + + + SequenceFlow_5 + SequenceFlow_vnfAdapterCallOK + SequenceFlow_vnfAdapterCallNotOK + + + #{VNFREST_SuccessIndicator == true} + + + SequenceFlow_vnfAdapterCallNotOK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVnfInfra.bpmn new file mode 100644 index 0000000000..6092de6c79 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVnfInfra.bpmn @@ -0,0 +1,353 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_2 + SequenceFlow_16ikne0 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + + SequenceFlow_15 + SequenceFlow_16 + + + + + + + + + + SequenceFlow_16 + SequenceFlow_17 + + + + SequenceFlow_17 + + + + SequenceFlow_14 + + + + + SequenceFlow_14 + SequenceFlow_15 + + + + + + + SequenceFlow_19 + + + SequenceFlow_18 + + + + + SequenceFlow_18 + SequenceFlow_19 + + + + + + SequenceFlow_0slfgmy + SequenceFlow_6 + + + + + + + + + + + SequenceFlow_6 + SequenceFlow_7 + + + + SequenceFlow_7 + + + + + + + + + SequenceFlow_00bhxtl + SequenceFlow_1f56g06 + + + SequenceFlow_16ikne0 + SequenceFlow_00o02cv + SequenceFlow_00bhxtl + + + + SequenceFlow_1f56g06 + SequenceFlow_0dy2xw0 + SequenceFlow_0slfgmy + + + + + + + + + + + + + + + SequenceFlow_00o02cv + SequenceFlow_0dy2xw0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn new file mode 100644 index 0000000000..6a157eb7c0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn @@ -0,0 +1,1815 @@ + + + + + SequenceFlow_5 + SequenceFlow_0y0jt4l + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_3 + SequenceFlow_19rrss6 + SequenceFlow_17 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_0ph6862 + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + + + SequenceFlow_1 + SequenceFlow_0msgw6c + + + + SequenceFlow_0uhssvq + SequenceFlow_0ph6862 + + + + + + + + + + + + + + + + + SequenceFlow_0msgw6c + SequenceFlow_0uhssvq + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + + + + + + + + + + SequenceFlow_19ba94v + SequenceFlow_0gzzeru + + + + + + + + + + + + + SequenceFlow_0y0jt4l + SequenceFlow_1w35ov3 + + + + SequenceFlow_1w35ov3 + SequenceFlow_053qjfy + + + + + SequenceFlow_16mo99z + SequenceFlow_0jph3mt + SequenceFlow_2 + + + + + + + SequenceFlow_0baosqi + SequenceFlow_1nodcf9 + SequenceFlow_0k3fx7p + + + + SequenceFlow_19lg15d + SequenceFlow_0usoiza + SequenceFlow_12mfil6 + + + + SequenceFlow_14yy8v4 + SequenceFlow_0usxnlk + + + + + + + + + + SequenceFlow_0usxnlk + SequenceFlow_16mo99z + SequenceFlow_12hm1ks + + + + SequenceFlow_2 + SequenceFlow_0baosqi + SequenceFlow_0etr76r + + + + + + + + + + + + + + + + + + + + SequenceFlow_1cezgw4 + SequenceFlow_0v0u7mf + + + + SequenceFlow_1qr8msw + + + + + + + + + SequenceFlow_0k3fx7p + SequenceFlow_1bkhs8m + SequenceFlow_11b00u2 + + + + SequenceFlow_0xx8y1s + SequenceFlow_0qy68ib + SequenceFlow_1ck3v34 + + + + SequenceFlow_0a6pdza + SequenceFlow_0q0qan8 + SequenceFlow_079nix0 + + + + SequenceFlow_13h26h9 + SequenceFlow_1c0vdki + SequenceFlow_032i8t0 + + + + SequenceFlow_0gzzeru + SequenceFlow_0bxgny0 + SequenceFlow_1f0c5lj + + + + SequenceFlow_1uno5rs + SequenceFlow_162mm0m + SequenceFlow_17vwb2h + + + + SequenceFlow_1c79909 + SequenceFlow_197t3qk + SequenceFlow_0ba08lt + + + + SequenceFlow_1xfbwpi + SequenceFlow_19lg15d + SequenceFlow_1akvi72 + + + + SequenceFlow_12mfil6 + SequenceFlow_3 + SequenceFlow_1sdol24 + + + + SequenceFlow_0vpd06n + SequenceFlow_051zp79 + + + + SequenceFlow_0v0u7mf + SequenceFlow_0vpd06n + SequenceFlow_1qr8msw + SequenceFlow_05gpym3 + + + SequenceFlow_05gpym3 + SequenceFlow_051zp79 + SequenceFlow_1ei7at5 + SequenceFlow_0kg02xg + SequenceFlow_1i6p53b + SequenceFlow_1yy7o24 + SequenceFlow_0sqmtpl + SequenceFlow_1shdmrj + SequenceFlow_1v1i5w4 + SequenceFlow_1h8rscx + SequenceFlow_1xzq6jb + SequenceFlow_165q14c + SequenceFlow_0wp1a6g + SequenceFlow_0vymfh9 + + + + + + + SequenceFlow_1c0vdki + SequenceFlow_0aldwvz + SequenceFlow_19ba94v + + + + SequenceFlow_0bxgny0 + SequenceFlow_111z6w4 + SequenceFlow_1qm0ygo + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1qm0ygo + SequenceFlow_0he2w4b + + + SequenceFlow_0he2w4b + SequenceFlow_04zwhw4 + SequenceFlow_0pfvulx + + + + + + + + + + + + + + + + + + + SequenceFlow_1bkhs8m + SequenceFlow_1qfjlt7 + SequenceFlow_0xx8y1s + + + + + + + + + + + + + + + + + + SequenceFlow_0qy68ib + SequenceFlow_0x7iupc + SequenceFlow_0a6pdza + + + + + + + + + + + + + + + + SequenceFlow_0q0qan8 + SequenceFlow_0hp0w6k + SequenceFlow_13h26h9 + + + + + + + + + + + + + + + + SequenceFlow_04zwhw4 + SequenceFlow_1lrbndo + SequenceFlow_1uno5rs + + + + + + + + + + + + + + + + + + SequenceFlow_162mm0m + SequenceFlow_14mblvp + SequenceFlow_1c79909 + + + SequenceFlow_12hm1ks + + + + SequenceFlow_0jph3mt + + + + SequenceFlow_0etr76r + + + + SequenceFlow_1nodcf9 + + + + SequenceFlow_11b00u2 + + + + + + + + + + + + + + + SequenceFlow_1qfjlt7 + + + + SequenceFlow_1ck3v34 + + + + SequenceFlow_0x7iupc + + + + SequenceFlow_079nix0 + + + + SequenceFlow_0hp0w6k + + + + SequenceFlow_032i8t0 + + + + + + + + + + + + + + + + SequenceFlow_0aldwvz + + + + SequenceFlow_1f0c5lj + + + + SequenceFlow_111z6w4 + + + + SequenceFlow_0pfvulx + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_197t3qk + SequenceFlow_18e0jz0 + SequenceFlow_1xfbwpi + + + SequenceFlow_1lrbndo + + + + SequenceFlow_17vwb2h + + + + SequenceFlow_14mblvp + + + + SequenceFlow_0ba08lt + + + + SequenceFlow_18e0jz0 + + + + SequenceFlow_1akvi72 + + + + SequenceFlow_0usoiza + + + + SequenceFlow_1sdol24 + + + + + + + + + + + + + + + + + + + + SequenceFlow_19rrss6 + + + + + SequenceFlow_1cezgw4 + + + + + SequenceFlow_1ei7at5 + + + + SequenceFlow_0kg02xg + + + + SequenceFlow_1i6p53b + + + + SequenceFlow_1yy7o24 + + + + SequenceFlow_0sqmtpl + + + + SequenceFlow_1shdmrj + + + + SequenceFlow_1v1i5w4 + + + + SequenceFlow_1h8rscx + + + + SequenceFlow_1xzq6jb + + + + SequenceFlow_165q14c + + + + SequenceFlow_0wp1a6g + + + + SequenceFlow_0vymfh9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_053qjfy + SequenceFlow_14yy8v4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ScaleCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ScaleCustomE2EServiceInstance.bpmn new file mode 100644 index 0000000000..5b9cceabff --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ScaleCustomE2EServiceInstance.bpmn @@ -0,0 +1,379 @@ + + + + + SequenceFlow_0c2denm + + + SequenceFlow_0c2denm + SequenceFlow_1ntnafv + + + + SequenceFlow_14zd9we + SequenceFlow_0er6ddi + + + + SequenceFlow_1fis1j1 + SequenceFlow_06f0dx5 + SequenceFlow_19b0pmt + + + SequenceFlow_06f0dx5 + SequenceFlow_1q6spfu + + + + + + + + + + + + SequenceFlow_1q6spfu + SequenceFlow_0mm4eqd + + + SequenceFlow_0mm4eqd + + + + + + + + + + + + + SequenceFlow_19b0pmt + + + + + SequenceFlow_04f826i + + + + SequenceFlow_1t2ijcu + + + SequenceFlow_09z92mf + SequenceFlow_1sooz22 + + + + SequenceFlow_04f826i + SequenceFlow_09z92mf + + + + + + + + + + + + + + + + SequenceFlow_1sooz22 + SequenceFlow_1t2ijcu + + + + + SequenceFlow_0gna7ys + SequenceFlow_0re5dm7 + + + + SequenceFlow_0gna7ys + + + + SequenceFlow_0re5dm7 + + + + + + + + + + + + + + + + + + + + SequenceFlow_0er6ddi + SequenceFlow_1fis1j1 + + + + + + SequenceFlow_1ntnafv + SequenceFlow_030pfun + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_030pfun + SequenceFlow_14zd9we + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn new file mode 100644 index 0000000000..28bd3f76ea --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn @@ -0,0 +1,693 @@ + + + + + SequenceFlow_0s2spoq + + + + SequenceFlow_1dsbjjb + SequenceFlow_1yay321 + + + + SequenceFlow_1dsbjjb + + + + SequenceFlow_1yay321 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_04qwbbf + SequenceFlow_0klbpxx + + + SequenceFlow_0yayvrf + + + SequenceFlow_0s2spoq + SequenceFlow_0az1n4y + + + + SequenceFlow_14zu6wr + SequenceFlow_0je30si + + + + + + + + + + + + SequenceFlow_0je30si + SequenceFlow_0yayvrf + + + + SequenceFlow_0e1r62n + + + + SequenceFlow_1ysapam + + + SequenceFlow_0n9pexp + SequenceFlow_01umodj + + + + + + + + + + + + SequenceFlow_01umodj + SequenceFlow_1ysapam + + + SequenceFlow_06o383f + SequenceFlow_0n9pexp + + + + + + + + SequenceFlow_0e1r62n + SequenceFlow_0t4nds2 + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0t4nds2 + SequenceFlow_06o383f + + + + + SequenceFlow_12dou7o + SequenceFlow_0secadm + + + + SequenceFlow_0klbpxx + SequenceFlow_14zu6wr + SequenceFlow_1fueo69 + + + SequenceFlow_1fueo69 + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0az1n4y + SequenceFlow_1bd4711 + + + SequenceFlow_1bd4711 + SequenceFlow_03i6zhx + + + + + SequenceFlow_0xhbobd + SequenceFlow_0t7zinj + + + + SequenceFlow_03i6zhx + SequenceFlow_1pdv4qj + + + + + + + + + + + + + + + + SequenceFlow_1pdv4qj + SequenceFlow_0xhbobd + + + + + + SequenceFlow_0secadm + SequenceFlow_0zmd4rt + SequenceFlow_1n8h3zt + + + + SequenceFlow_04qwbbf + + + + + + SequenceFlow_0kvl23y + + + SequenceFlow_1bddzne + SequenceFlow_1e3vtyq + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1e3vtyq + SequenceFlow_12dou7o + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1wzk6tu + SequenceFlow_0kvl23y + + + SequenceFlow_0t7zinj + + + + + SequenceFlow_1bddzne + + + + + SequenceFlow_1n8h3zt + SequenceFlow_1wzk6tu + + + + + SequenceFlow_0zmd4rt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn new file mode 100644 index 0000000000..e5236f92bf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn @@ -0,0 +1,322 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + import org.onap.so.bpmn.infrastructure.scripts.* +def networkMod = new UpdateNetworkInstance() +networkMod.processJavaException(execution) + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + SequenceFlow_1lj31zp + + + SequenceFlow_0x3znm5 + + + SequenceFlow_095crcd + SequenceFlow_0x3znm5 + import org.onap.so.bpmn.infrastructure.scripts.* +def UpdateNetworkInstance = new UpdateNetworkInstance() +UpdateNetworkInstance.postProcessResponse(execution) + + + + + + SequenceFlow_0lp2z7l + SequenceFlow_1ablr60 + import org.onap.so.bpmn.infrastructure.scripts.* +def preProcess = new UpdateNetworkInstance() +preProcess.preProcessRequest(execution) + + + + + SequenceFlow_1lj31zp + SequenceFlow_0xxvjxq + import org.onap.so.bpmn.infrastructure.scripts.* +def UpdateNetworkInstance = new UpdateNetworkInstance() +UpdateNetworkInstance.prepareCompletion(execution) + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_0n4umjf + SequenceFlow_1reso2f + import org.onap.so.bpmn.infrastructure.scripts.* +def UpdateNetworkInstance = new UpdateNetworkInstance() +UpdateNetworkInstance.buildErrorResponse(execution) + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + + + + + SequenceFlow_1ablr60 + SequenceFlow_0rt8wax + import org.onap.so.bpmn.infrastructure.scripts.* +def UpdateNetworkInstance = new UpdateNetworkInstance() +UpdateNetworkInstance.getNetworkModelInfo(execution) + + + SequenceFlow_0rt8wax + SequenceFlow_0eto8sn + import org.onap.so.bpmn.infrastructure.scripts.* +def UpdateNetworkInstance = new UpdateNetworkInstance() +UpdateNetworkInstance.sendSyncResponse(execution) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn new file mode 100644 index 0000000000..c35e7ece96 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn @@ -0,0 +1,297 @@ + + + + + SequenceFlow_5 + SequenceFlow_2 + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + SequenceFlow_2 + SequenceFlow_9 + + + + + + + + + + + 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_9 + SequenceFlow_3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn new file mode 100644 index 0000000000..1efb127e33 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn new file mode 100644 index 0000000000..078d72a1d8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn @@ -0,0 +1,517 @@ + + + + + SequenceFlow_1 + + + + + + + + + + + SequenceFlow_13 + SequenceFlow_14 + + + + + + + + ${UPDVfModVol_updateInfraRequest} + + + aapplication/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + ${response} + ${statusCode} + + http-connector + + + SequenceFlow_11 + SequenceFlow_12 + + + + SequenceFlow_22 + SequenceFlow_21 + + + + + SequenceFlow_12 + SequenceFlow_13 + + + + + + + + + + + + + SequenceFlow_21 + SequenceFlow_19 + + + + SequenceFlow_19 + SequenceFlow_11 + + + + + SequenceFlow_14 + SequenceFlow_1 + + + + + SequenceFlow_noVfModuleRelation + SequenceFlow_personaModelIdMatchYes + SequenceFlow_22 + + + + SequenceFlow_7 + + + + SequenceFlow_6 + + + + + SequenceFlow_7 + SequenceFlow_4 + + + + + + + + + + + + + + SequenceFlow_4 + SequenceFlow_6 + + + + + + SequenceFlow_8 + SequenceFlow_personaModelIdMatchYes + SequenceFlow_personaModelidMatchNo + + + #{UPDVfModVol_modelInvariantId == UPDVfModVol_personaModelId} + + + + SequenceFlow_YesVfModuleRelation + SequenceFlow_8 + + + + + SequenceFlow_personaModelidMatchNo + SequenceFlow_18 + + + + + SequenceFlow_18 + + + + SequenceFlow_3 + SequenceFlow_2 + + + + + SequenceFlow_3 + + + + SequenceFlow_2 + SequenceFlow_20 + + + + + SequenceFlow_tenantIsMatch + SequenceFlow_YesVfModuleRelation + SequenceFlow_noVfModuleRelation + + + + + + + SequenceFlow_15 + SequenceFlow_NoTenantMatch + SequenceFlow_tenantIsMatch + + + + #{UPDVfModVol_tenantId == UPDVfModVol_volumeGroupTenantId} + + + SequenceFlow_NoTenantMatch + SequenceFlow_17 + + + + + SequenceFlow_17 + + + + SequenceFlow_5 + SequenceFlow_15 + + + + + SequenceFlow_20 + SequenceFlow_5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn new file mode 100644 index 0000000000..e50eb7f805 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn @@ -0,0 +1,1685 @@ + + + + + SequenceFlow_5 + SequenceFlow_0y0jt4l + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_3 + SequenceFlow_1dqbqqx + SequenceFlow_17 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_0slcwxc + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + + + SequenceFlow_1 + SequenceFlow_0a0lfh8 + + + + SequenceFlow_0r0o5yt + SequenceFlow_0slcwxc + + + + + + + + + + + + + + + + + SequenceFlow_0a0lfh8 + SequenceFlow_0r0o5yt + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_19ba94v + SequenceFlow_0gzzeru + + + + + + + + + + + + + SequenceFlow_0y0jt4l + SequenceFlow_1w35ov3 + + + + SequenceFlow_1w35ov3 + SequenceFlow_053qjfy + + + + + SequenceFlow_16mo99z + SequenceFlow_1pj72fw + SequenceFlow_2 + + + + + + + SequenceFlow_0baosqi + SequenceFlow_1lmijmb + SequenceFlow_0k3fx7p + + + + SequenceFlow_19lg15d + SequenceFlow_11p8elx + SequenceFlow_12mfil6 + + + + SequenceFlow_178fxkj + SequenceFlow_0usxnlk + + + + + + + + + + SequenceFlow_0usxnlk + SequenceFlow_16mo99z + SequenceFlow_1esmtgy + + + + SequenceFlow_2 + SequenceFlow_0baosqi + SequenceFlow_1jmzl1j + + + + + + + + + + + + + + + + + + + + SequenceFlow_1nplvhi + SequenceFlow_0v0u7mf + + + + SequenceFlow_1qr8msw + + + + + + + + + SequenceFlow_0k3fx7p + SequenceFlow_1bkhs8m + SequenceFlow_010ynjs + + + + SequenceFlow_0xx8y1s + SequenceFlow_0qy68ib + SequenceFlow_1qsxbp4 + + + + SequenceFlow_0a6pdza + SequenceFlow_0q0qan8 + SequenceFlow_15bl7wd + + + + SequenceFlow_13h26h9 + SequenceFlow_1c0vdki + SequenceFlow_1m84lq5 + + + + SequenceFlow_0gzzeru + SequenceFlow_04zwhw4 + SequenceFlow_0fog99f + + + + SequenceFlow_1uno5rs + SequenceFlow_162mm0m + SequenceFlow_12g63pl + + + + SequenceFlow_1c79909 + SequenceFlow_197t3qk + SequenceFlow_0l83v2k + + + + SequenceFlow_1xfbwpi + SequenceFlow_19lg15d + SequenceFlow_07fhkt4 + + + + SequenceFlow_12mfil6 + SequenceFlow_3 + SequenceFlow_0p94lgv + + + + SequenceFlow_0vpd06n + SequenceFlow_1c022sy + + + + SequenceFlow_0v0u7mf + SequenceFlow_0vpd06n + SequenceFlow_1qr8msw + SequenceFlow_05gpym3 + + + SequenceFlow_05gpym3 + SequenceFlow_1c022sy + SequenceFlow_0tqrgop + SequenceFlow_126nlmw + SequenceFlow_0mw3mwl + SequenceFlow_13md9cw + SequenceFlow_0xylem3 + SequenceFlow_1c5mxd5 + SequenceFlow_0u8hiu2 + SequenceFlow_0fs7ay9 + SequenceFlow_00qwx4v + SequenceFlow_14s8ji9 + SequenceFlow_0kricor + + + + + + + SequenceFlow_1c0vdki + SequenceFlow_1hldqvv + SequenceFlow_19ba94v + + + + + + + + + + + + + + + + + SequenceFlow_1bkhs8m + SequenceFlow_0qmpjgv + SequenceFlow_0xx8y1s + + + + + + + + + + + + + + + + + + SequenceFlow_0qy68ib + SequenceFlow_0tld38t + SequenceFlow_0a6pdza + + + + + + + + + + + + + + + + SequenceFlow_0q0qan8 + SequenceFlow_08dyt3l + SequenceFlow_13h26h9 + + + + + + + + + + + + + + + + SequenceFlow_04zwhw4 + SequenceFlow_0ye8oij + SequenceFlow_1uno5rs + + + + + + + + + + + + + + + + + + SequenceFlow_162mm0m + SequenceFlow_08kn9ok + SequenceFlow_1c79909 + + + + + + + + + + + + + + + SequenceFlow_197t3qk + SequenceFlow_02uiht9 + SequenceFlow_1xfbwpi + + + SequenceFlow_1esmtgy + + + + SequenceFlow_1jmzl1j + + + + + + + + + + SequenceFlow_1pj72fw + + + + + SequenceFlow_1lmijmb + + + + + SequenceFlow_010ynjs + + + + + + + SequenceFlow_0qmpjgv + + + + SequenceFlow_1qsxbp4 + + + + SequenceFlow_15bl7wd + + + + SequenceFlow_1m84lq5 + + + + SequenceFlow_0tld38t + + + + SequenceFlow_08dyt3l + + + + + + + + + + + + + + + + SequenceFlow_1hldqvv + + + + SequenceFlow_0fog99f + + + + SequenceFlow_0ye8oij + + + + SequenceFlow_12g63pl + + + + + + + + + + + + SequenceFlow_08kn9ok + + + + SequenceFlow_0l83v2k + + + + SequenceFlow_02uiht9 + + + + SequenceFlow_07fhkt4 + + + + SequenceFlow_11p8elx + + + + SequenceFlow_0p94lgv + + + + + + + + + + + + + + + + + SequenceFlow_1dqbqqx + + + + SequenceFlow_1nplvhi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0tqrgop + + + + SequenceFlow_126nlmw + + + + SequenceFlow_0mw3mwl + + + + SequenceFlow_13md9cw + + + + SequenceFlow_0xylem3 + + + + SequenceFlow_1c5mxd5 + + + + SequenceFlow_0u8hiu2 + + + + SequenceFlow_0fs7ay9 + + + + SequenceFlow_00qwx4v + + + + SequenceFlow_14s8ji9 + + + + SequenceFlow_0kricor + + + + + SequenceFlow_053qjfy + SequenceFlow_178fxkj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfConfigUpdate.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfConfigUpdate.bpmn new file mode 100644 index 0000000000..e296aef863 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfConfigUpdate.bpmn @@ -0,0 +1,1636 @@ + + + + + SequenceFlow_5 + SequenceFlow_0y0jt4l + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_3 + SequenceFlow_07uuj2d + SequenceFlow_17 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_0xt2xvx + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + + + SequenceFlow_1 + SequenceFlow_1vxpbd0 + + + + SequenceFlow_03ayqeh + SequenceFlow_0xt2xvx + + + + + + + + + + + + + + + + + SequenceFlow_1vxpbd0 + SequenceFlow_03ayqeh + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + SequenceFlow_0y0jt4l + SequenceFlow_053qjfy + + + + + SequenceFlow_16mo99z + SequenceFlow_09lrk4q + SequenceFlow_2 + + + + + SequenceFlow_0baosqi + SequenceFlow_1eezqx8 + SequenceFlow_0k3fx7p + + + + SequenceFlow_16ff86u + SequenceFlow_08m0j98 + SequenceFlow_12mfil6 + + + + SequenceFlow_053qjfy + SequenceFlow_179tyul + SequenceFlow_0usxnlk + + + + SequenceFlow_0usxnlk + SequenceFlow_16mo99z + SequenceFlow_06ev8or + + + + SequenceFlow_2 + SequenceFlow_0baosqi + SequenceFlow_1cdfjed + + + + + + + + + + + + + + + + + + + + SequenceFlow_0nob5cp + SequenceFlow_0v0u7mf + + + + + + + + + + SequenceFlow_0k3fx7p + SequenceFlow_17g62fl + SequenceFlow_06ajc11 + + + + SequenceFlow_1c79909 + SequenceFlow_1urpp94 + SequenceFlow_08m0j98 + + + SequenceFlow_12mfil6 + SequenceFlow_0u6ho2p + SequenceFlow_0k3zxpd + + + + SequenceFlow_0vpd06n + SequenceFlow_1c022sy + SequenceFlow_05omwbu + SequenceFlow_18lemf9 + + + + SequenceFlow_0v0u7mf + SequenceFlow_1qr8msw + SequenceFlow_05gpym3 + SequenceFlow_0vpd06n + SequenceFlow_0rlmex7 + + + SequenceFlow_05gpym3 + SequenceFlow_19myx3o + SequenceFlow_1c022sy + SequenceFlow_0ueoglv + SequenceFlow_15fqlwe + SequenceFlow_0yuj0l5 + SequenceFlow_1abb030 + SequenceFlow_0ls3ej5 + SequenceFlow_1ar6ikk + SequenceFlow_0t53vux + SequenceFlow_11ck4qe + SequenceFlow_16d2ln4 + SequenceFlow_1quapjx + SequenceFlow_101n488 + + + + + + + + + + SequenceFlow_06ev8or + + + + + + SequenceFlow_0zzwdwf + SequenceFlow_06ajc11 + SequenceFlow_076leae + + + + SequenceFlow_076leae + SequenceFlow_0du9273 + SequenceFlow_0zh8r6j + + + + SequenceFlow_0nob5cp + + + + SequenceFlow_1cdfjed + + + + + + + SequenceFlow_17g62fl + + + + + + + SequenceFlow_0zh8r6j + + + + + + + SequenceFlow_09lrk4q + + + + + + SequenceFlow_1eezqx8 + + + + SequenceFlow_0zzwdwf + + + + + + + SequenceFlow_0du9273 + SequenceFlow_032tm9y + SequenceFlow_179z9vl + + + + + SequenceFlow_032tm9y + + + + SequenceFlow_179z9vl + SequenceFlow_1cjiv6i + SequenceFlow_1q3oxtf + + + + SequenceFlow_1q3oxtf + + + + + + + SequenceFlow_1wqinjh + + + + + + + SequenceFlow_1urpp94 + + + + SequenceFlow_1colra4 + + + + SequenceFlow_1tzax6l + SequenceFlow_3 + SequenceFlow_0w8mkkn + + + + SequenceFlow_0u6ho2p + SequenceFlow_09xxorv + SequenceFlow_1tzax6l + + + + + SequenceFlow_16ff86u + + + + + + + + SequenceFlow_0k3zxpd + + + + SequenceFlow_09xxorv + + + + + + + + SequenceFlow_0w8mkkn + + + + SequenceFlow_07uuj2d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0ueoglv + + + + SequenceFlow_15fqlwe + + + + SequenceFlow_0yuj0l5 + + + + SequenceFlow_1abb030 + + + + SequenceFlow_0ls3ej5 + + + + SequenceFlow_1quapjx + + + + + + + SequenceFlow_1ar6ikk + + + + SequenceFlow_0t53vux + + + + SequenceFlow_11ck4qe + + + + SequenceFlow_16d2ln4 + + + + SequenceFlow_179tyul + + + + + + + + SequenceFlow_101n488 + + + + + SequenceFlow_16igl7b + + + + + + SequenceFlow_0wfzjs1 + SequenceFlow_188a7lk + SequenceFlow_12konw1 + + + SequenceFlow_0lpreg4 + SequenceFlow_0q1skau + SequenceFlow_1s3pbww + + + + + + + + + SequenceFlow_12konw1 + + + + + + + SequenceFlow_1s3pbww + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1cjiv6i + SequenceFlow_1colra4 + SequenceFlow_0wfzjs1 + + + + + + + + + + + + + + + + + + SequenceFlow_16igl7b + SequenceFlow_0q1skau + SequenceFlow_1c79909 + + + + + + + + + + + + + + + SequenceFlow_188a7lk + SequenceFlow_1wqinjh + SequenceFlow_0lpreg4 + + + + + + SequenceFlow_0rlmex7 + SequenceFlow_1xwgemy + + + + SequenceFlow_1nm4wr1 + SequenceFlow_19myx3o + SequenceFlow_05omwbu + + + + + + + SequenceFlow_1xwgemy + SequenceFlow_1nm4wr1 + + PT1M + + + + + + + + + + + + + + + + + + SequenceFlow_1qr8msw + SequenceFlow_18lemf9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfInPlaceUpdate.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfInPlaceUpdate.bpmn new file mode 100644 index 0000000000..3c42320302 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/VnfInPlaceUpdate.bpmn @@ -0,0 +1,2302 @@ + + + + + SequenceFlow_5 + SequenceFlow_0y0jt4l + + + + + SequenceFlow_4 + SequenceFlow_5 + + + + + + + + + + + SequenceFlow_17 + SequenceFlow_14 + + + + SequenceFlow_6 + + + + SequenceFlow_14 + SequenceFlow_6 + + + + + SequenceFlow_3 + SequenceFlow_07uuj2d + SequenceFlow_17 + + + + + + SequenceFlow_1 + + + + + SequenceFlow_0ib8gb8 + SequenceFlow_7 + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_19 + + + SequenceFlow_19 + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0hvg70o + SequenceFlow_1qnzi6i + + + + SequenceFlow_1 + SequenceFlow_0hvg70o + + + + + SequenceFlow_1qnzi6i + SequenceFlow_0ib8gb8 + + + + + SequenceFlow_12 + + + + SequenceFlow_12 + + + + + SequenceFlow_4 + + + + + + SequenceFlow_0y0jt4l + SequenceFlow_053qjfy + + + + + SequenceFlow_16mo99z + SequenceFlow_09lrk4q + SequenceFlow_2 + + + + + SequenceFlow_0baosqi + SequenceFlow_1eezqx8 + SequenceFlow_0k3fx7p + + + + SequenceFlow_1nr9o85 + SequenceFlow_16ff86u + SequenceFlow_12mfil6 + + + + SequenceFlow_053qjfy + SequenceFlow_179tyul + SequenceFlow_0usxnlk + + + + + + + + + + SequenceFlow_0usxnlk + SequenceFlow_16mo99z + SequenceFlow_06ev8or + + + + SequenceFlow_2 + SequenceFlow_0baosqi + SequenceFlow_1cdfjed + + + + + + + + + + + + + + + + + + + + SequenceFlow_0nob5cp + SequenceFlow_0v0u7mf + + + + + + + + + + SequenceFlow_0k3fx7p + SequenceFlow_17g62fl + SequenceFlow_06ajc11 + + + + + SequenceFlow_0a6pdza + SequenceFlow_0q0qan8 + SequenceFlow_02mk8vs + + + + SequenceFlow_13h26h9 + SequenceFlow_1c0vdki + SequenceFlow_11o5j55 + + + + SequenceFlow_1uno5rs + SequenceFlow_162mm0m + SequenceFlow_1gagrha + + + + SequenceFlow_1c79909 + SequenceFlow_1urpp94 + SequenceFlow_1c2xyhk + + + SequenceFlow_12mfil6 + SequenceFlow_0u6ho2p + SequenceFlow_0k3zxpd + + + + SequenceFlow_0vpd06n + SequenceFlow_1c022sy + SequenceFlow_0h64c4o + SequenceFlow_0syfgbo + + + + SequenceFlow_0v0u7mf + SequenceFlow_1qr8msw + SequenceFlow_05gpym3 + SequenceFlow_0vpd06n + SequenceFlow_1ijc733 + + + SequenceFlow_05gpym3 + SequenceFlow_1kntfys + SequenceFlow_1nlqlwn + SequenceFlow_1c022sy + SequenceFlow_0ueoglv + SequenceFlow_15fqlwe + SequenceFlow_0yuj0l5 + SequenceFlow_1abb030 + SequenceFlow_0ls3ej5 + SequenceFlow_1ar6ikk + SequenceFlow_171iq7e + SequenceFlow_1553o9f + SequenceFlow_0dmxwel + SequenceFlow_1id2p8y + SequenceFlow_0t53vux + SequenceFlow_11ck4qe + SequenceFlow_16d2ln4 + SequenceFlow_1quapjx + SequenceFlow_101n488 + SequenceFlow_021ah63 + + + + + + + + + + + + + + SequenceFlow_06ev8or + + + + + + SequenceFlow_0zzwdwf + SequenceFlow_06ajc11 + SequenceFlow_076leae + + + + SequenceFlow_076leae + SequenceFlow_0du9273 + SequenceFlow_0zh8r6j + + + + SequenceFlow_0nob5cp + + + + SequenceFlow_1cdfjed + + + + + + + SequenceFlow_17g62fl + + + + + + + SequenceFlow_0zh8r6j + + + + + + + SequenceFlow_09lrk4q + + + + + + SequenceFlow_1eezqx8 + + + + SequenceFlow_0zzwdwf + + + + + + + SequenceFlow_0du9273 + SequenceFlow_032tm9y + SequenceFlow_179z9vl + + + + + SequenceFlow_032tm9y + + + + SequenceFlow_179z9vl + SequenceFlow_1cjiv6i + SequenceFlow_1q3oxtf + + + + SequenceFlow_1q3oxtf + + + + + + + SequenceFlow_1j81s6b + + + + + + + SequenceFlow_16t9vai + + + + + SequenceFlow_02mk8vs + + + + + + + SequenceFlow_1urt6le + + + + + SequenceFlow_11o5j55 + + + + + + + SequenceFlow_19ba94v + SequenceFlow_1fuaq5k + SequenceFlow_04gth9f + + + + SequenceFlow_0if6xj4 + + + + + + + + SequenceFlow_04gth9f + + + + + SequenceFlow_1v59be9 + + + + SequenceFlow_04rprct + SequenceFlow_1uceq96 + SequenceFlow_0txgesu + + + + SequenceFlow_1uceq96 + + + + + + + + + SequenceFlow_0trguug + SequenceFlow_1q3bwlt + SequenceFlow_1xg6pwh + + + + SequenceFlow_1xfbwpi + SequenceFlow_1nr9o85 + SequenceFlow_0ttowkv + + + + SequenceFlow_1gagrha + + + + + + + + SequenceFlow_16igl7b + + + + + + + SequenceFlow_1urpp94 + + + + + SequenceFlow_0yja56j + + + + + + + + SequenceFlow_1xg6pwh + + + + SequenceFlow_1hwtq9x + + + + + + + + SequenceFlow_0ttowkv + + + + SequenceFlow_1colra4 + + + + + SequenceFlow_1tzax6l + SequenceFlow_3 + SequenceFlow_0w8mkkn + + + + SequenceFlow_0u6ho2p + SequenceFlow_09xxorv + SequenceFlow_1tzax6l + + + + + SequenceFlow_16ff86u + + + + + + + + SequenceFlow_0k3zxpd + + + + SequenceFlow_09xxorv + + + + + + + + SequenceFlow_0w8mkkn + + + + SequenceFlow_07uuj2d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0ueoglv + + + + SequenceFlow_15fqlwe + + + + SequenceFlow_0yuj0l5 + + + + SequenceFlow_1abb030 + + + + SequenceFlow_0ls3ej5 + + + + SequenceFlow_1quapjx + + + + + + + SequenceFlow_1ar6ikk + + + + SequenceFlow_1nlqlwn + + + + SequenceFlow_171iq7e + + + + SequenceFlow_1553o9f + + + + SequenceFlow_0dmxwel + + + + SequenceFlow_1id2p8y + + + + SequenceFlow_0t53vux + + + + SequenceFlow_11ck4qe + + + + SequenceFlow_16d2ln4 + + + + SequenceFlow_179tyul + + + + + + + + SequenceFlow_101n488 + + + + SequenceFlow_1ood2pr + + + + + + + + + + + + + + + + + + + + SequenceFlow_1c0vdki + SequenceFlow_0if6xj4 + SequenceFlow_19ba94v + + + + + + + + + + + + + + + SequenceFlow_1cjiv6i + SequenceFlow_1ood2pr + SequenceFlow_0xx8y1s + + + + + + + + + + + + + + + SequenceFlow_1q3bwlt + SequenceFlow_1hwtq9x + SequenceFlow_1xfbwpi + + + + + + + + + + + + + + + + SequenceFlow_0qy68ib + SequenceFlow_16t9vai + SequenceFlow_0a6pdza + + + + + + + + + + + + + + + + SequenceFlow_162mm0m + SequenceFlow_16igl7b + SequenceFlow_1c79909 + + + SequenceFlow_021ah63 + + + + + + + SequenceFlow_1ijc733 + SequenceFlow_0ai205d + + + + SequenceFlow_0a2cv6d + SequenceFlow_1kntfys + SequenceFlow_0h64c4o + + + SequenceFlow_0ai205d + SequenceFlow_0a2cv6d + + PT1M + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1qr8msw + SequenceFlow_0syfgbo + + + + + + + + + + + + + + + + + + SequenceFlow_0q0qan8 + SequenceFlow_1urt6le + SequenceFlow_13h26h9 + + + + + + + + + + + + + + + + SequenceFlow_1fuaq5k + SequenceFlow_1v59be9 + SequenceFlow_04rprct + + + + + + + + + + + + + + + + SequenceFlow_0txgesu + SequenceFlow_1colra4 + SequenceFlow_1uno5rs + + + + + + + + + + + + + + + + + SequenceFlow_1c2xyhk + SequenceFlow_0yja56j + SequenceFlow_0trguug + + + SequenceFlow_0xx8y1s + SequenceFlow_1j81s6b + SequenceFlow_0qy68ib + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelVersions.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelVersions.bpmn new file mode 100644 index 0000000000..f7023c33fc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelVersions.bpmn @@ -0,0 +1,330 @@ + + + + + SequenceFlow_1rebkae + SequenceFlow_1lkpfe2 + + + + + SequenceFlow_1rebkae + + + + SequenceFlow_1lkpfe2 + + + + + SequenceFlow_19sogyb + + + + SequenceFlow_17mr4jl + + + SequenceFlow_19sogyb + SequenceFlow_17mr4jl + + + + + + + SequenceFlow_0enm2cg + + + + SequenceFlow_1pe6r93 + SequenceFlow_0enm2cg + + + + + + + + + + + + SequenceFlow_1lta49u + SequenceFlow_1pe6r93 + + + SequenceFlow_0frea3k + SequenceFlow_1lta49u + + + + SequenceFlow_0frea3k + + + + + + + + SequenceFlow_08zjjzw + + + + SequenceFlow_1wudpuj + SequenceFlow_08zjjzw + + + + + + + + + + + + SequenceFlow_04ciw70 + SequenceFlow_1wudpuj + + + SequenceFlow_1fgkvpr + SequenceFlow_04ciw70 + + + + SequenceFlow_1fgkvpr + + + + + + + + SequenceFlow_1chfao3 + + + SequenceFlow_1chfao3 + SequenceFlow_164yb3r + + + + SequenceFlow_164yb3r + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelofE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelofE2EServiceInstance.bpmn new file mode 100644 index 0000000000..c04c2d97ea --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCompareModelofE2EServiceInstance.bpmn @@ -0,0 +1,227 @@ + + + + + + SequenceFlow_1rebkae + + + + SequenceFlow_1lkpfe2 + + + + + SequenceFlow_19sogyb + + + + SequenceFlow_17mr4jl + + + SequenceFlow_19sogyb + SequenceFlow_17mr4jl + + + + + + + SequenceFlow_1chfao3 + + + SequenceFlow_1cpg3ku + + + + + + + + + + + + + + + + + + + SequenceFlow_1rebkae + SequenceFlow_1pe6r93 + + + SequenceFlow_1pe6r93 + SequenceFlow_1lkpfe2 + + + + + SequenceFlow_1chfao3 + SequenceFlow_1xzphe4 + + + + + + + + + + + + + + + SequenceFlow_1xzphe4 + SequenceFlow_0b6eqin + + + SequenceFlow_0b6eqin + SequenceFlow_1cpg3ku + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn new file mode 100644 index 0000000000..d7bd54cc4e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn @@ -0,0 +1,755 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + notFound + SequenceFlow_6 + + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_4 + + + + SequenceFlow_4 + notFound + found + + + + found + SequenceFlow_0gbsa12 + + + + SequenceFlow_6 + + + + SequenceFlow_17p4ohs + SequenceFlow_11 + + + + + SequenceFlow_09xwplc + + + + + + + + + + SequenceFlow_0gd64w9 + SequenceFlow_1q6udwm + + + + + + + + + + + + SequenceFlow_1q6udwm + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0c5h00o + + + + SequenceFlow_0c5h00o + SequenceFlow_1lalmvp + + + + + + + + + + + + SequenceFlow_1lalmvp + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_15z3gpq + + + + SequenceFlow_04t1zc2 + SequenceFlow_06w33tk + + + + + + + + + + + + SequenceFlow_06w33tk + SequenceFlow_1s7yieq + + + SequenceFlow_1s7yieq + SequenceFlow_00i7x43 + + + + + + + + + + + + + + + + + SequenceFlow_030mhcm + SequenceFlow_0q1hz2p + + + + + + + + + + + + + + + SequenceFlow_1m8u8dl + SequenceFlow_1vg5rfa + + + + SequenceFlow_1vg5rfa + SequenceFlow_17p4ohs + SequenceFlow_0f7u5pu + + + + + + SequenceFlow_0f7u5pu + SequenceFlow_16o7col + + + + SequenceFlow_16o7col + + + + + + + SequenceFlow_1h61pqs + + + + SequenceFlow_0t4ut76 + + + SequenceFlow_1h61pqs + SequenceFlow_1kbzr5v + + + + SequenceFlow_1cxj4yz + SequenceFlow_0t4ut76 + + + + + + + + + + + + + + SequenceFlow_1kbzr5v + SequenceFlow_1cxj4yz + + + + + SequenceFlow_00i7x43 + SequenceFlow_1dgzhsm + + + + SequenceFlow_15z3gpq + SequenceFlow_04t1zc2 + + + + SequenceFlow_0z8luou + SequenceFlow_0ec9eiq + SequenceFlow_030mhcm + + + + SequenceFlow_0q1hz2p + SequenceFlow_1iy3cqb + + + + + + SequenceFlow_0gbsa12 + SequenceFlow_1m8u8dl + SequenceFlow_0z8luou + + + + + + + SequenceFlow_0gd64w9 + + + + + SequenceFlow_11 + + + + + + + + SequenceFlow_1iy3cqb + SequenceFlow_09xwplc + + + + + SequenceFlow_1dgzhsm + SequenceFlow_0ec9eiq + + ${sdncReplDelay} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRGRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRGRollback.bpmn new file mode 100644 index 0000000000..f369504856 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceBRGRollback.bpmn @@ -0,0 +1,575 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_0bfuk6l + + + + SequenceFlow_0ymy62j + + + + + + + + + + + + + + + SequenceFlow_1fvfplx + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0c5h00o + + + + + + + + + + + + SequenceFlow_0m483rd + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_0sh1u69 + + + + + + + + + + + + SequenceFlow_04hdt5s + SequenceFlow_1s7yieq + + + SequenceFlow_1s7yieq + SequenceFlow_00i7x43 + + + + + + + SequenceFlow_1h61pqs + + + + SequenceFlow_1kbzr5v + + + SequenceFlow_1h61pqs + SequenceFlow_1kbzr5v + + + + + + + SequenceFlow_00i7x43 + SequenceFlow_13mhe5h + SequenceFlow_0m483td + SequenceFlow_03bkrg4 + + + + SequenceFlow_0c5h00o + SequenceFlow_0dzz8fp + SequenceFlow_0m483rd + SequenceFlow_0m483st + + + SequenceFlow_0gd64w9 + + + + + SequenceFlow_144pxkp + SequenceFlow_0g4cl5f + + + + SequenceFlow_0g4cl5f + + + + + + + + + + + + + SequenceFlow_0ebobc7 + + + + SequenceFlow_0ebobc7 + SequenceFlow_1ugqw84 + + + + SequenceFlow_1ugqw84 + + + + + + + SequenceFlow_03bkrg4 + SequenceFlow_0oe57h4 + SequenceFlow_0ymy62j + + + + SequenceFlow_0sh1u69 + SequenceFlow_0m483st + SequenceFlow_04hdt5s + SequenceFlow_0m483td + + + + + + + + SequenceFlow_1c07scr + SequenceFlow_0xm9g9s + SequenceFlow_144pxkp + + + + + + SequenceFlow_0xm9g9s + + + + + SequenceFlow_13mhe5h + + + + + SequenceFlow_0bfuk6l + SequenceFlow_1c07scr + SequenceFlow_0oe57h4 + + + + + + + SequenceFlow_0gd64w9 + SequenceFlow_1fvfplx + SequenceFlow_0dzz8fp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn new file mode 100644 index 0000000000..f26bae0b39 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn @@ -0,0 +1,755 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + notFound + SequenceFlow_6 + + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_4 + + + + SequenceFlow_4 + notFound + found + + + + found + SequenceFlow_0gbsa12 + + + + SequenceFlow_6 + + + + SequenceFlow_17p4ohs + SequenceFlow_11 + + + + + SequenceFlow_09xwplc + + + + + + + + + + SequenceFlow_0gd64w9 + SequenceFlow_1q6udwm + + + + + + + + + + + + SequenceFlow_1q6udwm + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0c5h00o + + + + SequenceFlow_0c5h00o + SequenceFlow_1lalmvp + + + + + + + + + + + + SequenceFlow_1lalmvp + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_15z3gpq + + + + SequenceFlow_04t1zc2 + SequenceFlow_06w33tk + + + + + + + + + + + + SequenceFlow_06w33tk + SequenceFlow_1s7yieq + + + SequenceFlow_1s7yieq + SequenceFlow_00i7x43 + + + + + + + + + + + + + + + + + SequenceFlow_030mhcm + SequenceFlow_0q1hz2p + + + + + + + + + + + + + + SequenceFlow_1m8u8dl + SequenceFlow_1vg5rfa + + + + SequenceFlow_1vg5rfa + SequenceFlow_17p4ohs + SequenceFlow_0f7u5pu + + + + + + SequenceFlow_0f7u5pu + SequenceFlow_16o7col + + + + SequenceFlow_16o7col + + + + + + + SequenceFlow_1h61pqs + + + + SequenceFlow_0t4ut76 + + + SequenceFlow_1h61pqs + SequenceFlow_1kbzr5v + + + + SequenceFlow_1cxj4yz + SequenceFlow_0t4ut76 + + + + + + + + + + + + + + SequenceFlow_1kbzr5v + SequenceFlow_1cxj4yz + + + + + SequenceFlow_00i7x43 + SequenceFlow_07kxd8t + + + + SequenceFlow_15z3gpq + SequenceFlow_04t1zc2 + + + + SequenceFlow_0z8luou + SequenceFlow_08hhqb2 + SequenceFlow_030mhcm + + + + SequenceFlow_0q1hz2p + SequenceFlow_1iy3cqb + + + + + + SequenceFlow_0gbsa12 + SequenceFlow_1m8u8dl + SequenceFlow_0z8luou + + + + + + + SequenceFlow_0gd64w9 + + + + + SequenceFlow_11 + + + + + + + + SequenceFlow_1iy3cqb + SequenceFlow_09xwplc + + + + + + SequenceFlow_07kxd8t + SequenceFlow_08hhqb2 + + ${sdncReplDelay} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXCRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXCRollback.bpmn new file mode 100644 index 0000000000..490f2b637a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateAllottedResourceTXCRollback.bpmn @@ -0,0 +1,575 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_0bfuk6l + + + + SequenceFlow_0ymy62j + + + + + + + + + + + + + + + SequenceFlow_1fvfplx + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0c5h00o + + + + + + + + + + + + SequenceFlow_0m483rd + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_0sh1u69 + + + + + + + + + + + + SequenceFlow_04hdt5s + SequenceFlow_1s7yieq + + + SequenceFlow_1s7yieq + SequenceFlow_00i7x43 + + + + + + + SequenceFlow_1h61pqs + + + + SequenceFlow_1kbzr5v + + + SequenceFlow_1h61pqs + SequenceFlow_1kbzr5v + + + + + + + SequenceFlow_00i7x43 + SequenceFlow_13mhe5h + SequenceFlow_0m483td + SequenceFlow_03bkrg4 + + + + SequenceFlow_0c5h00o + SequenceFlow_0dzz8fp + SequenceFlow_0m483rd + SequenceFlow_0m483st + + + SequenceFlow_0gd64w9 + + + + + SequenceFlow_144pxkp + SequenceFlow_0g4cl5f + + + + SequenceFlow_0g4cl5f + + + + + + + + + + + + + SequenceFlow_0ebobc7 + + + + SequenceFlow_0ebobc7 + SequenceFlow_1ugqw84 + + + + SequenceFlow_1ugqw84 + + + + + + + SequenceFlow_03bkrg4 + SequenceFlow_0oe57h4 + SequenceFlow_0ymy62j + + + + SequenceFlow_0sh1u69 + SequenceFlow_0m483st + SequenceFlow_04hdt5s + SequenceFlow_0m483td + + + + + + + + SequenceFlow_1c07scr + SequenceFlow_0xm9g9s + SequenceFlow_144pxkp + + + + + + SequenceFlow_0xm9g9s + + + + + SequenceFlow_13mhe5h + + + + + SequenceFlow_0bfuk6l + SequenceFlow_1c07scr + SequenceFlow_0oe57h4 + + + + + + + SequenceFlow_0gd64w9 + SequenceFlow_1fvfplx + SequenceFlow_0dzz8fp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2ENetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2ENetworkInstance.bpmn new file mode 100644 index 0000000000..07de3fc0b1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2ENetworkInstance.bpmn @@ -0,0 +1,136 @@ + + + + + SequenceFlow_1gomb9n + + + SequenceFlow_1gomb9n + SequenceFlow_0s7w7gp + + + + SequenceFlow_1wtx8gj + SequenceFlow_0k06cqp + + + + + + + + + + + + SequenceFlow_0s7w7gp + SequenceFlow_1wtx8gj + + + SequenceFlow_0o6bjmn + + + + + + + + + + + + + SequenceFlow_0k06cqp + SequenceFlow_1oql7zl + + + SequenceFlow_1oql7zl + SequenceFlow_0o6bjmn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn new file mode 100644 index 0000000000..a5fadcf14b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -0,0 +1,544 @@ + + + + + SequenceFlow_1qiiycn + + + SequenceFlow_1qiiycn + SequenceFlow_0w9t6tc + + + + + + + + + + + + + + + SequenceFlow_1i7t9hq + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_1w01tqs + SequenceFlow_129ih1g + + + + + SequenceFlow_0tgrn11 + + + + SequenceFlow_1xzgv5k + + + + + + + + + + SequenceFlow_1lqktwf + SequenceFlow_0eumzpf + + + + + SequenceFlow_0tgrn11 + SequenceFlow_1lqktwf + + + + + SequenceFlow_0eumzpf + SequenceFlow_1xzgv5k + + + + + + SequenceFlow_4 + SequenceFlow_1w01tqs + + + + + SequenceFlow_129ih1g + SequenceFlow_1tkgqu3 + + + + + SequenceFlow_03ebqhf + SequenceFlow_1qctzm0 + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1qctzm0 + SequenceFlow_13xfsff + + + SequenceFlow_0w9t6tc + + + + SequenceFlow_012h7yx + + + + SequenceFlow_0xjwb45 + SequenceFlow_012h7yx + + + + + + + + + + + + SequenceFlow_0qxzgvq + SequenceFlow_0xjwb45 + + + SequenceFlow_166w91p + SequenceFlow_0qxzgvq + + + + SequenceFlow_166w91p + + + + + + + + SequenceFlow_1tkgqu3 + + + + + + SequenceFlow_1i7t9hq + + + + + SequenceFlow_1hbesp9 + + + + + SequenceFlow_01s0ef2 + SequenceFlow_03ebqhf + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0bf6bzp + SequenceFlow_0d0c20n + + + SequenceFlow_13xfsff + SequenceFlow_0bf6bzp + + + + SequenceFlow_0d0c20n + SequenceFlow_0a6vgsu + + + + + + + SequenceFlow_0a6vgsu + + + + + + + SequenceFlow_1hbesp9 + SequenceFlow_01s0ef2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceRollback.bpmn new file mode 100644 index 0000000000..c26ad9ae59 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceRollback.bpmn @@ -0,0 +1,373 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + SequenceFlow_01l4ssl + + + + SequenceFlow_8 + + + + SequenceFlow_7 + + + + SequenceFlow_8 + SequenceFlow_7 + + + + + + + SequenceFlow_06aasqh + SequenceFlow_11fnnkb + SequenceFlow_1uw2p9a + + + + + + + rollback AAI + SequenceFlow_1uw2p9a + SequenceFlow_1njogr1 + SequenceFlow_1n7wade + SequenceFlow_1x9eh33 + + + + + + + + + + + + + + + + + SequenceFlow_11fnnkb + SequenceFlow_0k28xib + + + SequenceFlow_0k28xib + SequenceFlow_0khjo7l + + + + + SequenceFlow_2 + SequenceFlow_06aasqh + SequenceFlow_1rzlaoy + + + SequenceFlow_05wu9i7 + SequenceFlow_1n7wade + SequenceFlow_1rzlaoy + SequenceFlow_01l4ssl + + + + + + + + + + SequenceFlow_1ch4xrf + + + + SequenceFlow_1ch4xrf + SequenceFlow_1pjk2ff + + + + SequenceFlow_1pjk2ff + + + + + + + SequenceFlow_006g9e8 + SequenceFlow_1njogr1 + + + + + + + + + + + + SequenceFlow_0khjo7l + SequenceFlow_006g9e8 + + + + + SequenceFlow_1x9eh33 + SequenceFlow_05wu9i7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn new file mode 100644 index 0000000000..4c107c7cb4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn @@ -0,0 +1,1051 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_0zmz5am + SequenceFlow_129ih1g + + + + + SequenceFlow_0tgrn11 + + + + SequenceFlow_1xzgv5k + + + + + + + + + + SequenceFlow_1lqktwf + SequenceFlow_0eumzpf + + + + + SequenceFlow_0tgrn11 + SequenceFlow_1lqktwf + + + + + SequenceFlow_0eumzpf + SequenceFlow_1xzgv5k + + + + + + SequenceFlow_4 + SequenceFlow_10aubhh + + + + SequenceFlow_129ih1g + SequenceFlow_03fabby + + + + + + SequenceFlow_13l7ffp + SequenceFlow_0gorww6 + + + + SequenceFlow_1wf52w6 + SequenceFlow_1t9tmp4 + SequenceFlow_14ef6wp + SequenceFlow_163tmnq + + + + + + + SequenceFlow_1t9tmp4 + SequenceFlow_1t4cc7w + + + + + + + + + + + + + + + + + SequenceFlow_1a1du22 + SequenceFlow_1p99k36 + + + + SequenceFlow_0cyffv0 + SequenceFlow_07q8ra0 + + + + SequenceFlow_06byir6 + SequenceFlow_0ylmq2b + + + + SequenceFlow_0vey6x4 + SequenceFlow_0br9juy + + + + SequenceFlow_0ylmq2b + SequenceFlow_07q8ra0 + SequenceFlow_0gxsqsa + SequenceFlow_1yhd9dp + + + + + SequenceFlow_1rhn48b + SequenceFlow_1mbrbsc + SequenceFlow_13l7ffp + SequenceFlow_1fq4qzy + + + + SequenceFlow_1r1hl23 + SequenceFlow_1ct6u3o + + + + SequenceFlow_1vio1tn + SequenceFlow_07pkpa0 + + + SequenceFlow_0br9juy + SequenceFlow_06byir6 + + + SequenceFlow_0cnuo36 + SequenceFlow_1lkpfe2 + + + + SequenceFlow_1t4cc7w + SequenceFlow_1a1du22 + SequenceFlow_14jy44g + + + + SequenceFlow_1p99k36 + SequenceFlow_14jy44g + SequenceFlow_0cyffv0 + + + + + + + + + + SequenceFlow_14ef6wp + SequenceFlow_0gxsqsa + + + + + + SequenceFlow_10aubhh + + + + SequenceFlow_0zmz5am + + + + + + SequenceFlow_1rhn48b + + + + + SequenceFlow_1ct6u3o + + + + + SequenceFlow_1rebkae + + + + SequenceFlow_1lkpfe2 + + + + + + + SequenceFlow_1fq4qzy + + + + SequenceFlow_10jgs3j + SequenceFlow_1wf52w6 + + + + + SequenceFlow_1yhd9dp + SequenceFlow_0uj9myy + + + + + + SequenceFlow_03fabby + + + + SequenceFlow_0e8oxe4 + + + + + SequenceFlow_07pkpa0 + SequenceFlow_01zluif + SequenceFlow_0vey6x4 + + + + + + + + SequenceFlow_163tmnq + SequenceFlow_01zluif + SequenceFlow_1vio1tn + + + + + + + SequenceFlow_0e8oxe4 + SequenceFlow_1sata7n + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1sata7n + SequenceFlow_0x0jvs1 + + + + + SequenceFlow_1rebkae + SequenceFlow_0gr3l25 + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0gr3l25 + SequenceFlow_0cnuo36 + + + + + SequenceFlow_0uj9myy + SequenceFlow_037rvnb + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_037rvnb + SequenceFlow_1mbrbsc + + + + SequenceFlow_0x0jvs1 + SequenceFlow_0aylb6e + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0aylb6e + SequenceFlow_1r1hl23 + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_01oo8ar + SequenceFlow_10jgs3j + + + + SequenceFlow_0gorww6 + SequenceFlow_01oo8ar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn new file mode 100644 index 0000000000..12dbfe6dde --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn @@ -0,0 +1,1363 @@ + + + + + SequenceFlow_1n61wit + + + isReturnCode404_No_SequenceFlow + + + + isNetworkActiveNo_SequenceFlow + isReturnCode404_Yes_SequenceFlow + SequenceFlow_21 + + + + SequenceFlow_21 + isNameSentNo_SequenceFlow + SequenceFlow_32 + + + + + isSdncRpc1No_SequenceFlow1 + SequenceFlow_11 + + + + + SequenceFlow_12 + SequenceFlow_0d93bqw + SequenceFlow_5 + + + + SequenceFlow_5 + sdncTopoNo_SequenceFlow + sdncTopoYes_SequenceFlow + + + + + + + + SequenceFlow_34 + + + + + sdncTopoNo_SequenceFlow + SequenceFlow_34 + + + + sdncTopoYes_SequenceFlow + SequenceFlow_16 + + + + + + + + + + + + + + SequenceFlow_11 + SequenceFlow_12 + + + + SequenceFlow_59 + SequenceFlow_13 + + + + isAAIQueryNameYes_SequenceFlow + isNetworkActiveYes_SequenceFlow + isNetworkActiveNo_SequenceFlow + + + + + + + SequenceFlow_6 + isAAIQueryNameNo_SequenceFlow + isAAIQueryNameYes_SequenceFlow + + + + + + + isAAIQueryNameNo_SequenceFlow + isReturnCode404_No_SequenceFlow + isReturnCode404_Yes_SequenceFlow + + + + + + + + SequenceFlow_23 + + + + + isRollbackOn_SequenceFlow_Yes + isPONR_Yes_SequenceFlow + isPONR_No_SequenceFlow + + + + + + + SequenceFlow_0k7y7b5 + sdncOk_Yeso_ExclusiveGateway + sdncOk_No_ExclusiveGateway + + + + + + + isSdncRpc4No_SequenceFlow4 + SequenceFlow_0lndbvr + + + + isPONR_No_SequenceFlow + SequenceFlow_0cly7z2 + SequenceFlow_12tlymf + + + + + + + sdncOk_Yeso_ExclusiveGateway + isSdncRpc4Yes_SequenceFlow4 + isSdncRpc4No_SequenceFlow4 + + + + + + + isSdncRpc4Yes_SequenceFlow4 + SequenceFlow_0bwpkkb + + + + SequenceFlow_1qwubew + + + SequenceFlow_15sffxc + SequenceFlow_096tad6 + + + + + SequenceFlow_0cly7z2 + SequenceFlow_0b8j5rw + + + + + + + + + + + + + + + + + + SequenceFlow_096tad6 + SequenceFlow_0vzsyrd + + + + + + + SequenceFlow_0vzsyrd + SequenceFlow_17nx822 + SequenceFlow_1qwubew + + + + + SequenceFlow_10ttvwn + isRollbackOn_SequenceFlow_Yes + isRollbackOn_SequenceFlow_No + + + + + + + SequenceFlow_0lndbvr + sdncOk_No_ExclusiveGateway + SequenceFlow_0bwpkkb + SequenceFlow_15sffxc + + + + SequenceFlow_0b8j5rw + SequenceFlow_12tlymf + SequenceFlow_0k7y7b5 + + + + isPONR_Yes_SequenceFlow + isRollbackOn_SequenceFlow_No + SequenceFlow_17nx822 + + + + SequenceFlow_23 + SequenceFlow_10ttvwn + + + + + + + PO Network Rollback is created in validation. + + + + + + + + ${CRENWKI_createNetworkRequest} + + + + #{BasicAuthHeaderValuePO} + application/xml + + + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_61 + SequenceFlow_59 + + + + + SequenceFlow_13 + SequenceFlow_35 + + + + + SequenceFlow_35 + SequenceFlow_1ipz2ze + + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + SequenceFlow_0ftylq3 + SequenceFlow_3 + + + isNameSentYes_SequenceFlow + SequenceFlow_6 + + + + + + SequenceFlow_3 + siFoundYes + siFoundNo + + + + + + + siFoundNo + + + + SequenceFlow_16 + SequenceFlow_15 + + + + + SequenceFlow_15 + SequenceFlow_38 + + + + + SequenceFlow_20 + SequenceFlow_61 + + + + + SequenceFlow_38 + SequenceFlow_20 + + + + + + SequenceFlow_1n61wit + SequenceFlow_0ftylq3 + + + + + siFoundYes + isNameSentYes_SequenceFlow + isNameSentNo_SequenceFlow + + + + + + + + + + + + + + + + SequenceFlow_13deudk + SequenceFlow_08qibb9 + + + isSdncRpc2Yes_SequenceFlow2 + SequenceFlow_13deudk + + + + SequenceFlow_1t03rs2 + SequenceFlow_1jia57e + SequenceFlow_18ybfu5 + + + + + + + + + + SequenceFlow_08qibb9 + SequenceFlow_1t03rs2 + + + + SequenceFlow_0s51ns0 + + + + + SequenceFlow_18ybfu5 + SequenceFlow_0s51ns0 + + + + SequenceFlow_32 + isSdncRpc1No_SequenceFlow1 + isSdncRpc1Yes_SequenceFlow1 + + + + + + + + + + + + + + + + SequenceFlow_0j8bxnb + SequenceFlow_0d93bqw + + + + + SequenceFlow_1ipz2ze + isSdncRpc2Yes_SequenceFlow2 + isSdncRpc2No_SequenceFlow2 + + + + + + + isSdncRpc1Yes_SequenceFlow1 + SequenceFlow_0j8bxnb + + + + SequenceFlow_1s8b1m1 + + + SequenceFlow_18ylufb + + + + SequenceFlow_1jia57e + isSdncRpc2No_SequenceFlow2 + SequenceFlow_1s8b1m1 + + + + + isNetworkActiveYes_SequenceFlow + SequenceFlow_18ylufb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn new file mode 100644 index 0000000000..6a4861b9a4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn @@ -0,0 +1,517 @@ + + + + + SequenceFlow_1krl2dg + + + SequenceFlow_1krl2dg + SequenceFlow_0u41iz2 + + + + + + + + + + + + + + + SequenceFlow_1mxbdps + SequenceFlow_07s5r14 + + + + + + + + + + + + SequenceFlow_0mw0dgd + SequenceFlow_1rrutp3 + + + SequenceFlow_0u41iz2 + SequenceFlow_1bb7zpp + SequenceFlow_1mxbdps + + + SequenceFlow_1bb7zpp + SequenceFlow_07s5r14 + SequenceFlow_0e1uixp + SequenceFlow_1lteduj + + + + + + + + + + + + SequenceFlow_101y57s + SequenceFlow_0790olb + + + SequenceFlow_0virkpu + SequenceFlow_101y57s + SequenceFlow_0mw0dgd + + + SequenceFlow_0qc4v9t + SequenceFlow_0el8yzs + SequenceFlow_0yto4gz + + + + SequenceFlow_1lteduj + SequenceFlow_17o4w67 + SequenceFlow_0virkpu + SequenceFlow_0qc4v9t + + + + + + + + + + + + + + + + + + + + SequenceFlow_0yto4gz + + + + + + + SequenceFlow_0xktw7v + SequenceFlow_0soe5t3 + + + + SequenceFlow_0xktw7v + + + + SequenceFlow_0soe5t3 + + + + + + SequenceFlow_1rrutp3 + SequenceFlow_0790olb + SequenceFlow_0el8yzs + + + + + + SequenceFlow_0lomcvn + + + SequenceFlow_0q0te67 + SequenceFlow_0lomcvn + + + + + + SequenceFlow_0q0te67 + + + + + SequenceFlow_0ctlrql + + + + + SequenceFlow_0ctlrql + + + + SequenceFlow_1j55a94 + + + + SequenceFlow_1yn24xq + + + + SequenceFlow_1j55a94 + SequenceFlow_1yn24xq + + + + + + SequenceFlow_0e1uixp + SequenceFlow_17o4w67 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn new file mode 100644 index 0000000000..dc2cf9b676 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn @@ -0,0 +1,370 @@ + + + + + SequenceFlow_1qiiycn + + + SequenceFlow_1qiiycn + SequenceFlow_0w9t6tc + + + + SequenceFlow_16nxl6h + SequenceFlow_0epxs3b + + + + SequenceFlow_0k0f7lm + SequenceFlow_11f2zuu + + + + SequenceFlow_1hbesp9 + SequenceFlow_13d9g1n + + + + + SequenceFlow_1jenxlp + SequenceFlow_0q6uy30 + SequenceFlow_16nxl6h + + + + SequenceFlow_13c7bhn + SequenceFlow_1jenxlp + + + + + SequenceFlow_0q6uy30 + SequenceFlow_1qozd66 + SequenceFlow_0uiygod + + + + SequenceFlow_13d9g1n + SequenceFlow_18wj44x + SequenceFlow_1vprtt9 + + + + SequenceFlow_0uiygod + SequenceFlow_1u9k0dm + + + + SequenceFlow_1u9k0dm + SequenceFlow_13c7bhn + + + + SequenceFlow_0w9t6tc + + + + + + SequenceFlow_18wj44x + SequenceFlow_11f2zuu + + + + + + + SequenceFlow_1hbesp9 + + + + + SequenceFlow_1qozd66 + + + + + + + + + + + SequenceFlow_0epxs3b + + + + + SequenceFlow_0gr9xqj + + + + SequenceFlow_0a6l29p + + + SequenceFlow_0gr9xqj + SequenceFlow_0a6l29p + + + + + + + SequenceFlow_1vprtt9 + SequenceFlow_0k0f7lm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn new file mode 100644 index 0000000000..29116a67fc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn @@ -0,0 +1,515 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_2 + SequenceFlow_3 + + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + SequenceFlow_156ih25 + SequenceFlow_14 + + + + SequenceFlow_9 + SequenceFlow_10 + + + + + + + + + + + + SequenceFlow_14 + SequenceFlow_9 + + + SequenceFlow_01q6pl4 + + + + + + + + + + + + + + + SequenceFlow_11fnnkb + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_1uw2p9a + SequenceFlow_1w01tqs + SequenceFlow_1jhzmzn + + + SequenceFlow_3 + SequenceFlow_11fnnkb + SequenceFlow_1uw2p9a + + + + + + + + SequenceFlow_0tgrn11 + + + + SequenceFlow_1xzgv5k + + + + + + + + + + SequenceFlow_1lqktwf + SequenceFlow_0eumzpf + + + + + SequenceFlow_0tgrn11 + SequenceFlow_1lqktwf + + + + + SequenceFlow_0eumzpf + SequenceFlow_1xzgv5k + + + + + + SequenceFlow_0w5i6vf + SequenceFlow_156ih25 + SequenceFlow_00v4npo + + + + SequenceFlow_00v4npo + + + + + + SequenceFlow_4 + SequenceFlow_1w01tqs + + + + + + + + + + + + + + + SequenceFlow_10 + SequenceFlow_0tx5frq + + + + + SequenceFlow_0tx5frq + SequenceFlow_01q6pl4 + + + + SequenceFlow_1jhzmzn + SequenceFlow_16sdyz9 + + + + + SequenceFlow_16sdyz9 + SequenceFlow_0k0wn03 + + + + SequenceFlow_0k0wn03 + SequenceFlow_0w5i6vf + + + + + + + + SequenceFlow_0x48any + SequenceFlow_052o4xc + + + + SequenceFlow_0x48any + + + + SequenceFlow_052o4xc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn new file mode 100644 index 0000000000..eb3e35f6fe --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn @@ -0,0 +1,373 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + SequenceFlow_01l4ssl + + + + SequenceFlow_8 + + + + SequenceFlow_7 + + + + SequenceFlow_8 + SequenceFlow_7 + + + + + + + SequenceFlow_06aasqh + SequenceFlow_11fnnkb + SequenceFlow_1uw2p9a + + + + + + + rollback AAI + SequenceFlow_1uw2p9a + SequenceFlow_1njogr1 + SequenceFlow_1n7wade + SequenceFlow_1x9eh33 + + + + + + + + + + + + + SequenceFlow_11fnnkb + SequenceFlow_0k28xib + + + SequenceFlow_0k28xib + SequenceFlow_0khjo7l + + + + + SequenceFlow_2 + SequenceFlow_06aasqh + SequenceFlow_1rzlaoy + + + SequenceFlow_1n7wade + SequenceFlow_1rzlaoy + SequenceFlow_0h3wkj4 + SequenceFlow_01l4ssl + + + + + + + + + + SequenceFlow_1ch4xrf + + + + SequenceFlow_1ch4xrf + SequenceFlow_1pjk2ff + + + + SequenceFlow_1pjk2ff + + + + + + + SequenceFlow_006g9e8 + SequenceFlow_1njogr1 + + + + + + + + + + + + SequenceFlow_0khjo7l + SequenceFlow_006g9e8 + + + + + SequenceFlow_1x9eh33 + SequenceFlow_0h3wkj4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollbackV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollbackV2.bpmn new file mode 100644 index 0000000000..88a99c2938 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceRollbackV2.bpmn @@ -0,0 +1,103 @@ + + + + + SequenceFlow_0r35zfs + + + + SequenceFlow_1f949uf + + + + SequenceFlow_0r35zfs + SequenceFlow_1f949uf + + + + + SequenceFlow_1tnfu1n + + + + + SequenceFlow_0hi9120 + + + + SequenceFlow_1tnfu1n + SequenceFlow_0hi9120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceV2.bpmn new file mode 100644 index 0000000000..e8dbc8c7f6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstanceV2.bpmn @@ -0,0 +1,197 @@ + + + + + SequenceFlow_0g8qp84 + + + + + SequenceFlow_0ekno6w + SequenceFlow_1t50vt9 + SequenceFlow_0xhy3o1 + + + + + + + SequenceFlow_0xhy3o1 + + + + SequenceFlow_0eryvle + + + + SequenceFlow_0g8qp84 + SequenceFlow_0651nnp + + + + SequenceFlow_0651nnp + SequenceFlow_0u0ptz7 + + + + SequenceFlow_0u0ptz7 + SequenceFlow_0ekno6w + + + + SequenceFlow_1t50vt9 + SequenceFlow_0eryvle + + + + + SequenceFlow_0mk8fd7 + + + + SequenceFlow_14mdxgk + + + + + + + + + + SequenceFlow_0mk8fd7 + SequenceFlow_14mdxgk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn new file mode 100644 index 0000000000..c151370698 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVFCNetworkServiceInstance.bpmn @@ -0,0 +1,261 @@ + + + + + SequenceFlow_1qo2pln + + + + + + SequenceFlow_0khtova + SequenceFlow_1uiz85h + + + + SequenceFlow_1qo2pln + SequenceFlow_0khtova + + + + createNSSuccess_SequenceFlow + SequenceFlow_1ywe21t + + + + SequenceFlow_1uiz85h + createNSSuccess_SequenceFlow + createNSFailed_SequenceFlow + + + + + + + + + SequenceFlow_1ywe21t + instantiateFailed_SequenceFlow + instantiateSuccess_SequenceFlow + + + + + + + + + + SequenceFlow_0xqo13p + operationFinished_SequenceFlow + operationProcessing_SequenceFlow + + + + + + + + + + createNSFailed_SequenceFlow + + + instantiateFailed_SequenceFlow + + + SequenceFlow_0cq2q6g + + + instantiateSuccess_SequenceFlow + SequenceFlow_1gsbpxj + SequenceFlow_0xqo13p + + + + operationFinished_SequenceFlow + SequenceFlow_0cq2q6g + + + + + operationProcessing_SequenceFlow + SequenceFlow_1gsbpxj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn new file mode 100644 index 0000000000..820d1174be --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn @@ -0,0 +1,1701 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_15 + + + + + SequenceFlow_15 + SequenceFlow_11 + SequenceFlow_40 + + + + + + + + + + + + + + SequenceFlow_43 + SequenceFlow_17 + + + + SequenceFlow_17 + SequenceFlow_19 + SequenceFlow_21 + + + + + + + + + + + + + + + SequenceFlow_19 + SequenceFlow_35 + + + + SequenceFlow_11 + SequenceFlow_21 + SequenceFlow_35 + SequenceFlow_6 + + + + + + + + + + + + + SequenceFlow_18 + SequenceFlow_20 + + + SequenceFlow_20 + SequenceFlow_1nh92s8 + + + + SequenceFlow_8 + SequenceFlow_18 + + + + + + SequenceFlow_0p61zug + SequenceFlow_0aegg0r + SequenceFlow_23 + + + + + + + + + + + + + SequenceFlow_23 + SequenceFlow_24 + + + + + SequenceFlow_24 + SequenceFlow_31 + + + + + + + + + + SequenceFlow_5 + SequenceFlow_10 + + + SequenceFlow_1avfxsz + SequenceFlow_5 + + + + SequenceFlow_10 + SequenceFlow_12 + + + + + + + + + + + + + SequenceFlow_12 + SequenceFlow_13 + + + SequenceFlow_13 + SequenceFlow_14 + + + + SequenceFlow_14 + SequenceFlow_30 + SequenceFlow_28 + + + + + + + + + SequenceFlow_0363dz7 + + + + SequenceFlow_8 + + + + + SequenceFlow_28 + SequenceFlow_3 + + + + + + + + + + SequenceFlow_3 + SequenceFlow_29 + + + + + SequenceFlow_30 + SequenceFlow_29 + SequenceFlow_16 + + + + SequenceFlow_31 + SequenceFlow_32 + + + + + + + + + + + + SequenceFlow_32 + SequenceFlow_33 + + + SequenceFlow_33 + SequenceFlow_1ushk1d + + + + SequenceFlow_0xfanpi + SequenceFlow_0abffyj + + + + + + + SequenceFlow_0zcfn2x + SequenceFlow_170kw7h + + + + SequenceFlow_39 + SequenceFlow_37 + SequenceFlow_0zcfn2x + SequenceFlow_0m382su + + + SequenceFlow_25 + SequenceFlow_27 + + + + + SequenceFlow_27 + SequenceFlow_36 + SequenceFlow_39 + + + + + + + SequenceFlow_36 + SequenceFlow_37 + + + + + SequenceFlow_16 + SequenceFlow_7 + + + + + SequenceFlow_7 + + + + SequenceFlow_40 + SequenceFlow_43 + + + + + + + + SequenceFlow_1 + SequenceFlow_4 + + + + + SequenceFlow_1f53tby + SequenceFlow_0270n5c + + + + + + + + + + + + + + + + + + + + + SequenceFlow_6 + SequenceFlow_25 + + + + SequenceFlow_1ushk1d + SequenceFlow_0ery1pk + SequenceFlow_0xfanpi + + + + + + + + + SequenceFlow_0ery1pk + SequenceFlow_0abffyj + + + + SequenceFlow_0363dz7 + SequenceFlow_0bi38s7 + SequenceFlow_1k5uku2 + + + SequenceFlow_112los9 + SequenceFlow_1k5uku2 + SequenceFlow_1avfxsz + + + + + + + + + + + SequenceFlow_0bi38s7 + SequenceFlow_1qm81ym + + + + + + + + + + + SequenceFlow_1qm81ym + SequenceFlow_112los9 + + + + + + + + + SequenceFlow_0d00zqi + SequenceFlow_0g270u0 + + + + + + + + + + + + + SequenceFlow_0g270u0 + SequenceFlow_1yrlvgb + + + SequenceFlow_1yrlvgb + SequenceFlow_170kw7h + + + + + + + + + + + + + SequenceFlow_0m382su + SequenceFlow_0d00zqi + + + + SequenceFlow_1y1ttqe + SequenceFlow_0lilmm3 + SequenceFlow_0270n5c + SequenceFlow_05og7iw + + + + + + + + + + + + + + + + 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 + + + + + + SequenceFlow_0cc17yk + SequenceFlow_17cp3tn + SequenceFlow_006rnym + + + + + + SequenceFlow_4 + SequenceFlow_1y1ttqe + SequenceFlow_1y8q87e + + + + SequenceFlow_1sf1091 + SequenceFlow_0lilmm3 + SequenceFlow_15i583d + + + + + + + + + + + SequenceFlow_00bh7m7 + + + + + + + SequenceFlow_1nh92s8 + SequenceFlow_16mgvsd + SequenceFlow_1iyt5i4 + + + + + + + + + + + + + + + + + + + SequenceFlow_0ynd0iy + SequenceFlow_1mnipp8 + + + SequenceFlow_17cp3tn + SequenceFlow_0ynd0iy + + + + SequenceFlow_16mgvsd + SequenceFlow_0cc17yk + + + + SequenceFlow_1y8q87e + SequenceFlow_1sf1091 + + + + SequenceFlow_1mnipp8 + SequenceFlow_00bh7m7 + + + + SequenceFlow_15i583d + SequenceFlow_0tfrcnc + SequenceFlow_0oadvvx + + + + + + + SequenceFlow_0tfrcnc + SequenceFlow_0c6p4aa + SequenceFlow_1qzw172 + + + + + + SequenceFlow_1qzw172 + SequenceFlow_0xed5sn + SequenceFlow_0p3cspl + + + + + + + SequenceFlow_0xed5sn + SequenceFlow_1k7xbcu + SequenceFlow_0p61zug + + + + + SequenceFlow_0oadvvx + SequenceFlow_03batve + + + + + + + + + + + + + + SequenceFlow_03batve + SequenceFlow_0c6p4aa + + + SequenceFlow_0p3cspl + SequenceFlow_1k7xbcu + + + + SequenceFlow_006rnym + SequenceFlow_1iyt5i4 + SequenceFlow_0thm33s + + + + + + + + + + SequenceFlow_0thm33s + SequenceFlow_0aegg0r + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn new file mode 100644 index 0000000000..2508b31f01 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn @@ -0,0 +1,978 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_11er1t8 + SequenceFlow_6 + SequenceFlow_9 + + + + + + + + + SequenceFlow_6 + SequenceFlow_8 + + + + + + + + SequenceFlow_8 + SequenceFlow_9 + SequenceFlow_10 + SequenceFlow_15 + + + SequenceFlow_1p0v6yk + SequenceFlow_16 + + + + + + + + + + + + + SequenceFlow_16 + SequenceFlow_08aruzz + + + + + + + SequenceFlow_13 + SequenceFlow_14 + + + + + + + + + + SequenceFlow_14 + SequenceFlow_18 + + + + SequenceFlow_1gcfdej + SequenceFlow_13 + SequenceFlow_17 + + + + + + + SequenceFlow_17 + SequenceFlow_18 + SequenceFlow_19 + SequenceFlow_20 + + + + + + + SequenceFlow_1rpg6ac + SequenceFlow_32 + + + + + + + + + + + + + + SequenceFlow_32 + SequenceFlow_2 + + + SequenceFlow_20 + SequenceFlow_4 + SequenceFlow_12otwa4 + SequenceFlow_21 + SequenceFlow_24 + + + + + + + + + + + + + SequenceFlow_34 + SequenceFlow_35 + + + + SequenceFlow_0ggp8wz + SequenceFlow_1h8ve60 + + + SequenceFlow_24 + SequenceFlow_34 + + + + + + SequenceFlow_2 + SequenceFlow_4 + + + + + + SequenceFlow_12 + + + + SequenceFlow_22 + + + + + SequenceFlow_02fx6z6 + SequenceFlow_22 + + + + + SequenceFlow_12 + SequenceFlow_02fx6z6 + + + + + SequenceFlow_23 + + + + SequenceFlow_23 + + + + SequenceFlow_1 + SequenceFlow_5 + + + + + SequenceFlow_0djpj3r + SequenceFlow_0n58kg1 + SequenceFlow_185bo77 + SequenceFlow_111l1he + + + SequenceFlow_0unumxv + SequenceFlow_0djpj3r + + + + SequenceFlow_111l1he + SequenceFlow_0ca4brn + + + + + + + + + + + SequenceFlow_0ca4brn + SequenceFlow_19r2uus + + + + SequenceFlow_185bo77 + SequenceFlow_19r2uus + SequenceFlow_1p0v6yk + SequenceFlow_03i4czf + + + + + + + + + + + + + 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_17it51d + SequenceFlow_1h8ve60 + + + + SequenceFlow_03i4czf + SequenceFlow_08aruzz + SequenceFlow_1gcfdej + SequenceFlow_17ne2iz + + + + + + + + + + + + + + SequenceFlow_0fvuowt + SequenceFlow_17it51d + + + SequenceFlow_17ne2iz + SequenceFlow_0fvuowt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn new file mode 100644 index 0000000000..a762b7ecd7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn new file mode 100644 index 0000000000..ac48776c95 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn new file mode 100644 index 0000000000..dacce53963 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -0,0 +1,635 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + notFound + SequenceFlow_6 + + + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_4 + + + + SequenceFlow_4 + notFound + found + + + + + + + SequenceFlow_7 + vnfExistYes + vnfExistNo + + + + + + + + + + + + + + + + VnfNameSpecified1 + SequenceFlow_7 + + + + vnfExistYes + SequenceFlow_10 + + + + + SequenceFlow_6 + + + + SequenceFlow_10 + + + + vnfExistNo + VnfNameNotSpecified1 + SequenceFlow_11 + + + + + + SequenceFlow_8 + SequenceFlow_9 + + + + + SequenceFlow_9 + + + SequenceFlow_8 + + + + + + SdncInteractionNotEnabled + SequenceFlow_0bj7c4s + + + + + + + + + SdncInteractionEnabled + SequenceFlow_1q6udwm + + + + + + + + + + + + + SequenceFlow_1q6udwm + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0lnh79j + + + + SequenceFlow_1q1poly + VnfNameSpecified2 + SequenceFlow_1lalmvp + + + + + + + + + + + + + SequenceFlow_1lalmvp + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_15z3gpq + + + + SequenceFlow_1gc18ih + SdncInteractionEnabled + SdncInteractionNotEnabled + + + + + + + + SequenceFlow_11 + SequenceFlow_1gc18ih + + + + found + VnfNameNotSpecified1 + VnfNameSpecified1 + + + + + + + + + + SequenceFlow_0lnh79j + VnfNameNotSpecified2 + VnfNameSpecified2 + + + + + + + + VnfNameNotSpecified2 + SequenceFlow_1h9jdgr + + + + + + + + + + + + + SequenceFlow_1h9jdgr + SequenceFlow_14xac2y + + + SequenceFlow_14xac2y + SequenceFlow_1q1poly + + + + + + + + + + + + SequenceFlow_0nhsdmj + SequenceFlow_0bj7c4s + + + + SequenceFlow_15z3gpq + SequenceFlow_0nhsdmj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn new file mode 100644 index 0000000000..d817f5703b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn @@ -0,0 +1,527 @@ + + + + + SequenceFlow_0o4vuzt + + + SequenceFlow_0o4vuzt + SequenceFlow_1xd3ri5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1hf7k7q + SequenceFlow_1ixcnb6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1lh21yl + SequenceFlow_1llbx0k + + + SequenceFlow_1llbx0k + SequenceFlow_1mguf2m + + + + SequenceFlow_132bohl + + + + + + + + + + SequenceFlow_1a6wyuu + SequenceFlow_0j52dxv + SequenceFlow_132bohl + SequenceFlow_0jz6bqn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_19ohb1a + SequenceFlow_07u8e3l + + + SequenceFlow_0jz6bqn + SequenceFlow_12x4dvf + + + + SequenceFlow_1xd3ri5 + SequenceFlow_19ohb1a + + + + SequenceFlow_1mguf2m + SequenceFlow_12x4dvf + SequenceFlow_0kld3qt + SequenceFlow_1vrogpr + + + + + + + + + + + + + + + + + + + + + SequenceFlow_07u8e3l + SequenceFlow_1hf7k7q + + + + + + + + + + + + SequenceFlow_0kld3qt + SequenceFlow_1lh21yl + + + + + + + SequenceFlow_1ixcnb6 + SequenceFlow_1a6wyuu + + + + + SequenceFlow_1h74w1v + + + + + + + + + + + SequenceFlow_03v8mmc + SequenceFlow_0yu0im2 + + + SequenceFlow_1l0rxnh + SequenceFlow_03v8mmc + + + + SequenceFlow_0yu0im2 + SequenceFlow_1h74w1v + + + + + + + + SequenceFlow_1l0rxnh + + + + + + + + SequenceFlow_1vrogpr + SequenceFlow_0j52dxv + + + + + + SequenceFlow_07u8e3l + SequenceFlow_1t407j7 + + + + SequenceFlow_1t407j7 + SequenceFlow_0baw1tl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn new file mode 100644 index 0000000000..a900a4e241 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModulesRollback.bpmn @@ -0,0 +1,541 @@ + + + + + + SequenceFlow_12 + + + + SequenceFlow_22 + + + + SequenceFlow_1wch84s + SequenceFlow_22 + + + + + + SequenceFlow_12 + SequenceFlow_1wch84s + + + + + SequenceFlow_23 + + + + SequenceFlow_23 + + + + SequenceFlow_1537b7m + + + SequenceFlow_1srw52v + SequenceFlow_0zjzorm + SequenceFlow_19xaddm + SequenceFlow_1r6wyy6 + SequenceFlow_0v85t87 + + + SequenceFlow_1g6psjt + SequenceFlow_152tazp + SequenceFlow_1kr0r4a + SequenceFlow_1yas9ol + + + SequenceFlow_0mk9lrj + SequenceFlow_03cc9y6 + + + + SequenceFlow_1537b7m + SequenceFlow_0bmsi5h + + + + + + SequenceFlow_0v85t87 + SequenceFlow_1ycq005 + + + + + + + + + + + + + + + + SequenceFlow_1ycq005 + SequenceFlow_181hb2a + + + + 0}]]> + + + + + + + + + + + + + SequenceFlow_1kr0r4a + SequenceFlow_04yd2yr + + + + SequenceFlow_181hb2a + SequenceFlow_1srw52v + + + + + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn new file mode 100644 index 0000000000..73c21090ea --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn @@ -0,0 +1,470 @@ + + + + + SequenceFlow_0vz7cd9 + + + SequenceFlow_0vz7cd9 + SequenceFlow_11e6bfy + + + + SequenceFlow_0e7inkl + + + SequenceFlow_188ejvu + SequenceFlow_0vi0sv6 + + + + SequenceFlow_0oj2anh + SequenceFlow_1ev7z6q + SequenceFlow_0e7inkl + + + + + SequenceFlow_1921mo3 + + + + SequenceFlow_18vlzfo + + + SequenceFlow_1921mo3 + SequenceFlow_18vlzfo + + + + + + + + + + + SequenceFlow_1ubor5z + SequenceFlow_1dza4q4 + + + + + + SequenceFlow_1x3lehs + SequenceFlow_1wnkgpx + + + + + + + + + + + + + + SequenceFlow_1wnkgpx + SequenceFlow_0phwem2 + + + SequenceFlow_1dza4q4 + SequenceFlow_1lxqjmp + + + SequenceFlow_1icwpye + SequenceFlow_1ev7z6q + + + SequenceFlow_0vi0sv6 + SequenceFlow_1ym9otf + + + + + + + ${URN_mso_adapters_openecomp_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1ym9otf + SequenceFlow_1j08ko3 + + + + + + + + + + + + + + + SequenceFlow_11e6bfy + SequenceFlow_188ejvu + + + + SequenceFlow_1j08ko3 + SequenceFlow_03c0zlq + + + + + SequenceFlow_1htjmkv + SequenceFlow_1ubor5z + SequenceFlow_1x3lehs + + + SequenceFlow_03c0zlq + SequenceFlow_0s1lswk + SequenceFlow_1htjmkv + + + + + + + + + + + + SequenceFlow_1lxqjmp + SequenceFlow_0phwem2 + SequenceFlow_0l5r96s + + + + + + SequenceFlow_0l5r96s + SequenceFlow_0talboa + SequenceFlow_0s1lswk + + + + SequenceFlow_0talboa + SequenceFlow_1icwpye + SequenceFlow_0oj2anh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn new file mode 100644 index 0000000000..3e76f61224 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn @@ -0,0 +1,928 @@ + + + + + SequenceFlow_0vz7cd9 + + + SequenceFlow_0vz7cd9 + SequenceFlow_11e6bfy + + + + SequenceFlow_06tonva + + + SequenceFlow_188ejvu + SequenceFlow_00a3ijv + + + + SequenceFlow_0t5f2dt + SequenceFlow_0e7inkl + + + + + SequenceFlow_1921mo3 + + + + SequenceFlow_18vlzfo + + + SequenceFlow_1921mo3 + SequenceFlow_18vlzfo + + + + + + + + + + SequenceFlow_1931m8u + SequenceFlow_17b01zs + + + + SequenceFlow_1w2n8dn + SequenceFlow_09z6zl7 + + + + SequenceFlow_1jfyo1x + SequenceFlow_1t1mg6y + + + + + + + SequenceFlow_1bx4es4 + SequenceFlow_1wnkgpx + + + + + + + + + + + + + + SequenceFlow_1wnkgpx + SequenceFlow_1931m8u + + + SequenceFlow_0a1q5fw + SequenceFlow_0rpu756 + + + + + SequenceFlow_1lv9vmb + SequenceFlow_16r9z75 + + + + SequenceFlow_0m7ks9t + SequenceFlow_1g4djgh + + + SequenceFlow_0akcnw7 + SequenceFlow_0uc2beq + + + + + + + + + + + + + + SequenceFlow_11e6bfy + SequenceFlow_188ejvu + + + + SequenceFlow_1qzxy2i + + + + SequenceFlow_1jfyo1x + + + + + + SequenceFlow_09z6zl7 + + + + + SequenceFlow_0homduu + + + + + SequenceFlow_0t5f2dt + + + + + SequenceFlow_0homduu + SequenceFlow_0eoibq3 + SequenceFlow_0n7qeqt + SequenceFlow_13c2v9z + + + + SequenceFlow_0n7qeqt + SequenceFlow_1a5ki3p + + + + + SequenceFlow_17b01zs + SequenceFlow_0gxv0wp + + + + + SequenceFlow_13c2v9z + + + + + + + SequenceFlow_1t1mg6y + SequenceFlow_0a1q5fw + SequenceFlow_1fac57w + + + + + + + SequenceFlow_0rpu756 + SequenceFlow_1fac57w + SequenceFlow_1lv9vmb + + + + + SequenceFlow_16r9z75 + SequenceFlow_0m7ks9t + SequenceFlow_00knko8 + + + + + + + SequenceFlow_1g4djgh + SequenceFlow_00knko8 + SequenceFlow_0akcnw7 + SequenceFlow_15pzf5n + + + + + + + SequenceFlow_033eqeg + + + + + SequenceFlow_00a3ijv + + + + + SequenceFlow_18wibmi + SequenceFlow_11405m9 + + + + + SequenceFlow_033eqeg + SequenceFlow_1sm5x5e + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1sm5x5e + SequenceFlow_18wibmi + + + + + SequenceFlow_0e7inkl + SequenceFlow_0l4qcge + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0l4qcge + SequenceFlow_06tonva + + + + + SequenceFlow_0gxv0wp + SequenceFlow_1i96ytk + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1i96ytk + SequenceFlow_0eoibq3 + + + + SequenceFlow_1a5ki3p + SequenceFlow_1oo4g4h + + + + + SequenceFlow_0uc2beq + SequenceFlow_15pzf5n + SequenceFlow_1w2n8dn + + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateServiceOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1oo4g4h + SequenceFlow_1bx4es4 + + + + SequenceFlow_11405m9 + SequenceFlow_15d5odq + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_15d5odq + SequenceFlow_1qzxy2i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceBRG.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceBRG.bpmn new file mode 100644 index 0000000000..b10d6b1b18 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceBRG.bpmn @@ -0,0 +1,422 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_0bfuk6l + + + + SequenceFlow_0bfuk6l + SequenceFlow_0xm9g9s + + + + SequenceFlow_0ymy62j + + + + + + + + + + SequenceFlow_0gd64w9 + SequenceFlow_1q6udwm + + + + + + + + + + + + SequenceFlow_1q6udwm + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0c5h00o + + + + foundInSDNC + SequenceFlow_1lalmvp + + + + + + + + + + + + SequenceFlow_1lalmvp + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_15z3gpq + + + + SequenceFlow_15z3gpq + SequenceFlow_06w33tk + + + + + + + + + + + + SequenceFlow_06w33tk + SequenceFlow_1s7yieq + + + SequenceFlow_1s7yieq + SequenceFlow_00i7x43 + + + + + + + + SequenceFlow_1h61pqs + + + + SequenceFlow_1kbzr5v + + + SequenceFlow_1h61pqs + SequenceFlow_1kbzr5v + + + + + + + SequenceFlow_00i7x43 + notFoundInSDNC + SequenceFlow_0ymy62j + + + + SequenceFlow_0c5h00o + foundInSDNC + notFoundInSDNC + + + SequenceFlow_0gd64w9 + + + + + SequenceFlow_0xm9g9s + SequenceFlow_0g4cl5f + + + + SequenceFlow_0g4cl5f + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceTXC.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceTXC.bpmn new file mode 100644 index 0000000000..84895e225d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteAllottedResourceTXC.bpmn @@ -0,0 +1,422 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_0bfuk6l + + + + SequenceFlow_0bfuk6l + SequenceFlow_0xm9g9s + + + + SequenceFlow_0ymy62j + + + + + + + + + + SequenceFlow_0gd64w9 + SequenceFlow_1q6udwm + + + + + + + + + + + + SequenceFlow_1q6udwm + SequenceFlow_15knw0q + + + SequenceFlow_15knw0q + SequenceFlow_0c5h00o + + + + foundInSDNC + SequenceFlow_1lalmvp + + + + + + + + + + + + SequenceFlow_1lalmvp + SequenceFlow_0eb41vb + + + SequenceFlow_0eb41vb + SequenceFlow_15z3gpq + + + + SequenceFlow_15z3gpq + SequenceFlow_06w33tk + + + + + + + + + + + + SequenceFlow_06w33tk + SequenceFlow_1s7yieq + + + SequenceFlow_1s7yieq + SequenceFlow_00i7x43 + + + + + + + + SequenceFlow_1h61pqs + + + + SequenceFlow_1kbzr5v + + + SequenceFlow_1h61pqs + SequenceFlow_1kbzr5v + + + + + + + SequenceFlow_00i7x43 + notFoundInSDNC + SequenceFlow_0ymy62j + + + + SequenceFlow_0c5h00o + foundInSDNC + notFoundInSDNC + + + SequenceFlow_0gd64w9 + + + + + SequenceFlow_0xm9g9s + SequenceFlow_0g4cl5f + + + + SequenceFlow_0g4cl5f + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn new file mode 100644 index 0000000000..a975ebdee0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn @@ -0,0 +1,378 @@ + + + + + SequenceFlow_0vz7cd9 + + + SequenceFlow_0vz7cd9 + SequenceFlow_11e6bfy + + + + SequenceFlow_0e7inkl + + + SequenceFlow_188ejvu + SequenceFlow_0vi0sv6 + + + + SequenceFlow_1cevtpy + SequenceFlow_0e7inkl + + + + + SequenceFlow_1921mo3 + + + + SequenceFlow_18vlzfo + + + SequenceFlow_1921mo3 + SequenceFlow_18vlzfo + + + + + + + + + + SequenceFlow_1961633 + SequenceFlow_1ym9otf + + + + + + + ${URN_mso_adapters_openecomp_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_1ym9otf + SequenceFlow_1j08ko3 + + + + + + + + + + + + + + + SequenceFlow_11e6bfy + SequenceFlow_188ejvu + + + + + + + + SequenceFlow_0ha8ix9 + + + + SequenceFlow_1961633 + + + + + SequenceFlow_1q2mqnm + SequenceFlow_0fo5vw5 + + + + + + + + + + + + + + + SequenceFlow_0fo5vw5 + SequenceFlow_0orw2f8 + + + SequenceFlow_0orw2f8 + SequenceFlow_0ha8ix9 + + + + + + + + + + + + + + + + + + SequenceFlow_1j08ko3 + SequenceFlow_1cevtpy + + + + SequenceFlow_1q2mqnm + + + + + SequenceFlow_0vi0sv6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn new file mode 100644 index 0000000000..d6069d714e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn @@ -0,0 +1,933 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_0msqfwu + SequenceFlow_6 + + + + + + + + + + + + + + SequenceFlow_1pdp4d2 + SequenceFlow_12 + + + + SequenceFlow_12 + SequenceFlow_1jnva78 + SequenceFlow_5 + + + + + SequenceFlow_8 + + + + + SequenceFlow_5 + sdncTopoDeleteNo_SequenceFlow + sdncTopoDeleteYes_SequenceFlow + + + SequenceFlow_8 + sdncTopoDeleteNo_SequenceFlow + + + + + + + + + SequenceFlow_1a51h25 + + + + SequenceFlow_1yvnovn + + + SequenceFlow_1nl99y6 + SequenceFlow_1yvnovn + + + + + + SequenceFlow_1wif0e5 + + + + SequenceFlow_021b0sz + SequenceFlow_0tiz0kk + SequenceFlow_1suj1nc + + + + + + + + + + + + + + + + + + + + + SequenceFlow_147vc14 + + + SequenceFlow_0tiz0kk + SequenceFlow_0jb7rws + SequenceFlow_1raa09h + + + + + + SequenceFlow_1suj1nc + SequenceFlow_1raa09h + SequenceFlow_0jb7rws + SequenceFlow_1nl99y6 + + + + + SequenceFlow_1wif0e5 + SequenceFlow_147vc14 + + + + + + + SequenceFlow_1a51h25 + SequenceFlow_021b0sz + + + Rollback Not Needed for Delete. + + + + + isRelationshipExistNo_SequenceFlow + querySuccessYes_SequenceFlow + querySuccessNo_SequenceFlow + + + + + + + querySuccessNo_SequenceFlow + isReturnCode404_No_SequenceFlow + isReturnCode404_Yes_SequenceFlow + + + + + + + isReturnCode404_No_SequenceFlow + + + + querySuccessYes_SequenceFlow + isResponseEmptyNo_SequenceFlow + isResponseEmptyYes_SequenceFlow + + + + + + + isReturnCode404_Yes_SequenceFlow + isResponseEmptyYes_SequenceFlow + silentSuccess_SequenceFlow + + + + SequenceFlow_0f25bme + + + isResponseEmptyNo_SequenceFlow + SequenceFlow_30 + + + + + SequenceFlow_6 + isRelationshipExistNo_SequenceFlow + isRelationshipExistYes_SequenceFlow + + + + + + + isRelationshipExistYes_SequenceFlow + + + + SequenceFlow_1pbgnr2 + + + SequenceFlow_0r3pvf8 + SequenceFlow_1pdp4d2 + + + + SequenceFlow_2 + SequenceFlow_20 + + + + + SequenceFlow_30 + SequenceFlow_15 + + + + + SequenceFlow_15 + SequenceFlow_2 + + + + + + SequenceFlow_13 + + + + SequenceFlow_17 + + + SequenceFlow_13 + SequenceFlow_17 + + + + + + + sdncTopoDeleteYes_SequenceFlow + SequenceFlow_1pbgnr2 + + + + + + SequenceFlow_20 + SequenceFlow_0r3pvf8 + SequenceFlow_0kqnddy + + + + SequenceFlow_0f13b17 + SequenceFlow_0zlbzad + + + + + + + + + + + + + SequenceFlow_0zlbzad + SequenceFlow_1jnva78 + + + + + + + + SequenceFlow_1 + SequenceFlow_0msqfwu + + + + + silentSuccess_SequenceFlow + SequenceFlow_0f25bme + + + + + + + + + + + + + + SequenceFlow_1o088sy + SequenceFlow_1i3193l + + + SequenceFlow_0kqnddy + SequenceFlow_1o088sy + + + + + SequenceFlow_0n8sf23 + SequenceFlow_1qyo7ot + SequenceFlow_0f13b17 + + + SequenceFlow_1i3193l + SequenceFlow_0n8sf23 + + + + SequenceFlow_08hus4u + + + + + + + + + + + SequenceFlow_08hus4u + SequenceFlow_1qyo7ot + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn new file mode 100644 index 0000000000..7ec02addfa --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn @@ -0,0 +1,547 @@ + + + + + SequenceFlow_1krl2dg + + + SequenceFlow_1krl2dg + SequenceFlow_0u41iz2 + + + + + + + + + + + + + + + SequenceFlow_1mxbdps + SequenceFlow_07s5r14 + + + SequenceFlow_0u41iz2 + SequenceFlow_1bb7zpp + SequenceFlow_1mxbdps + + + SequenceFlow_1xokvq6 + SequenceFlow_1xs882r + SequenceFlow_1ucaagl + + + + + + + + + SequenceFlow_1ucaagl + + + + + SequenceFlow_0xktw7v + SequenceFlow_0soe5t3 + + + + SequenceFlow_0xktw7v + + + + SequenceFlow_0soe5t3 + + + + + + SequenceFlow_1hcmrh9 + SequenceFlow_1pi168e + SequenceFlow_1xs882r + + + + SequenceFlow_1bb7zpp + SequenceFlow_07s5r14 + SequenceFlow_1yj3542 + SequenceFlow_18e00sw + + + + + + + ${DELNWKIR_rollbackNetworkRequest} + + + + #{BasicAuthHeaderValuePO} + application/xml + + + POST + ${response} + ${statusCode} + + http-connector + + + SequenceFlow_18e00sw + SequenceFlow_1eyt8z2 + + + + + + SequenceFlow_1yj3542 + SequenceFlow_1eyt8z2 + SequenceFlow_1xokvq6 + SequenceFlow_172safw + + + SequenceFlow_172safw + SequenceFlow_1wy1aba + SequenceFlow_1yltkyg + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1yltkyg + SequenceFlow_1hcmrh9 + + + + + + + + + + + + SequenceFlow_1wy1aba + SequenceFlow_1pi168e + + + + + SequenceFlow_1s5yjuu + + + SequenceFlow_01hh1wq + SequenceFlow_1s5yjuu + + + + SequenceFlow_01hh1wq + + + + + + + SequenceFlow_0b0m3o7 + + + + SequenceFlow_141226w + + + + + + SequenceFlow_141226w + SequenceFlow_0b0m3o7 + + + + SequenceFlow_1lr1613 + + + + SequenceFlow_0np0b8p + + + + SequenceFlow_1lr1613 + SequenceFlow_0np0b8p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResources.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResources.bpmn new file mode 100644 index 0000000000..7fbfe46cdb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResources.bpmn @@ -0,0 +1,486 @@ + + + + + SequenceFlow_0vz7cd9 + + + SequenceFlow_1r5306k + + + + SequenceFlow_1921mo3 + + + + SequenceFlow_18vlzfo + + + SequenceFlow_1921mo3 + SequenceFlow_18vlzfo + + + + + + + + SequenceFlow_1ubor5z + SequenceFlow_1dza4q4 + + + + + + SequenceFlow_1x3lehs + SequenceFlow_1wnkgpx + + + + + + + + + + + + + + SequenceFlow_1wnkgpx + SequenceFlow_0phwem2 + + + SequenceFlow_1dza4q4 + SequenceFlow_1lxqjmp + + + SequenceFlow_1icwpye + SequenceFlow_1yujjwx + + + SequenceFlow_0xqdf1z + SequenceFlow_03c0zlq + + + + SequenceFlow_1htjmkv + SequenceFlow_1ubor5z + SequenceFlow_1x3lehs + + + SequenceFlow_03c0zlq + SequenceFlow_0s1lswk + SequenceFlow_1htjmkv + + + + + + + + + + SequenceFlow_1lxqjmp + SequenceFlow_0phwem2 + SequenceFlow_0l5r96s + + + + + + SequenceFlow_0l5r96s + SequenceFlow_0talboa + SequenceFlow_0s1lswk + + + + SequenceFlow_0talboa + SequenceFlow_1icwpye + SequenceFlow_12avhgx + + + + + + + + + + + SequenceFlow_1yujjwx + SequenceFlow_12avhgx + SequenceFlow_1r5306k + + + + + SequenceFlow_042d7oc + SequenceFlow_1t2hfv0 + SequenceFlow_1t8hf8m + + + + + + + + + + + + + + + SequenceFlow_1t8hf8m + SequenceFlow_0p5gr4z + + + SequenceFlow_0p5gr4z + SequenceFlow_131imj8 + + + + + + + + + + + + SequenceFlow_1n85wxv + SequenceFlow_0xqdf1z + SequenceFlow_042d7oc + + + + + + + SequenceFlow_0vz7cd9 + SequenceFlow_1t2hfv0 + + + + + SequenceFlow_131imj8 + SequenceFlow_1n85wxv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn new file mode 100644 index 0000000000..fe5e93cbec --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn @@ -0,0 +1,455 @@ + + + + + SequenceFlow_0stqur4 + + + SequenceFlow_1oil1t3 + SequenceFlow_13nyd1j + SequenceFlow_1qm7owo + + + + SequenceFlow_098gain + SequenceFlow_1ly5jrs + + + + SequenceFlow_1ly5jrs + SequenceFlow_0djplpd + SequenceFlow_0i1gez5 + + + + SequenceFlow_0i1gez5 + SequenceFlow_1oil1t3 + SequenceFlow_1d5mzit + + + + + + + + + + + SequenceFlow_0rkycoj + + + + SequenceFlow_117fiux + + + SequenceFlow_0rkycoj + SequenceFlow_117fiux + + + + + + + SequenceFlow_1yrkxjm + SequenceFlow_1s1nnmj + SequenceFlow_0lk19rm + + + + SequenceFlow_0o21fg8 + + + + + + + + + + SequenceFlow_1d5mzit + + + + SequenceFlow_1yrkxjm + + + + SequenceFlow_0lk19rm + SequenceFlow_14fx6hv + SequenceFlow_0o21fg8 + + + + SequenceFlow_14dezx8 + SequenceFlow_13nyd1j + + + + + + SequenceFlow_0stqur4 + SequenceFlow_14dezx8 + + + + SequenceFlow_1qm7owo + SequenceFlow_098gain + SequenceFlow_19ccmqv + + + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_updateResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_11bgbsh + SequenceFlow_0djplpd + + + SequenceFlow_19ccmqv + SequenceFlow_11bgbsh + + + + + + + + SequenceFlow_1s1nnmj + SequenceFlow_11h5pba + + + + + + + + + + + + + SequenceFlow_11h5pba + SequenceFlow_0gqlayv + + + + + + + + + + + + + SequenceFlow_0etaubw + SequenceFlow_14fx6hv + + + + SequenceFlow_0gqlayv + SequenceFlow_0etaubw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn new file mode 100644 index 0000000000..fae66a7381 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn @@ -0,0 +1,373 @@ + + + + + SequenceFlow_0jfgn05 + + + SequenceFlow_0jfgn05 + SequenceFlow_1jqc16k + + + + SequenceFlow_1wyvxwi + + + + + + + + + + + + SequenceFlow_0yohjl7 + SequenceFlow_0k28xib + + + SequenceFlow_0k28xib + SequenceFlow_1w8ao21 + + + + + SequenceFlow_1dwch0k + SequenceFlow_1ju26o1 + + + + SequenceFlow_1up0j5r + SequenceFlow_1hcfvcj + SequenceFlow_05jfuko + + + + + + SequenceFlow_05jfuko + + + + + SequenceFlow_1hcfvcj + SequenceFlow_0riudmc + SequenceFlow_1dwch0k + + + + + + + + + + + + + + + + SequenceFlow_1jqc16k + SequenceFlow_1grea1r + + + + SequenceFlow_1grea1r + SequenceFlow_1up0j5r + + + + + + SequenceFlow_0riudmc + SequenceFlow_0znbzxu + SequenceFlow_1wyvxwi + + + + + + SequenceFlow_0u33vy6 + + + + SequenceFlow_0hevfee + + + SequenceFlow_0u33vy6 + SequenceFlow_0hevfee + + + + + + + + + + + + + + + SequenceFlow_1w8ao21 + SequenceFlow_1swzrij + SequenceFlow_14x55db + + + SequenceFlow_14x55db + SequenceFlow_0znbzxu + + + + + + SequenceFlow_1ju26o1 + SequenceFlow_0yohjl7 + SequenceFlow_1swzrij + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn new file mode 100644 index 0000000000..e6ad16b4d1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn @@ -0,0 +1,275 @@ + + + + + SequenceFlow_1qo2pln + + + + terminateFinished_SequenceFlow + SequenceFlow_1sjop71 + + + + SequenceFlow_1qo2pln + SequenceFlow_150q0fo + + + + SequenceFlow_1h1c24p + SequenceFlow_1ywe21t + + + + SequenceFlow_1sjop71 + deleteNSFailed_SequenceFlow + deleteNSSuccess_SequenceFlow + + + + + + SequenceFlow_1ywe21t + terminateFailed_SequenceFlow + terminateSuccess_SequenceFlow + + + + + + + + + + SequenceFlow_0xqo13p + terminateFinished_SequenceFlow + terminateProcessing_SequenceFlow + + + + + + + + + + deleteNSFailed_SequenceFlow + + + terminateFailed_SequenceFlow + + + SequenceFlow_0cq2q6g + + + terminateSuccess_SequenceFlow + SequenceFlow_1gsbpxj + SequenceFlow_0xqo13p + + + + deleteNSSuccess_SequenceFlow + SequenceFlow_0cq2q6g + + + + + terminateProcessing_SequenceFlow + SequenceFlow_1gsbpxj + + + + + + + + + + + SequenceFlow_150q0fo + SequenceFlow_1h1c24p + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn new file mode 100644 index 0000000000..848796c0b6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn @@ -0,0 +1,433 @@ + + + + + SequenceFlow_0fp1wqz + SequenceFlow_28 + + + + + + + + + + SequenceFlow_28 + SequenceFlow_31 + + + + + + + + + + + SequenceFlow_029ioyr + SequenceFlow_14xn858 + + + + + + + + + + + + + SequenceFlow_32 + SequenceFlow_33 + + + + SequenceFlow_14xn858 + SequenceFlow_4 + + + + SequenceFlow_31 + SequenceFlow_32 + + + + + + + + + + + + + SequenceFlow_4 + SequenceFlow_1xruki1 + + + SequenceFlow_35 + + + + + + + + + SequenceFlow_34 + SequenceFlow_35 + + + + SequenceFlow_2 + SequenceFlow_34 + + + + + SequenceFlow_33 + SequenceFlow_2 + + + + + SequenceFlow_1 + SequenceFlow_12 + + + + + SequenceFlow_12 + SequenceFlow_42 + + + + + SequenceFlow_1 + + + + + SequenceFlow_0coa90m + SequenceFlow_08g02ch + + + + SequenceFlow_1xruki1 + SequenceFlow_0coa90m + + + + + SequenceFlow_08g02ch + SequenceFlow_1yehsyc + SequenceFlow_0ep3hjm + + + + + + + + SequenceFlow_0ep3hjm + SequenceFlow_14l7olw + SequenceFlow_0fp1wqz + + + + + + SequenceFlow_1yehsyc + SequenceFlow_1a7lzhz + + + + + + + + + + + SequenceFlow_1a7lzhz + SequenceFlow_14l7olw + + + + SequenceFlow_42 + SequenceFlow_029ioyr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn new file mode 100644 index 0000000000..b7a1373fe9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn new file mode 100644 index 0000000000..4409f2a0dc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn new file mode 100644 index 0000000000..d9596f0d14 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn @@ -0,0 +1,303 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_5 + + + + SequenceFlow_5 + vnfFound + notFound + + + + + + + vnfFound + SequenceFlow_4 + + + + + notFound + + + + SequenceFlow_4 + inUse + notInUse + + + + + + + inUse + SequenceFlow_8 + + + + + SequenceFlow_8 + + + + + + SequenceFlow_19 + + + SequenceFlow_18 + + + + + SequenceFlow_18 + SequenceFlow_19 + + + + + + SequenceFlow_9 + SequenceFlow_12 + SequenceFlow_10 + + + + SequenceFlow_12 + + + + + SequenceFlow_10 + + + + notInUse + SequenceFlow_9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn new file mode 100644 index 0000000000..4d6d0006e3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn @@ -0,0 +1,490 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_08nd69s + + + + + SequenceFlow_19 + + + SequenceFlow_18 + + + + + SequenceFlow_18 + SequenceFlow_19 + + + + + + SequenceFlow_1uqlr6b + + + + SequenceFlow_0t4yszi + SequenceFlow_1tt31qu + SequenceFlow_1fccvli + SequenceFlow_1qrkdn3 + SequenceFlow_1936oc0 + + + + + + + + SequenceFlow_05ujwz8 + SequenceFlow_1x25m7t + SequenceFlow_1uqlr6b + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1xujrk5 + SequenceFlow_1p4ycii + + + SequenceFlow_1936oc0 + SequenceFlow_05ujwz8 + SDNCInteractionEnabled2 + + + + + + + + SequenceFlow_08nd69s + SequenceFlow_0lu7b1v + + + + SequenceFlow_1qrkdn3 + SequenceFlow_1qoor0l + + + + + + SequenceFlow_1p4ycii + SequenceFlow_0xl033m + SequenceFlow_0t4yszi + + + + SequenceFlow_0lu7b1v + SequenceFlow_1tt31qu + SDNCInteractionEnabled1 + + + + + + + + + + SDNCInteractionEnabled1 + SequenceFlow_0fhhsyo + + + + SequenceFlow_0qdn8k4 + SequenceFlow_1fccvli + + + + + + + + + + + + + SequenceFlow_0fhhsyo + SequenceFlow_0qdn8k4 + + + + + + + + + SDNCInteractionEnabled2 + SequenceFlow_001uxa1 + + + + + + + + + + + + + SequenceFlow_001uxa1 + SequenceFlow_1x29mht + + + SequenceFlow_1x29mht + SequenceFlow_1x25m7t + + + + SequenceFlow_1qoor0l + SequenceFlow_1xujrk5 + SequenceFlow_1laeenc + + + + + + + + + + + + + + SequenceFlow_1laeenc + SequenceFlow_0xl033m + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn new file mode 100644 index 0000000000..fa8a2213b0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn @@ -0,0 +1,187 @@ + + + + + SequenceFlow_1fhno84 + + + SequenceFlow_1fhno84 + SequenceFlow_194bhkx + + + + SequenceFlow_1yee730 + + + SequenceFlow_194bhkx + SequenceFlow_0b5p6gy + + + + + + + ${URN_mso_openecomp_adapters_db_endpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0b5p6gy + SequenceFlow_0nqrq1k + + + + + + + + + + + + + + + + + + + + SequenceFlow_0nqrq1k + SequenceFlow_1yee730 + + + + + + + + + SequenceFlow_0yyws1p + + + + SequenceFlow_0i814ke + + + SequenceFlow_0yyws1p + SequenceFlow_0i814ke + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleVFCServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleVFCServiceInstance.bpmn new file mode 100644 index 0000000000..f8b1ba5bee --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleVFCServiceInstance.bpmn @@ -0,0 +1,89 @@ + + + + + SequenceFlow_00w1ntj + + + SequenceFlow_00w1ntj + SequenceFlow_0izumqq + + + + SequenceFlow_0izumqq + SequenceFlow_0hzy01n + + + + + + SequenceFlow_18hdal9 + + + + SequenceFlow_0hzy01n + SequenceFlow_18hdal9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUnderlayVpnOperation.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUnderlayVpnOperation.bpmn new file mode 100644 index 0000000000..ad79d471af --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUnderlayVpnOperation.bpmn @@ -0,0 +1,293 @@ + + + + + SequenceFlow_0trm4dk + + + SequenceFlow_1vncx6p + SequenceFlow_1amfirn + SequenceFlow_083crve + + + SequenceFlow_10j9lbs + + + SequenceFlow_083crve + SequenceFlow_0al8gdl + + + + + + + + + SequenceFlow_0h35z1p + SequenceFlow_07bp14s + + + SequenceFlow_0trm4dk + SequenceFlow_199ig0b + + + SequenceFlow_199ig0b + SequenceFlow_1rj6k5t + SequenceFlow_0h35z1p + + + + SequenceFlow_1rj6k5t + SequenceFlow_1vncx6p + + + + + + + + SequenceFlow_1amfirn + SequenceFlow_0bsmh51 + + + + SequenceFlow_0bsmh51 + SequenceFlow_10j9lbs + SequenceFlow_0al8gdl + + + + + + SequenceFlow_07bp14s + SequenceFlow_1oz5grh + SequenceFlow_19glon5 + + + SequenceFlow_1oz5grh + SequenceFlow_06e7qr6 + + + SequenceFlow_06e7qr6 + SequenceFlow_0koi1ia + SequenceFlow_1q83qn9 + + + SequenceFlow_0koi1ia + + + SequenceFlow_19glon5 + SequenceFlow_1q83qn9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn new file mode 100644 index 0000000000..a46d8d4de2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn @@ -0,0 +1,648 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_04xlw7s + + + + SequenceFlow_115mdln + SequenceFlow_0yztz2p + + + + SequenceFlow_1wwjugw + SequenceFlow_177wo8z + + + + SequenceFlow_115mdln + + + + + + SequenceFlow_1qn0865 + SequenceFlow_1s799cp + + + + SequenceFlow_0w4t4ao + SequenceFlow_1uu6uiu + + + + SequenceFlow_1qn0865 + + + + + SequenceFlow_04xlw7s + SequenceFlow_0r6c0ci + + + + + + + ${CVFMI_dbAdapterEndpoint} + + + application/soap+xml + Basic QlBFTENsaWVudDpwYXNzd29yZDEk + + + ${CVFMI_initResOperStatusRequest} + POST + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0r6c0ci + SequenceFlow_1muxopq + + + + + SequenceFlow_177wo8z + + + + + + + + + + + + + + + SequenceFlow_1kx5ke9 + SequenceFlow_0f76thv + + + SequenceFlow_0f76thv + SequenceFlow_0x0mhlj + + + + SequenceFlow_1demy08 + + + + + + SequenceFlow_0ku36oy + SequenceFlow_07aa121 + + + + SequenceFlow_0ku36oy + + + + SequenceFlow_07aa121 + + + + + SequenceFlow_1uu6uiu + + + + SequenceFlow_0x0mhlj + + + + + SequenceFlow_1muxopq + + + + + + SequenceFlow_05j3sat + + + + SequenceFlow_02znk15 + + + SequenceFlow_05j3sat + SequenceFlow_19ly8h7 + + + + SequenceFlow_19ly8h7 + SequenceFlow_02znk15 + + + + + + + + SequenceFlow_1demy08 + SequenceFlow_1cy5gq2 + + + + + + + + + + + + + + + + SequenceFlow_1cy5gq2 + SequenceFlow_1vy856f + + + SequenceFlow_1vy856f + SequenceFlow_14ggluy + + + + + + SequenceFlow_14ggluy + SequenceFlow_1kx5ke9 + + + + + + SequenceFlow_0yztz2p + SequenceFlow_0ttlte0 + SequenceFlow_01po987 + + + + + + SequenceFlow_01po987 + + + + + SequenceFlow_070o30v + + + + + + + + + + + + + + + + + SequenceFlow_0ur34hv + SequenceFlow_0w4t4ao + + + + + + + + + + + + + + + + + SequenceFlow_0ttlte0 + SequenceFlow_1wwjugw + + + + SequenceFlow_1s799cp + SequenceFlow_0ur34hv + SequenceFlow_070o30v + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn new file mode 100644 index 0000000000..1589633e59 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn @@ -0,0 +1,799 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 + + + + SequenceFlow_01l4ssl + + + + SequenceFlow_8 + + + + SequenceFlow_7 + + + + SequenceFlow_8 + SequenceFlow_7 + + + + + + + SequenceFlow_1rzlaoy + SequenceFlow_0a83f6m + SequenceFlow_01l4ssl + + + + + + SequenceFlow_1ch4xrf + + + + SequenceFlow_1ch4xrf + SequenceFlow_1pjk2ff + + + + SequenceFlow_1pjk2ff + + + + + + + SequenceFlow_2 + SequenceFlow_1rzlaoy + SequenceFlow_06aasqh + + + + + + rollback Deleted Resources + SequenceFlow_1uw2p9a + SequenceFlow_0drjj7b + SequenceFlow_055b52t + + + SequenceFlow_06aasqh + SequenceFlow_1uw2p9a + SequenceFlow_11fnnkb + + + + + + + + + + + + + + + + + + + + SequenceFlow_1fih4h0 + SequenceFlow_0pwixhh + + + + SequenceFlow_06xv7b2 + SequenceFlow_0b73i9r + + + + SequenceFlow_0pwixhh + SequenceFlow_08p4pkv + + + + SequenceFlow_1g4qm2l + SequenceFlow_1fih4h0 + + + + + + + + + + + + + + + + SequenceFlow_0b73i9r + SequenceFlow_0q9ws1s + + + SequenceFlow_0q9ws1s + SequenceFlow_1bp5oce + + + + rollback AAI + SequenceFlow_055b52t + SequenceFlow_0a83f6m + SequenceFlow_0zijz16 + + + + + + SequenceFlow_06xv7b2 + + + + SequenceFlow_1g4qm2l + + + + SequenceFlow_11fnnkb + + + + SequenceFlow_0drjj7b + + + + + + + + + + SequenceFlow_1a65s3k + + + + SequenceFlow_1ixphei + SequenceFlow_1lppnhy + + + + + + + + + + + + + + + SequenceFlow_1lppnhy + SequenceFlow_0kbisn8 + + + SequenceFlow_0kbisn8 + SequenceFlow_1azhgda + + + + + + + rollback AAI + SequenceFlow_08p4pkv + SequenceFlow_0cbnwwi + SequenceFlow_161uzhj + + + + SequenceFlow_0cbnwwi + + + + + + + SequenceFlow_161uzhj + SequenceFlow_13r4lij + + + + + SequenceFlow_13r4lij + + + + rollback AAI + SequenceFlow_1bp5oce + SequenceFlow_0bkvqao + SequenceFlow_1isdxh1 + + + SequenceFlow_0bkvqao + + + + SequenceFlow_1isdxh1 + SequenceFlow_0a9xori + + + + SequenceFlow_0a9xori + + + + + + + + SequenceFlow_0zijz16 + + + + + + + + SequenceFlow_1azhgda + SequenceFlow_1n6foyw + + + + SequenceFlow_1n6foyw + + + + + + SequenceFlow_1a65s3k + SequenceFlow_0870pzc + + + + + + + + + + + + + + + SequenceFlow_0870pzc + SequenceFlow_1f31l5s + + + + SequenceFlow_1f31l5s + SequenceFlow_1ixphei + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn new file mode 100644 index 0000000000..306b05cea1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn @@ -0,0 +1,829 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_32 + SequenceFlow_11 + + + + + SequenceFlow_12 + SequenceFlow_5 + + + + SequenceFlow_5 + sdncTopoNo_SequenceFlow + sdncTopoYes_SequenceFlow + + + + + + + + SequenceFlow_34 + + + + + sdncTopoNo_SequenceFlow + SequenceFlow_34 + + + + + + + + + + + + + + SequenceFlow_11 + SequenceFlow_12 + + + + SequenceFlow_46 + SequenceFlow_29 + + + + + + SequenceFlow_053re4q + isRollbackOn_YesNetwork_SequenceFlow + isRollbackOn_NoNetwork_SequenceFlow + + + + + + + SequenceFlow_23 + + + + + isRollbackOn_YesNetwork_SequenceFlow + isPONR_Yes_SequenceFlow + isPONR_No_SequenceFlow + + + + + + + SequenceFlow_0nrc66n + sdncOk_Yeso_ExclusiveGateway + sdncOk_No_ExclusiveGateway + + + + + + + sdncOk_Yeso_ExclusiveGateway + SequenceFlow_53 + + + + + SequenceFlow_04rdjfi + + + SequenceFlow_53 + sdncOk_No_ExclusiveGateway + SequenceFlow_0srdlf3 + SequenceFlow_47 + + + + SequenceFlow_47 + SequenceFlow_0qr4es6 + + + + + + + + + + + + + + + + + + + SequenceFlow_0qr4es6 + + + SequenceFlow_0ze5k6c + SequenceFlow_04rdjfi + + + + + + SequenceFlow_0nrc66n + SequenceFlow_0srdlf3 + + + + + + + SequenceFlow_23 + SequenceFlow_053re4q + + + + + isPONR_Yes_SequenceFlow + isRollbackOn_NoNetwork_SequenceFlow + isPONR_No_SequenceFlow + SequenceFlow_0ze5k6c + + + Note: Rollback is not needed for UpdateNetwork, + + + + + SequenceFlow_13 + SequenceFlow_35 + + + + + SequenceFlow_35 + SequenceFlow_46 + + + + + SequenceFlow_29 + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + SequenceFlow_1 + SequenceFlow_7 + + + + + SequenceFlow_24 + SequenceFlow_32 + + + + + siFoundYes + SequenceFlow_24 + + + + + siFoundNo + + + + SequenceFlow_3 + siFoundYes + siFoundNo + + + + + + + + + + + + + + + + SequenceFlow_7 + SequenceFlow_3 + + + + SequenceFlow_59 + SequenceFlow_13 + + + + + + + + ${UPDNETI_updateNetworkRequest} + + + + #{BasicAuthHeaderValuePO} + application/xml + + + PUT + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_61 + SequenceFlow_59 + + + + SequenceFlow_2 + SequenceFlow_61 + + + + + SequenceFlow_38 + SequenceFlow_2 + + + + + sdncTopoYes_SequenceFlow + SequenceFlow_6 + + + + + SequenceFlow_6 + SequenceFlow_15 + + + + + SequenceFlow_15 + SequenceFlow_38 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn new file mode 100644 index 0000000000..9d37d8084e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn @@ -0,0 +1,374 @@ + + + + + SequenceFlow_1krl2dg + + + SequenceFlow_1krl2dg + SequenceFlow_0u41iz2 + + + + + + + + + ${UPDNETIR_rollbackNetworkRequest} + + + + #{BasicAuthHeaderValuePO} + application/xml + + + PUT + ${statusCode} + ${response} + + http-connector + + + SequenceFlow_0e1uixp + SequenceFlow_17o4w67 + + + SequenceFlow_0u41iz2 + SequenceFlow_0e1uixp + SequenceFlow_1lteduj + + + + + + + + + + + + SequenceFlow_101y57s + SequenceFlow_0790olb + + + SequenceFlow_0virkpu + SequenceFlow_101y57s + SequenceFlow_0mw0dgd + + + SequenceFlow_0qc4v9t + SequenceFlow_0el8yzs + SequenceFlow_0yto4gz + + + + SequenceFlow_1lteduj + SequenceFlow_17o4w67 + SequenceFlow_0virkpu + SequenceFlow_0qc4v9t + + + + + + + + + + + + + + + SequenceFlow_0yto4gz + + + + + + SequenceFlow_0xktw7v + SequenceFlow_0soe5t3 + + + + SequenceFlow_0xktw7v + + + + SequenceFlow_0soe5t3 + + + + + + SequenceFlow_0790olb + SequenceFlow_0mw0dgd + SequenceFlow_0el8yzs + + + + + + SequenceFlow_07kf49j + SequenceFlow_01syg1x + + + + SequenceFlow_07kf49j + + + + SequenceFlow_01syg1x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn new file mode 100644 index 0000000000..46e7ddcbe6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn @@ -0,0 +1,671 @@ + + + + + + SequenceFlow_38 + SequenceFlow_2 + + + + + + + + + + + + + + SequenceFlow_2 + SequenceFlow_15 + + + SequenceFlow_1 + SequenceFlow_38 + + + + + + SequenceFlow_6 + SequenceFlow_35 + + + + SequenceFlow_35 + + + + + SequenceFlow_6 + + + + + + SequenceFlow_36 + + + + SequenceFlow_36 + + + + + SequenceFlow_9 + SequenceFlow_18 + SequenceFlow_25 + + + + + + + + + + + + SequenceFlow_25 + SequenceFlow_26 + + + + SequenceFlow_26 + SequenceFlow_27 + + + + + + + + + + + + + + SequenceFlow_27 + SequenceFlow_7 + + + SequenceFlow_24 + SequenceFlow_13 + + + + + + + + + + + + SequenceFlow_14 + SequenceFlow_9 + + + + SequenceFlow_13 + SequenceFlow_14 + SequenceFlow_18 + + + + + + + SequenceFlow_1 + + + + SequenceFlow_16 + SequenceFlow_17 + SequenceFlow_12 + + + + + + + + + + + + + + SequenceFlow_12 + SequenceFlow_3 + + + + + + + + + + + SequenceFlow_21 + SequenceFlow_24 + + + + SequenceFlow_23 + SequenceFlow_21 + + + + + SequenceFlow_22 + SequenceFlow_23 + + + + + + + + + + + + + SequenceFlow_19 + SequenceFlow_22 + + + SequenceFlow_3 + SequenceFlow_5 + + + + + + SequenceFlow_5 + SequenceFlow_19 + + + + + + + SequenceFlow_15 + SequenceFlow_28 + SequenceFlow_30 + + + + + + + + + + + + + + SequenceFlow_11 + SequenceFlow_17 + + + + SequenceFlow_10 + SequenceFlow_11 + + + + + SequenceFlow_29 + SequenceFlow_10 + SequenceFlow_16 + + + + + + + + + + SequenceFlow_30 + SequenceFlow_34 + + + + + + SequenceFlow_28 + SequenceFlow_34 + SequenceFlow_29 + + + + + SequenceFlow_7 + SequenceFlow_20 + + + + SequenceFlow_20 + SequenceFlow_4 + + + + + SequenceFlow_4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn new file mode 100644 index 0000000000..ae77461070 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn @@ -0,0 +1,275 @@ + + + + + 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/so-bpmn-infrastructure-flows/src/main/resources/subprocess/RollbackVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/RollbackVnf.bpmn new file mode 100644 index 0000000000..e1300c978f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/RollbackVnf.bpmn @@ -0,0 +1,346 @@ + + + + + SequenceFlow_0bie3cu + + + SequenceFlow_0mpoa26 + SequenceFlow_1pirwg0 + SequenceFlow_1lne8je + SequenceFlow_0tj5bkd + + + SequenceFlow_0tj5bkd + SequenceFlow_1ney8l6 + SequenceFlow_0gsro0z + SequenceFlow_0b2y2dw + + + SequenceFlow_0b2y2dw + SequenceFlow_11556y3 + SequenceFlow_0skjb2u + SequenceFlow_0c5ovtd + + + SequenceFlow_0g18wrd + SequenceFlow_0c5ovtd + SequenceFlow_12bz15k + SequenceFlow_03qkk4e + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0bie3cu + SequenceFlow_1ix4dpf + + + + + + + + + + + + + SequenceFlow_1lne8je + SequenceFlow_1ney8l6 + + + + + + + + + + + SequenceFlow_0gsro0z + SequenceFlow_11556y3 + + + SequenceFlow_0skjb2u + SequenceFlow_0g18wrd + + + + SequenceFlow_12bz15k + SequenceFlow_0tkvd6f + + + + SequenceFlow_1p3pyal + + + + + SequenceFlow_03qkk4e + SequenceFlow_0tkvd6f + SequenceFlow_1p3pyal + + + + + SequenceFlow_1ix4dpf + SequenceFlow_0mpoa26 + SequenceFlow_05ihl7f + + + + + + + + + + + + + + + + + + SequenceFlow_05ihl7f + SequenceFlow_1pirwg0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/SetRefactorServiceDecomp.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/SetRefactorServiceDecomp.bpmn new file mode 100644 index 0000000000..7afac44ff6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/SetRefactorServiceDecomp.bpmn @@ -0,0 +1,68 @@ + + + + + SequenceFlow_1aizx5q + + + + SequenceFlow_1fypndb + + + + SequenceFlow_1aizx5q + SequenceFlow_1ipdcwj + + + + + + SequenceFlow_1ipdcwj + SequenceFlow_1fypndb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..ae40e9d7c6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner + +import static org.junit.Assert.assertNotNull +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class CreateCustomE2EServiceInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testPrepareInitServiceOperationStatus (){ + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter") + CreateCustomE2EServiceInstance obj = new CreateCustomE2EServiceInstance(); + obj.prepareInitServiceOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertNotNull(updateVolumeGroupRequest); + } + + private ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("CreateCustomE2EServiceInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateCustomE2EServiceInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("CreateCustomE2EServiceInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("CreateCustomE2EServiceInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + return mockExecution + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy new file mode 100644 index 0000000000..da0990910a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy @@ -0,0 +1,235 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.VidUtils + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class CreateGenericAlaCarteServiceInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + String Prefix="CRESI_" + def utils = new MsoUtils() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + 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": "service", + "modelInvariantId": "1de901ed-17af-4b03-bc1f-41659cfa27cb", + "modelVersionId": "ace39141-09ec-4068-b06d-ac6b23bdc6e0", + "modelName": "demoVLB", + "modelVersion": "1.0" + }, + "cloudConfiguration" : { + "lcpCloudRegionId": "RegionOne", + "tenantId": "onap" + }, + "subscriberInfo": { + "globalSubscriberId": "Demonstration", + "subscriberName": "Demonstration" + }, + "requestInfo": { + "instanceName": "sample-instance-2", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "requestorId":"1234", + "suppressRollback": "false" + }, + "requestParameters": { + "subscriptionServiceType": "vLB" + } + } + }""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables(DelegateExecution 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) + try{ + + // preProcessRequest(DelegateExecution execution) + CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance() + createGenericALaCarteServiceInstance.preProcessRequest(mockExecution) + + //verify(mockExecution).getVariable("isDebugLogEnabled") + //verify(mockExecution).setVariable("prefix", Prefix) + + initializeVariables(mockExecution) + //verify(mockExecution).setVariable(Prefix + "Success", false) + }catch(Exception e){ + //ignore + } + } + + @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") + try{ + // preProcessRequest(DelegateExecution execution) + CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance() + createGenericALaCarteServiceInstance.sendSyncResponse(mockExecution) + + //verify(mockExecution).setVariable("prefix", Prefix) + //verify(mockExecution).setVariable("createServiceRestRequest", "202") + }catch(Exception e){ + //ignore + } + } + + @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") + try{ + CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance() + createGenericALaCarteServiceInstance.sendSyncError(mockExecution) + + //verify(mockExecution).setVariable("prefix", Prefix) + //verify(mockExecution).setVariable("createServiceRestRequest", "500") + }catch(Exception e){ + //ignore + } + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("CreateGenericALaCarteSeviceInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateGenericALaCarteSeviceInstance") + 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("CreateGenericALaCarteSeviceInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("CreateGenericALaCarteSeviceInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..4d5f506599 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy @@ -0,0 +1,379 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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 + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy new file mode 100644 index 0000000000..77220da94f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner + +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.when + +@RunWith(MockitoJUnitRunner.class) +class CreateVfModuleInfraTest { + + def prefix = "CVFMI_" + def requestInfo = "12345" + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + void testPrepareUpdateInfraRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "requestInfo")).thenReturn(requestInfo) + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("12345") + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + CreateVfModuleInfra obj = new CreateVfModuleInfra() + obj.prepareUpdateInfraRequest(mockExecution) + Mockito.verify(mockExecution).setVariable(prefix + "dbAdapterEndpoint", "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + } + + + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("CreateVfModuleInfra") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateVfModuleInfra") + 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("CreateVfModuleInfra") + when(mockExecution.getProcessInstanceId()).thenReturn("CreateVfModuleInfra") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy new file mode 100644 index 0000000000..2b437d875e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy @@ -0,0 +1,208 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +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.ArgumentCaptor +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { + + def jsonRequest = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelInstanceName": "vSAMP12" + } + } + } + ], + "requestParameters": { + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + {"name": "vnfName", "value": "STMTN5MMSC20" }, + {"name": "vnfName2", "value": "US1117MTSNJVBR0246" }, + {"name": "vnfNmInformation", "value": "" }, + {"name": "vnfType", "value": "pcrf-capacity" }, + {"name": "vnfId", "value": "skask" }, + {"name": "vnfStackId", "value": "slowburn" }, + {"name": "vnfStatus", "value": "created" }, + {"name": "aicCloudRegion", "value": "MDTWNJ21" }, + {"name": "availabilityZone", "value": "slcp3-esx-az01" }, + {"name": "oamNetworkName", "value": "VLAN-OAM-1323" }, + {"name": "vmName", "value": "slcp34246vbc246ceb" }, + {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" }, + {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" } + ] + } + } +} +""" + + def volumeRequestXml = """ + + CREATE_VF_MODULE_VOL + VID + + + + + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + Test/vSAMP12 + vSAMP12::base::module-0 + 2.0 + mdt1 + 88a6ca3ee0394ade9403f075db23167e + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + + + + STMTN5MMSC20 + US1117MTSNJVBR0246 + + pcrf-capacity + skask + slowburn + created + MDTWNJ21 + slcp3-esx-az01 + VLAN-OAM-1323 + slcp34246vbc246ceb + 970cd2b9-7f09-4a12-af47-182ea38ba1f0 + 545cc2c3-1930-4100-b534-5d82d0e12bb6 + +""" + + def completeMsoRequestXml = """ + + 1234 + CREATE + VID + + Volume Group has been created successfully. + BPMN VF Module Volume action: CREATE +""" + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + + @Test + @Ignore + public void testPreProcessRequest() { + + ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1') + + when(mockExecution.getVariable("prefix")).thenReturn('CVMVINFRAV1_') + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonRequest) + when(mockExecution.getVariable("serviceInstanceId")).thenReturn('') + when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id') + when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + when(mockExecution.getVariable("mso.rollback")).thenReturn('true') + + CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() + createVfModuleVolumeInfraV1.preProcessRequest(mockExecution, 'true') + + // Capture the arguments to setVariable + ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(15)).setVariable(captor1.capture(), captor2.capture()) + + List arg2List = captor2.getAllValues() + String volumeRequestActual = arg2List.get(6) + String isVidRequestActual = arg2List.get(8) + + assertEquals(volumeRequestXml, volumeRequestActual.trim()) + assertEquals('true', isVidRequestActual) + } + + @Test + public void testPostProcessResponse() { + + ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1') + when(mockExecution.getVariable("dbReturnCode")).thenReturn('000') + when(mockExecution.getVariable("CVMVINFRAV1_createDBResponse")).thenReturn('') + when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + when(mockExecution.getVariable("CVMVINFRAV1_source")).thenReturn('VID') + + CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() + createVfModuleVolumeInfraV1.postProcessResponse(mockExecution, 'true') + + verify(mockExecution).setVariable('CVMVINFRAV1_Success', true) + verify(mockExecution).setVariable('CVMVINFRAV1_CompleteMsoProcessRequest', completeMsoRequestXml) + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..95259e9ec0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase + +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +class DeleteCustomE2EServiceInstanceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) + + String Prefix = "CVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DeleteCustomE2EServiceInstanceTest(){ + super("DeleteCustomE2EServiceInstance") + } + @Test + public void preProcessRequestTest () { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + mex.setVariable("isDebugLogEnabled","true") + instance.preProcessRequest(mex); + + verify(mex).getVariable(GroovyTestBase.DBGFLAG) + + Map userParams = new HashMap<>() + userParams.put("someUserParam","someValue") + + verify(mex).setVariable("prefix", "DELSI_") + verify(mex).setVariable("msoRequestId", "mri") + verify(mex).setVariable("source", "CCD") + verify(mex).setVariable("operationType", "DELETE") + verify(mex).setVariable("globalSubscriberId", "38829939920000") + verify(mex).setVariable("serviceInputParams",userParams) + } + + @Test + public void sendSyncResponseTest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.sendSyncResponse(mex) + verify(mex).setVariable("DeleteCustomE2EServiceInstanceWorkflowResponseSent", "true") + } + + @Test + public void prepareCompletionRequestTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.prepareCompletionRequest(mex) + String msoComplitionRequest = FileUtil.readResourceFile("__files/GenericFlows/MsoCompletionRequest.xml") + //verify(mex).setVariable("completionRequest", msoComplitionRequest) + } + + @Test + public void sendSyncErrorTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.sendSyncError(mex) + + } + + @Test + public void prepareFalloutRequest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.prepareFalloutRequest(mex) + String requestInfo = + """ + null + DELETE + null + """ + //verify(mex).setVariable("falloutRequest", requestInfo) + } + + @Test + public void processJavaExceptionTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.processJavaException() + } + + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceType")).thenReturn("VoLTE") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("requestAction")).thenReturn("ra") + when(mex.getVariable("operationId")).thenReturn("59960003992") + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy new file mode 100644 index 0000000000..b459710479 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.common.scripts.VidUtils + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DeleteGenericAlaCarteServiceInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + String Prefix="DELSI_" + def utils = new MsoUtils() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + String jsonIncomingRequest = + """{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1de901ed-17af-4b03-bc1f-41659cfa27cb", + "modelVersionId": "ace39141-09ec-4068-b06d-ac6b23bdc6e0", + "modelName": "demoVLB", + "modelVersion": "1.0" + }, + "cloudConfiguration" : { + "lcpCloudRegionId": "RegionOne", + "tenantId": "onap" + }, + "subscriberInfo": { + "globalSubscriberId": "Demonstration", + "subscriberName": "Demonstration" + }, + "requestInfo": { + "instanceName": "sample-instance-2", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "requestorId":"1234", + "suppressRollback": "false" + }, + "requestParameters": { + "subscriptionServiceType": "vLB" + } + } + }""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables(DelegateExecution 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) + + try { + // preProcessRequest(DelegateExecution execution) + DeleteGenericALaCarteServiceInstance deleteGenericALaCarteServiceInstance = new DeleteGenericALaCarteServiceInstance() + deleteGenericALaCarteServiceInstance.preProcessRequest(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + initializeVariables(mockExecution) + //verify(mockExecution).setVariable(Prefix + "Success", false) + }catch(Exception e){ + //ignore + } + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy new file mode 100644 index 0000000000..9b7d7ee21f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy @@ -0,0 +1,418 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution +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.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/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.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/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.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/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 (DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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 + + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy new file mode 100644 index 0000000000..0bce32716f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException + +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +@RunWith(MockitoJUnitRunner.class) +class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { + + def deleteVnfAdapterRequestXml = """ + RDM2WAGPLCP + fba1bd1e195a404cacb9ce17a9b2b421 + 78987 + + true + + TEST-REQUEST-ID-0123 + 1234 + + ebb9ef7b-a6a5-40e6-953e-f868f1767677 + http://localhost:28080/mso/WorkflowMessage/VNFAResponse/ebb9ef7b-a6a5-40e6-953e-f868f1767677 +""" + + def dbRequestXml = """ + + + + TEST-REQUEST-ID-0123 + BPMN + VolumeGroup successfully deleted + COMPLETE + 100 + + + +""" + + def completionRequestXml = """ + + TEST-REQUEST-ID-0123 + DELETE + VID + + Volume Group has been deleted successfully. + BPMN VF Module Volume action: DELETE +""" + + def falloutHandlerRequestXml = """ + + TEST-REQUEST-ID-0123 + DELETE + VID + + + Unexpected Error + 5000 + +""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + + @Test + public void testPrepareVnfAdapterDeleteRequest() { + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + when(mockExecution.getVariable("DELVfModVol_cloudRegion")).thenReturn('RDM2WAGPLCP') + when(mockExecution.getVariable("DELVfModVol_tenantId")).thenReturn('fba1bd1e195a404cacb9ce17a9b2b421') + when(mockExecution.getVariable("DELVfModVol_volumeGroupId")).thenReturn('78987') + when(mockExecution.getVariable("DELVfModVol_volumeGroupHeatStackId")).thenReturn('') + when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("DELVfModVol_serviceId")).thenReturn('1234') + when(mockExecution.getVariable("DELVfModVol_messageId")).thenReturn('ebb9ef7b-a6a5-40e6-953e-f868f1767677') + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn('') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareVnfAdapterDeleteRequest(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_deleteVnfARequest", deleteVnfAdapterRequestXml) + + } + + @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("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareDBRequest(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_updateInfraRequest", dbRequestXml) + } + + @Test + public void testPrepareCompletionHandlerRequest() { + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + when(mockExecution.getVariable("mso-request-id")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("DELVfModVol_source")).thenReturn('VID') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareCompletionHandlerRequest(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_CompleteMsoProcessRequest", completionRequestXml) + } + + @Test + public void testPrepareFalloutHandler() { + + WorkflowException workflowException = new WorkflowException('DeleteVfModuleVolumeInfraV1', 5000, 'Unexpected Error') + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + + when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable("DELVfModVol_source")).thenReturn('VID') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareFalloutHandler(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_Success", false) + verify(mockExecution).setVariable("DELVfModVol_FalloutHandlerRequest", falloutHandlerRequestXml) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..72f79c80d9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.utils.XmlComparator + +import static org.mockito.Mockito.* +/** + * @author sushilma + * @since January 10, 2018 + */ +@RunWith(MockitoJUnitRunner.class) +class DoCreateE2EServiceInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + String expectedServiceInstanceData = """ + 1234 + volte-service + voLTE type + voLTE role + Created + c1d4305f-cdbd-4bbe-9069-a2f4978fd89e + d4df5c27-98a1-4812-a8aa-c17f055b7a3f + """ + @Test + public void testPreProcessRequest(){ + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345") + when(mockExecution.getVariable("serviceType")).thenReturn("TRANSPORT") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("1234") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("volte-service") + when(mockExecution.getVariable("uuiRequest")).thenReturn("""{"service":{"serviceDefId":"c1d4305f-cdbd-4bbe-9069-a2f4978fd89e" , "templateId" : "d4df5c27-98a1-4812-a8aa-c17f055b7a3f"}}""") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') + DoCreateE2EServiceInstance obj = new DoCreateE2EServiceInstance() + obj.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(expectedServiceInstanceData, captor.getValue()) + } + + private ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateE2EServiceInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateE2EServiceInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateE2EServiceInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateE2EServiceInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + return mockExecution + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..5ee10bc931 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy @@ -0,0 +1,369 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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.onap.so.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 (DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") + + + // preProcessRequest(DelegateExecution 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("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + + // preProcessRequest(DelegateExecution 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/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..0a1f8f2859 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy @@ -0,0 +1,4324 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByName; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByName_404; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; +import static org.onap.so.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.delegate.DelegateExecution +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.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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 + ECOMP + true + + + string + 192.10.16.0/24 + 192.10.16.100/24 + ip-address + 1505857301954 + + + string + 192.110.17.0/24 + 192.110.17.110/24 + ip-address + 1505857301954 + + + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-create + true + subnetName + true + + + string + 192.10.16.0/24 + 192.10.16.100/24 + ip-address + 1505857301954 + + + + + + + 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_AlaCarte = +""" + + + + + + + + + + + + 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://localhost: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://localhost: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://localhost: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 + true + + 192.10.16.0/24 + 192.10.16.100/24 + + + 192.110.17.0/24 + 192.110.17.110/24 + + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + true + + 192.10.16.0/24 + 192.10.16.100/24 + + + true + true + false + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_generated + +""" + +String createNetworkRequest_Ipv4 = +""" + 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 + ECOMP + 1505857301954 + subnetName + true + + + string + 192.10.16.0/24 + 192.10.16.100/24 + ip-address + 1505857301954 + + + string + 192.110.17.0/24 + 192.110.17.110/24 + ip-address + 1505857301954 + + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Created + true + 1505857301954 + subnetName + true + + + string + 192.10.16.0/24 + 192.10.16.100/24 + ip-address + 1505857301954 + + + + + + 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.onap.so/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 (DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + + // preProcessRequest(DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(DelegateExecution 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", expectedXMLNetworkRequest) + 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(DelegateExecution 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(DelegateExecution 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_Ipv4) + + } + + @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_AlaCarte) + 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(DelegateExecution 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(DelegateExecution 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("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(DelegateExecution 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("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(DelegateExecution 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("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(DelegateExecution 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("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(DelegateExecution 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("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(DelegateExecution 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("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(DelegateExecution 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("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(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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", "all"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowAssignResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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, 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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, 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("aai.endpoint")).thenReturn("http://localhost:8090") + //old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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, 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.network.vpn-binding.uri")).thenReturn("") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.vpn-binding.uri")).thenReturn("") + when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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 callRESTQueryAAINetworkVpnBindingList_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBindingList_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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.network.vpn-binding.uri")).thenReturn("") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.vpn-binding.uri")).thenReturn("") + when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + //when(mockExecution.getVariable("mso.workflow.default.aai.network.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network-policy.uri")).thenReturn("") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.default.aai.network-table-reference.uri")).thenReturn("") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network-table-reference.uri")).thenReturn("") + when(mockExecution.getVariable("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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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", "all"); + + 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("aai.endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + //old: when(mockExecution.getVariable("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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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", "all"); + + 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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", "all"); + + 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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(DelegateExecution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.prepareRollbackData(mockExecution) + +// verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + + } + + @Test + public void postProcessResponse() { + + println "************ postProcessResponse() ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("testProcessKey")).thenReturn("DoCreateNetworkInstanceTest") + 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(DelegateExecution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.postProcessResponse(mockExecution) + +// verify(mockExecution,atLeastOnce()).getVariable("isDebugLogEnabled") + verify(mockExecution,atLeastOnce()).setVariable("prefix", Prefix) + verify(mockExecution,atLeastOnce()).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 + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy new file mode 100644 index 0000000000..cc6f89865f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInstance +import org.onap.so.bpmn.mock.StubResponseAAI + +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoCreateServiceInstanceTest { + def prefix = "DCRESI_" + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + void testPreProcessRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("MDTWNJ21") + when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_dev") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") + when(mockExecution.getVariable("productFamilyId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("sdnc.si.svc.types")).thenReturn("PORT-MIRROR,PPROBES") + + ServiceDecomposition decomposition = new ServiceDecomposition() + ModelInfo modelInfo = new ModelInfo() + ServiceInstance instance = new ServiceInstance() + instance.instanceId = "12345" + decomposition.modelInfo = modelInfo + decomposition.serviceInstance = instance + + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') + + + DoCreateServiceInstance obj = new DoCreateServiceInstance() + obj.preProcessRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", prefix) + verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:28080/mso/SDNCAdapterCallbackService") + } + + + + @Test + void testGetAAICustomerById() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn("/aai/v9/business/customers/customer") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8') + StubResponseAAI.MockGetCustomer("12345", "") + DoCreateServiceInstance obj = new DoCreateServiceInstance() + obj.getAAICustomerById(mockExecution) + + verify(mockExecution, times(1)).getVariable("aai.endpoint") + } + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateServiceInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateServiceInstance") + 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("DoCreateServiceInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateServiceInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy new file mode 100644 index 0000000000..6d9d5e5356 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +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.urlMatching +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +/** + * @author sushilma + * @since January 10, 2018 + */ +@RunWith(MockitoJUnitRunner.class) +class DoCreateVFCNetworkServiceInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + public void testAddNSRelationship(){ + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("nsInstanceId")).thenReturn("NS12345") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_dev") + when(mockExecution.getVariable("serviceType")).thenReturn("MSO-dev-service-type") + when(mockExecution.getVariable("serviceId")).thenReturn("SER12345") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + MockPutServiceInstance("MSO_dev", "MSO-dev-service-type", "SER12345"); + DoCreateVFCNetworkServiceInstance DoCreateVFCNetworkServiceInstance = new DoCreateVFCNetworkServiceInstance() + DoCreateVFCNetworkServiceInstance.addNSRelationship(mockExecution); + verify(mockExecution, times(1)).getVariable("aai.endpoint") + verify(mockExecution, times(1)).getVariable("mso.msoKey") + verify(mockExecution, times(1)).getVariable("aai.auth") + } + + private ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateVFCNetworkServiceInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVFCNetworkServiceInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateVFCNetworkServiceInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVFCNetworkServiceInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + return mockExecution + } + + public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId) { + stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId+"/relationship-list/relationship")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml").withBody("") + )); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy new file mode 100644 index 0000000000..c5c6187648 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy @@ -0,0 +1,202 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoCreateVfModuleRollbackTest { + + def prefix = "DCVFMR_" + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + void testPrepSDNCAdapterRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") + when(mockExecution.getVariable(prefix + "source")).thenReturn("VID") + when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "cloudSiteId")).thenReturn("RDM2WAGPLCP") + + when(mockExecution.getVariable(prefix + "rollbackSDNCRequestActivate")).thenReturn("true") + + + DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() + obj.prepSDNCAdapterRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + String expectedValue = FileUtil.readResourceFile("__files/DoCreateVfModuleRollback/sdncAdapterWorkflowRequest.xml") + XmlComparator.assertXMLEquals(expectedValue, captor.getValue()) + } + + + + @Test + void testBuildSDNCRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") + when(mockExecution.getVariable(prefix + "source")).thenReturn("VID") + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + + when(mockExecution.getVariable(prefix + "rollbackSDNCRequestActivate")).thenReturn("true") + + + DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() + String sdncRequest = obj.buildSDNCRequest(mockExecution, "svcInstId_test", "deactivate") + String expectedValue = FileUtil.readResourceFile("__files/DoCreateVfModuleRollback/deactivateSDNCRequest.xml") + XmlComparator.assertXMLEquals(expectedValue, sdncRequest) + } + + + + @Test + void testPrepVNFAdapterRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable(prefix + "mso-request-id")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:18080/mso/WorkflowMessage/') + + + DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() + String sdncRequest = obj.prepVNFAdapterRequest(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + String expectedValue = FileUtil.readResourceFile("__files/DoCreateVfModuleRollback/vnfAdapterRestV1Request.xml") + XmlComparator.assertXMLEquals(expectedValue, captor.getValue(), "messageId", "notificationUrl") + } + + @Test + void testDeleteNetworkPoliciesFromAAI() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoCreateVfModuleRollback.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("mso.workflow.custom.DoCreateVfModuleRollback.aai.version")).thenReturn("8") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData()) + List fqdnList = new ArrayList() + fqdnList.add("test") + when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) + mockData() + DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() + obj.deleteNetworkPoliciesFromAAI(mockExecution) + + Mockito.verify(mockExecution).setVariable("prefix", prefix) + Mockito.verify(mockExecution).setVariable(prefix + "networkPolicyFqdnCount", 1) + Mockito.verify(mockExecution).setVariable(prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", 200) + } + + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateVfModuleRollback") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVfModuleRollback") + 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("DoCreateVfModuleRollback") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVfModuleRollback") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + private static void mockData() { + stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) + stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) + .willReturn(aResponse() + .withStatus(200))); + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy new file mode 100644 index 0000000000..30e3779b53 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy @@ -0,0 +1,229 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoCreateVfModuleTest { + def prefix = "DCVFM_" + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + void testQueryAAIVfModule() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoCreateVfModule obj = new DoCreateVfModule() + obj.queryAAIVfModule(mockExecution) + Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleResponseCode", 200) + } + + + @Test + void testQueryAAIVfModuleForStatus() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345") + when(mockExecution.getVariable("DCVFM_vfModuleName")).thenReturn("module-0") + when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoCreateVfModule obj = new DoCreateVfModule() + obj.queryAAIVfModuleForStatus(mockExecution) + Mockito.verify(mockExecution).setVariable("DCVFM_orchestrationStatus", '') + Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleForStatusResponseCode", 200) + } + + + + @Test + void testPreProcessVNFAdapterRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable(prefix + "cloudSiteId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable("volumeGroupStackId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("MDTWNJ21") + when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "vfModuleIndex")).thenReturn("index") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + when(mockExecution.getVariable(prefix + "backoutOnFailure")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "volumeGroupId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "asdcServiceModelVersion")).thenReturn("1.0") + when(mockExecution.getVariable(prefix + "modelCustomizationUuid")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ced3") + when(mockExecution.getVariable("baseVfModuleId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "baseVfModuleHeatStackId")).thenReturn("12345") + String sdncGetResponse = FileUtil.readResourceFile("__files/DoCreateVfModule/sdncGetResponse.xml"); + when(mockExecution.getVariable(prefix + "getSDNCAdapterResponse")).thenReturn(sdncGetResponse) + Map map = new HashMap(); + map.put("vrr_image_name", "MDT17"); + map.put("availability_zone_0", "nova"); + map.put("vrr_flavor_name", "ns.c16r32d128.v1"); + when(mockExecution.getVariable("vnfParamsMap")).thenReturn(map) + when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") + + mockData() + DoCreateVfModule obj = new DoCreateVfModule() + obj.preProcessVNFAdapterRequest(mockExecution) + + String createVnfARequest = FileUtil.readResourceFile("__files/DoCreateVfModule/createVnfARequest.xml") + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl") + } + + @Test + void testQueryCloudRegion() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoCreateVfModule obj = new DoCreateVfModule() + obj.queryCloudRegion(mockExecution) + + Mockito.verify(mockExecution).setVariable("prefix", prefix) + Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/12345") + Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionReturnCode", "200") + } + + + + @Test + void testCreateNetworkPoliciesInAAI() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("mso.workflow.custom.DoCreateVfModule.aai.version")).thenReturn("8") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData()) + List fqdnList = new ArrayList() + fqdnList.add("test") + when(mockExecution.getVariable("DCVFM_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) + + mockData() + DoCreateVfModule obj = new DoCreateVfModule() + obj.createNetworkPoliciesInAAI(mockExecution) + + Mockito.verify(mockExecution).setVariable("prefix", prefix) + Mockito.verify(mockExecution).setVariable(prefix + "networkPolicyFqdnCount", 1) + Mockito.verify(mockExecution).setVariable(prefix + "aaiQqueryNetworkPolicyByFqdnReturnCode", 200) + } + + + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateVfModule") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVfModule") + 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("DoCreateVfModule") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVfModule") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + private static void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoCreateVfModule/getGenericVnfResponse.xml"))) + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module[?]vf-module-name=module-0")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoCreateVfModule/getGenericVnfResponse.xml"))) + stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/12345")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoCreateVfModule/cloudRegion_AAIResponse_Success.xml"))) + stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy new file mode 100644 index 0000000000..91e7086bd3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + + +@RunWith(MockitoJUnitRunner.class) +class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + def String volumeRollbackRequest = """ + + + 171907d6-cdf0-4e08-953d-81ee104005a7 + {{VOLUMEGROUPSTACKID}} + c2141e3fcae940fcb4797ec9115e5a7a + mtwnj1a + true + + 230fd6ac-2a39-4be4-9b1e-7b7e1cc039b5 + 88c871d6-be09-4982-8490-96b1d243fb34 + + 9a5a91e8-3b79-463c-81c3-874a78f5b567 + + true + http://localhost:8080/mso/WorkflowMessage/VNFAResponse/9a5a91e8-3b79-463c-81c3-874a78f5b567 + + """ + + def String volumeRollbackRequestWithStackId = """ + + + 171907d6-cdf0-4e08-953d-81ee104005a7 + mdt22avrr_volume01/0f1aaae8-efe3-45ce-83e1-bfad01db58d8 + c2141e3fcae940fcb4797ec9115e5a7a + mtwnj1a + true + + 230fd6ac-2a39-4be4-9b1e-7b7e1cc039b5 + 88c871d6-be09-4982-8490-96b1d243fb34 + + 9a5a91e8-3b79-463c-81c3-874a78f5b567 + + true + http://localhost:8080/mso/WorkflowMessage/VNFAResponse/9a5a91e8-3b79-463c-81c3-874a78f5b567 + + """ + + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + public void testBuildRollbackVolumeGroupRequestXml() { + DoCreateVfModuleVolumeV2 process = new DoCreateVfModuleVolumeV2() + String xml = process.buildRollbackVolumeGroupRequestXml( + "171907d6-cdf0-4e08-953d-81ee104005a7", // volumeGroupId + "mtwnj1a", // cloudSiteId + "c2141e3fcae940fcb4797ec9115e5a7a", // tenantId + "230fd6ac-2a39-4be4-9b1e-7b7e1cc039b5", // requestId + "88c871d6-be09-4982-8490-96b1d243fb34", // serviceInstanceId + "9a5a91e8-3b79-463c-81c3-874a78f5b567", // messageId + "http://localhost:8080/mso/WorkflowMessage/VNFAResponse/9a5a91e8-3b79-463c-81c3-874a78f5b567") // notificationUrl + + assertEquals(volumeRollbackRequest.replaceAll("\\s", ""), xml.replaceAll("\\s", "")) + } + + + @Test + public void testUpdateRollbackVolumeGroupRequestXml() { + DoCreateVfModuleVolumeV2 process = new DoCreateVfModuleVolumeV2() + String updatedXml = process.updateRollbackVolumeGroupRequestXml(volumeRollbackRequest, "mdt22avrr_volume01/0f1aaae8-efe3-45ce-83e1-bfad01db58d8") + assertEquals(volumeRollbackRequestWithStackId.replaceAll("\\s", ""), updatedXml.replaceAll("\\s", "")) + } + + @Test + public void testPrepareVnfAdapterCreateRequest (){ + ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV2') + + when(mockExecution.getVariable("prefix")).thenReturn('DCVFMODVOLV2_') + when(mockExecution.getVariable("serviceInstanceId")).thenReturn('') + when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id') + when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + when(mockExecution.getVariable("volumeGroupId")).thenReturn('1234') + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") + Map vfModuleInputParams = new HashMap() + vfModuleInputParams.put("param1","value1") + when(mockExecution.getVariable("vfModuleInputParams")).thenReturn(vfModuleInputParams) + DoCreateVfModuleVolumeV2 process = new DoCreateVfModuleVolumeV2() + process.prepareVnfAdapterCreateRequest(mockExecution,"true"); + Mockito.verify(mockExecution,times(2)).setVariable(captor.capture(), captor.capture()) + String DCVFMODVOLV2_createVnfARequest = captor.getValue(); + assertNotNull(DCVFMODVOLV2_createVnfARequest) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy new file mode 100644 index 0000000000..9b421d8b63 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.VnfResource + +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoCreateVnfTest { + def prefix = "DoCVNF_" + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + void testPreProcessRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + when(mockExecution.getVariable("vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable("vnfName")).thenReturn("skask-test") + + when(mockExecution.getVariable("productFamilyId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("MDTWNJ21") + + when(mockExecution.getVariable("vnfResourceDecomposition")).thenReturn(new VnfResource()) + when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") + + + + DoCreateVnf obj = new DoCreateVnf() + obj.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, times(31)).setVariable(captor.capture(), captor.capture()) + List list = captor.getAllValues() + String str = list.get(51) + Assert.assertEquals("http://localhost:28080/mso/SDNCAdapterCallbackService", str) + } + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoCreateVnf") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVnf") + 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("DoCreateVnf") + when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVnf") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..bbbb82b5aa --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy @@ -0,0 +1,169 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.infrastructure.scripts.DoCustomDeleteE2EServiceInstance +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase + +import static org.assertj.core.api.Assertions.assertThatThrownBy +import static org.mockito.Matchers.anyString +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.Mockito.eq + +class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) + + String Prefix = "CVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + public DoCustomDeleteE2EServiceInstanceTest(){ + super("DoCustomDeleteE2EServiceInstance") + } + + @Test + public void preProcessRequestTest(){ + + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + instance.preProcessRequest(mex) + verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/") + verify(mex).setVariable("siParamsXml", "") + } + + @Test + public void postProcessAAIGETSuccessTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true) + + String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml") + when(mex.getVariable("GENGS_service")).thenReturn(aaiGetResponse) + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + instance.postProcessAAIGET(mex) + + verify(mex).setVariable(eq("serviceRelationShip"), anyString()) + } + + @Test + public void postProcessAAIGETFailureTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false) + when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(false) + + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + assertThatThrownBy { instance.postProcessAAIGET(mex) } isInstanceOf BpmnError.class + } + + @Test + public void preInitResourcesOperStatusTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]") + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + instance.preInitResourcesOperStatus(mex) + + verify(mex).setVariable(eq("CVFMI_initResOperStatusRequest"), anyString()) + } + + @Test + public void preResourceDeleteTest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]") + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + instance.preResourceDelete(mex,"overlay") + verify(mex).setVariable("resourceType", "overlay") + } + + @Test + public void postProcessSDNCDeleteTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true") + when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn("DDELSI_") + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml") + String method = "deleteE2E"; + instance.postProcessSDNCDelete(mex, response, method) + // following method doesn't do anything currently -> nothing to check + } + + @Test + public void postProcessAAIDELTest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true") + DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() + instance.postProcessAAIDEL(mex) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceType")).thenReturn("VoLTE") + when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4") + when(mex.getVariable("requestAction")).thenReturn("ra") + when(mex.getVariable("operationId")).thenReturn("59960003992") + when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") + when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true") + when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/") + when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123") + when(mex.getVariable("GENGS_service")).thenReturn("test3434") + when(mex.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://localhost:8080/mso") + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..5e264c0af4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy @@ -0,0 +1,343 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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 (DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + + // preProcessRequest(DelegateExecution 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/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy new file mode 100644 index 0000000000..1a2d16d9d0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy @@ -0,0 +1,1948 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import static org.mockito.Mockito.* + +import static org.onap.so.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.onap.so.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.delegate.DelegateExecution +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.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("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 (DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + // preProcessRequest(DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + // preProcessRequest(DelegateExecution 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("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("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("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("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("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("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("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("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(DelegateExecution 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", "all"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("") + // old: when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("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=all") + + 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", "all"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("") + // old: when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("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=all") + + 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", "all"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("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=all") + + 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + 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(DelegateExecution 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(DelegateExecution 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 + + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy new file mode 100644 index 0000000000..a8bdfb0633 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoDeleteServiceInstanceTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090) + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + public void preProcessRequestTest() { + + ExecutionEntity mex = setupMock() + when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") + when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4") + when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") + when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123") + + DoDeleteServiceInstance instance = new DoDeleteServiceInstance() + instance.preProcessRequest(mex) + + Mockito.verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/") + Mockito.verify(mex).setVariable("siParamsXml", "") + } + + + @Test + public void testPostProcessAAIGET() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090') + when(mockExecution.getVariable("GENGS_FoundIndicator")).thenReturn(true) + when(mockExecution.getVariable("sdnc.si.svc.types")).thenReturn("") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalSubscriberId_test") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("subscriptionServiceType_test") + + String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml") + when(mockExecution.getVariable("GENGS_service")).thenReturn(aaiGetResponse) + when(mockExecution.getVariable("GENGS_siResourceLink")).thenReturn("/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + mockData() + DoDeleteServiceInstance instance = new DoDeleteServiceInstance() + instance.postProcessAAIGET(mockExecution) + + Mockito.verify(mockExecution).setVariable("sendToSDNC", true) + } + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteServiceInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteServiceInstance") + 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("DoDeleteServiceInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteServiceInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + private void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/.*")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile(""))) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy new file mode 100644 index 0000000000..fcb0fb0940 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.core.WorkflowException + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoDeleteVfModuleFromVnfTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testPreProcessRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("source")).thenReturn("VID") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("tenantId")).thenReturn("19123c2924c648eb8e42a3c1f14b7682") + when(mockExecution.getVariable("vfModuleId")).thenReturn("12345") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") + when(mockExecution.getVariable("sdncVersion")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + + DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf() + obj.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution).setVariable("prefix", "DDVFMV_") + Mockito.verify(mockExecution).setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null) + Mockito.verify(mockExecution).setVariable("mso-request-id", "12345") + Mockito.verify(mockExecution).setVariable("requestId", "12345") + Mockito.verify(mockExecution).setVariable("cloudSiteId", "12345") + Mockito.verify(mockExecution).setVariable("source", "VID") + Mockito.verify(mockExecution).setVariable("isVidRequest", "true") + Mockito.verify(mockExecution).setVariable("srvInstId", "") + Mockito.verify(mockExecution).setVariable("DDVFMV_serviceInstanceIdToSdnc", "12345") + Mockito.verify(mockExecution).setVariable("DDVFMV_sdncVersion", "8") + Mockito.verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:8090/SDNCAdapterCallback") + } + + + + @Test + void testDeleteNetworkPoliciesFromAAI() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleFromVnf.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("mso.workflow.custom.DoDeleteVfModuleFromVnf.aai.version")).thenReturn("8") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + List fqdnList = new ArrayList() + fqdnList.add("test") + when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) + mockData() + DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf() + obj.deleteNetworkPoliciesFromAAI(mockExecution) + + Mockito.verify(mockExecution).setVariable("prefix", 'DDVFMV_') + Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) + } + + + @Test + void testQueryAAIForVfModule() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("mso.workflow.global.default.aai.namespace") + when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + mockData() + DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf() + obj.queryAAIForVfModule(mockExecution) + + Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 200) + } + + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModuleFromVnf") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModuleFromVnf") + 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("DoDeleteVfModuleFromVnf") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModuleFromVnf") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + + } + + private static void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/GenerateVfModuleName_AAIResponse_Success.xml"))) + + stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) + + stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) + .willReturn(aResponse() + .withStatus(200))); + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy new file mode 100644 index 0000000000..3390b1a6f0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy @@ -0,0 +1,163 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoDeleteVfModuleTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testPrepSDNCAdapterRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + when(mockExecution.getVariable("requestId")).thenReturn("12345") + when(mockExecution.getVariable("source")).thenReturn("VID") + when(mockExecution.getVariable("serviceId")).thenReturn("12345") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("tenantId")).thenReturn("19123c2924c648eb8e42a3c1f14b7682") + when(mockExecution.getVariable("vfModuleId")).thenReturn("12345") + when(mockExecution.getVariable("DoDVfMod_serviceInstanceIdToSdnc")).thenReturn("123456789") + when(mockExecution.getVariable("vfModuleName")).thenReturn("vfModuleName_test") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + + DoDeleteVfModule obj = new DoDeleteVfModule() + obj.prepSDNCAdapterRequest(mockExecution, 'release') + + String expectedValue = FileUtil.readResourceFile("__files/DoDeleteVfModule/sdncAdapterWorkflowRequest.xml") + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(expectedValue, captor.getValue()) + } + + + @Test + void testDeleteNetworkPoliciesFromAAI() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.DoDeleteVfModule.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("mso.workflow.custom.DoDeleteVfModule.aai.version")).thenReturn("8") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + List fqdnList = new ArrayList() + fqdnList.add("test") + when(mockExecution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) + mockData() + DoDeleteVfModule obj = new DoDeleteVfModule() + obj.deleteNetworkPoliciesFromAAI(mockExecution) + + Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) + } + + + @Test + void testQueryAAIVfModuleForStatus() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345") + when(mockExecution.getVariable("DCVFM_vfModuleName")).thenReturn("module-0") + when(mockExecution.getVariable("mso.workflow.DoDeleteVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoCreateVfModule obj = new DoCreateVfModule() + obj.queryAAIVfModuleForStatus(mockExecution) + + Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleForStatusResponseCode", 200) + } + + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModule") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModule") + 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("DoDeleteVfModule") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModule") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + + } + + private static void mockData() { + stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) + + stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) + .willReturn(aResponse() + .withStatus(200))) + + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module[?]vf-module-name=module-0")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoDeleteVfModule/getGenericVnfResponse.xml"))) + + } +} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy new file mode 100644 index 0000000000..730be14df0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoDeleteVfModuleVolumeV2Test { + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testCallRESTQueryAAICloudRegion() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleVolumeV2.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() + obj.callRESTQueryAAICloudRegion(mockExecution, "true") + Mockito.verify(mockExecution).setVariable("DDVMV_queryCloudRegionReturnCode", "200") + Mockito.verify(mockExecution).setVariable("DDVMV_aicCloudRegion", "RDM2WAGPLCP") + } + + @Test + public void testCallRESTQueryAAICloudRegionAAiEndpointNull() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleVolumeV2.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + try { + DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() + obj.callRESTQueryAAICloudRegion(mockExecution, "true") + + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + Mockito.verify(mockExecution,atLeastOnce()).setVariable(captor.capture(),captor.capture()) + WorkflowException workflowException = captor.getValue() + Assert.assertEquals(9999, workflowException.getErrorCode()) + } + + @Test + public void testPrepareVnfAdapterDeleteRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("aicCloudRegion")).thenReturn("RegionOne") + when(mockExecution.getVariable("tenantId")).thenReturn("12345") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("12345") + when(mockExecution.getVariable("volumeGroupHeatStackId")).thenReturn("12345") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:18080/mso/WorkflowMessage") + + DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() + obj.prepareVnfAdapterDeleteRequest(mockExecution, "true") + + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + String str = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV2/vnfAdapterDeleteRequest.xml") + XmlComparator.assertXMLEquals(str, captor.getValue(),"messageId","notificationUrl") + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModuleVolumeV2") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModuleVolumeV2") + 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("DoDeleteVfModuleVolumeV2") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModuleVolumeV2") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + + } + + private void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/12345")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml"))) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy new file mode 100644 index 0000000000..0b95ffc053 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.core.WorkflowException + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +public class DoDeleteVnfAndModulesTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + String cloudConfiguration = "{ " + + "\"lcpCloudRegionId\": \"mdt1\"," + + "\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}"; + + @Before + public void init() throws IOException { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testPreProcessRequestTest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("cloudConfiguration")).thenReturn(cloudConfiguration) + when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("serviceInstanceId") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") + when(mockExecution.getVariable("productFamilyId")).thenReturn("productFamilyId") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("mdt1") + when(mockExecution.getVariable("tenantId")).thenReturn("19123c2924c648eb8e42a3c1f14b7682") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_test") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + + DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules() + obj.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution).setVariable("prefix", "DDVAM_") + Mockito.verify(mockExecution).setVariable("requestId", "12345") + Mockito.verify(mockExecution).setVariable("mso-request-id", "12345") + Mockito.verify(mockExecution).setVariable("DDVAM_source", "VID") + Mockito.verify(mockExecution).setVariable("DDVAM_isVidRequest", "true") + Mockito.verify(mockExecution).setVariable("DDVAM_sdncVersion", "1702") + Mockito.verify(mockExecution).setVariable("DDVAM_isVidRequest", "true") + Mockito.verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:8090/SDNCAdapterCallback") + } + + + + @Test + public void testQueryAAIVfModuleNullEndPoint() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoDeleteVnfAndModules.aai.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + try { + DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules() + obj.queryAAIVfModule(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + Mockito.verify(mockExecution,atLeastOnce()).setVariable(captor.capture(),captor.capture()) + WorkflowException workflowException = captor.getValue() + Assert.assertEquals("AAI GET Failed:null", workflowException.getErrorMessage()) + Assert.assertEquals(1002, workflowException.getErrorCode()) + } + + @Test + public void testQueryAAIVfModule() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.DoDeleteVnfAndModules.aai.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules() + obj.queryAAIVfModule(mockExecution) + + Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleResponseCode", 200) + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVnfAndModules") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVnfAndModules") + 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("DoDeleteVnfAndModules") + when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVnfAndModules") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + + } + + private void mockData() { + + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml"))); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..4e993525f9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC All rights reserved. * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase + +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +class DoScaleE2EServiceInstanceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) + + String Prefix = "CVRCS_" + + @BeforeClass + public static void setUpBeforeClass() { + request = FileUtil.readResourceFile("__files/InfrastructureFlows/DoScaleE2EServiceInstance.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + public DoScaleE2EServiceInstanceTest(){ + super("DoScaleE2EServiceInstance") + } + + @Test + public void preProcessRequestTest(){ + + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + DoScaleE2EServiceInstance instance = new DoScaleE2EServiceInstance() + instance.preProcessRequest(mex) + verify(mex).setVariable("resourceTemplateUUIDs", "ns111:ns333:") + } + + @Test + public void preInitResourcesOperStatusTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DoScaleE2EServiceInstance instance = new DoScaleE2EServiceInstance() + instance.preInitResourcesOperStatus(mex) + + verify(mex).setVariable("serviceInstanceId","e151059a-d924-4629-845f-264db19e50b4") + verify(mex).setVariable("operationId", "59960003992") + verify(mex).setVariable("operationType", "SCALE") + verify(mex).setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + + String payload = + """ + + + + e151059a-d924-4629-845f-264db19e50b4 + 59960003992 + SCALE + ns111:ns333: + + +""" + verify(mex).setVariable("CVFMI_initResOperStatusRequest", payload) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("msoRequestId")).thenReturn("mri") + when(mex.getVariable("serviceType")).thenReturn("VoLTE") + when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4") + when(mex.getVariable("serviceInstanceName")).thenReturn("ra") + when(mex.getVariable("operationId")).thenReturn("59960003992") + when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123") + when(mex.getVariable("resourceTemplateUUIDs")).thenReturn("ns111:ns333:") + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..0189d065df --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy @@ -0,0 +1,332 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.repository.ProcessDefinition +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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 (DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") + + + // preProcessRequest(DelegateExecution 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 + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..de3db5b5a8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy @@ -0,0 +1,2762 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + + +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; +import static org.onap.so.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.delegate.DelegateExecution +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.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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 = +""" + MNS-25180-L-01-dmz_direct_net_1 + 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 + 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 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 + ECOMP + true + + + 400d286b-7e44-4514-b9b3-f70f7360ff32 + 172.20.1.0/24 + 10.102.200.1 + ip-address + 1505857300987 + + + 6f038013-8b15-4eb8-914b-507489fbc8ee + 10.102.0.0/16 + 10.102.200.1 + ip-address + 1505857301151 + + + 8811c5f8-f1ed-4fa0-a505-e1be60396e28 + 192.168.2.0/25 + 10.102.200.1 + 1505857301954 + + + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + true + + + 400d286b-7e44-4514-b9b3-f70f7360ff32 + 172.20.1.0/24 + 10.102.200.1 + 1505857300987 + + + + + + + 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://localhost: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://localhost: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://localhost: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 + + 172.20.1.0/24 + 10.102.200.1 + + + 10.102.0.0/16 + 10.102.200.1 + + + 192.168.2.0/25 + 10.102.200.1 + + + 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 + + 172.20.1.0/24 + 10.102.200.1 + + + 10.102.0.0/16 + 10.102.200.1 + + + 192.168.2.0/25 + 10.102.200.1 + + + 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 + ECOMP + 1505857300987 + subnetName + true + + + 400d286b-7e44-4514-b9b3-f70f7360ff32 + 172.20.1.0/24 + 10.102.200.1 + ip-address + 1505857300987 + + + 6f038013-8b15-4eb8-914b-507489fbc8ee + 10.102.0.0/16 + 10.102.200.1 + ip-address + 1505857301151 + + + 8811c5f8-f1ed-4fa0-a505-e1be60396e28 + 192.168.2.0/25 + 10.102.200.1 + + 1505857301954 + + + + + + 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.onap.so/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" + + String aaiResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + MNS-25180-L-01-dmz_direct_net_1/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 (DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(DelegateExecution 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("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(Prefix + "queryIdAAIResponse")).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("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(DelegateExecution 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("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(DelegateExecution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareSDNCRollbackRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "WorkflowException", null) + 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", "all"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + + } + + @Test + 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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 + "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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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, 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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 callRESTQueryAAINetworkVpnBindingList_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBindingList_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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.default.aai.network-table-reference.uri")).thenReturn("") + when(mockExecution.getVariable("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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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", "all"); + + 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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", "all"); + + 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("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(DelegateExecution 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=all") + 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(DelegateExecution 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(DelegateExecution 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/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy new file mode 100644 index 0000000000..beaebceaf7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy @@ -0,0 +1,309 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.VfModule +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* +import org.onap.so.bpmn.common.scripts.utils.XmlComparator + +@RunWith(MockitoJUnitRunner.class) +class DoUpdateVfModuleTest { + + def prefix = "DOUPVfMod_" + String doUpdateVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/DoUpdateVfModuleRequest.xml"); + String sdncChangeAssignRequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncChangeAssignRequest.xml") + String sdncTopologyRequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncTopologyRequest.xml") + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Before + public void init() { + MockitoAnnotations.initMocks(this) + } + + @Test + void testPreProcessRequest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("DoUpdateVfModuleRequest")).thenReturn(doUpdateVfModuleRequest) + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") + + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution, atLeastOnce()).getVariable("mso.workflow.sdncadapter.callback") + } + + + + @Test + void testPrepConfirmVolumeGroupTenant() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("att-aic") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") + when(mockExecution.getVariable("mso.workflow.default.aai.cloud-region.version")).thenReturn("8") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.prepConfirmVolumeGroupTenant(mockExecution) + + Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionReturnCode", "200") + Mockito.verify(mockExecution).setVariable(prefix + "cloudRegionForVolume", "AAIAIC25") + Mockito.verify(mockExecution).setVariable(prefix + "isCloudRegionGood", true) + } + + + @Test + void testPrepSDNCTopologyChg() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("12345") + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + + + when(mockExecution.getVariable(prefix + "cloudSiteId")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable("volumeGroupStackId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("MDTWNJ21") + when(mockExecution.getVariable(prefix + "usePreload")).thenReturn("Y") + when(mockExecution.getVariable(prefix + "vnfNameFromAAI")).thenReturn("skask-test") + + def node = new Node(null, 'vfModule') + new Node(node, 'vf-module-name', "abc") + VfModule vfModule = new VfModule(node, true); + when(mockExecution.getVariable(prefix + "vfModule")).thenReturn(vfModule) + + when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + Map map = new HashMap(); + map.put("vrr_image_name", "MDT17"); + map.put("availability_zone_0", "nova"); + map.put("vrr_flavor_name", "ns.c16r32d128.v1"); + when(mockExecution.getVariable("vnfParamsMap")).thenReturn(map) + when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapter") + + mockData() + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.prepSDNCTopologyChg(mockExecution) + + Mockito.verify(mockExecution).setVariable(prefix + "vnfName", "skask-test") + + Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(sdncChangeAssignRequest, captor.getValue()) + } + + + + @Test + void testPrepSDNCTopologyQuery() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapter") + + mockData() + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.prepSDNCTopologyQuery(mockExecution) + + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(sdncTopologyRequest, captor.getValue()) + } + + + + @Test + void testPrepVnfAdapterRest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable(prefix + "volumeGroupStackId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "vfModuleIndex")).thenReturn("index") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + when(mockExecution.getVariable(prefix + "backoutOnFailure")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "volumeGroupId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "asdcServiceModelVersion")).thenReturn("1.0") + when(mockExecution.getVariable(prefix + "modelCustomizationUuid")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ced3") + when(mockExecution.getVariable(prefix + "baseVfModuleId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "baseVfModuleHeatStackId")).thenReturn("12345") + + def node = new Node(null, 'vfModule') + new Node(node, 'heat-stack-id', "abc") + VfModule vfModule = new VfModule(node, true); + when(mockExecution.getVariable(prefix + "vfModule")).thenReturn(vfModule) + + String sdncGetResponse = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncGetResponse.xml"); + when(mockExecution.getVariable(prefix + "sdncTopologyResponse")).thenReturn(sdncGetResponse) + Map map = new HashMap(); + map.put("vrr_image_name", "MDT17"); + map.put("availability_zone_0", "nova"); + map.put("vrr_flavor_name", "ns.c16r32d128.v1"); + when(mockExecution.getVariable(prefix + "vnfParamsMap")).thenReturn(map) + when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") + + mockData() + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.prepVnfAdapterRest(mockExecution) + + String createVnfARequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/vnfAdapterRestRequest.xml") + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl") + } + + + + @Test + void testPrepSDNCTopologyAct() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") + when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") + when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") + when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") + when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") + when(mockExecution.getVariable(prefix + "usePreload")).thenReturn("Y") + when(mockExecution.getVariable(prefix + "modelCustomizationUuid")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ced3") + + def node = new Node(null, 'vfModule') + new Node(node, 'vf-module-name', "abc") + VfModule vfModule = new VfModule(node, true); + when(mockExecution.getVariable(prefix + "vfModule")).thenReturn(vfModule) + + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapter") + + mockData() + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.prepSDNCTopologyAct(mockExecution) + + String createVnfARequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncActivateRequest.xml") + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue()) + } + + @Test + void testQueryAAIVfModule() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoUpdateVfModule obj = new DoUpdateVfModule() + obj.queryAAIVfModule(mockExecution) + Mockito.verify(mockExecution).setVariable(prefix + "queryAAIVfModuleResponseCode", 200) + } + + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoUpdateVfModule") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateVfModule") + 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("DoUpdateVfModule") + when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateVfModule") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + private static void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml"))) + + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoUpdateVfModule/getGenericVnfResponse.xml"))) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy new file mode 100644 index 0000000000..ba54787dc1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.core.WorkflowException + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class DoUpdateVnfAndModulesTest { + + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Before + public void init() { + MockitoAnnotations.initMocks(this) + } + + @Test + void testQueryAAIVfModule() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + DoUpdateVnfAndModules obj = new DoUpdateVnfAndModules() + obj.queryAAIVfModule(mockExecution) + Mockito.verify(mockExecution).setVariable("DUVAM_queryAAIVfModuleResponseCode", 200) + } + + @Test + @Ignore + void testQueryAAIVfModuleEndpointNull() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("vnfId")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + + mockData() + try { + DoUpdateVnfAndModules obj = new DoUpdateVnfAndModules() + obj.queryAAIVfModule(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + Mockito.verify(mockExecution, atLeastOnce()).setVariable(captor.capture(), captor.capture()) + WorkflowException workflowException = captor.getValue() + Assert.assertEquals(1002, workflowException.getErrorCode()) + Assert.assertEquals("AAI GET Failed:org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage()) + } + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("DoUpdateVfModule") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateVfModule") + 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("DoUpdateVfModule") + when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateVfModule") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + private static void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("DoUpdateVfModule/getGenericVnfResponse.xml"))) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..e196a62e1f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy @@ -0,0 +1,195 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.common.scripts.ExceptionUtil + + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +@RunWith(MockitoJUnitRunner.class) +class SacleCustomE2EServiceInstanceTest{ + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090); + + String Prefix="CRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + String globalSubscriberId="test_custormer" + String requestDescription = "request description for test" + def utils = new MsoUtils() + + String jsonIncomingRequest = """{"service":{ + "serviceType":"example-service-type", + "globalSubscriberId":"test_custormer", + "resources":[ + { + "resourceInstanceId":"ns111", + "scaleType":"SCALE_NS", + "scaleNsData":{ + "scaleNsByStepsData":{ + "numberOfSteps":"4", + "aspectId":"TIC_EDGE_HW", + "scalingDirection":"UP" + } + } + }, + { + "resourceInstanceId":"ns333", + "scaleType":"SCALE_NS", + "scaleNsData":{ + "scaleNsByStepsData":{ + "numberOfSteps":"4", + "aspectId":"TIC_EDGE_HW", + "scalingDirection":"UP" + } + } + }], + "serviceInstanceName":"XXXX" + }, + "operationId":"0a5b1651-c56e-4263-8c26-c8f8a6ef72d8" + }""" + + String xmlMsoCompletionRequest = """ + + 56c881ad-6c9d-4b79-aacc-401e5640b47f + SCALE + null + + Service Instance was scaled successfully. + 56c881ad-6c9d-4b79-aacc-401e5640b47f + ScaleGenericALaCarteServiceInstance +""" + + String requestInfo = """ + 56c881ad-6c9d-4b79-aacc-401e5640b47f + SCALE + null + """ + + String payload =""" + + + + 56c881ad-6c9d-4b79-aacc-401e5640b47f + 0a5b1651-c56e-4263-8c26-c8f8a6ef72d8 + SCALE + + processing + Prepare service scaling + 0 + + + + """ + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + public void preProcessRequestTest() { + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + + when(mockExecution.getVariable("mso-request-id")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") + + ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() + scaleCustomE2EServiceInstance.preProcessRequest(mockExecution) + + verify(mockExecution).setVariable("globalSubscriberId", globalSubscriberId) + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("requestDescription", requestDescription) + } + + @Test + public void sendSyncResponseTest() { + println "************ sendSyncResponse ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("operationId")).thenReturn("3338b250-e995-4782-8936-081b66ba4dbf") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") + + ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() + scaleCustomE2EServiceInstance.sendSyncResponse(mockExecution) + + verify(mockExecution).setVariable("sentSyncResponse", true) + } + + @Test + public void prepareCompletionRequestTest() { + println "************ prepareCompletionRequest ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("msoRequestId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") + + ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() + scaleCustomE2EServiceInstance.prepareCompletionRequest(mockExecution) + + verify(mockExecution).setVariable("CompleteMsoProcessRequest", xmlMsoCompletionRequest) + + } + + @Test + public void prepareInitServiceOperationStatusTest() { + println "************ prepareInitServiceOperationStatus ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") + //when(mockExecution.getVariable("serviceInstanceName")).thenReturn("XXXX") + when(mockExecution.getVariable("operationId")).thenReturn("0a5b1651-c56e-4263-8c26-c8f8a6ef72d8") + + ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() + scaleCustomE2EServiceInstance.prepareInitServiceOperationStatus(mockExecution) + + payload = utils.formatXml(payload) + verify(mockExecution).setVariable("CVFMI_updateServiceOperStatusRequest", payload) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..fd3c1e352f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy @@ -0,0 +1,358 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.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.delegate.DelegateExecution +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.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.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(DelegateExecution 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("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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(DelegateExecution 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 + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy new file mode 100644 index 0000000000..620b0b787d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy @@ -0,0 +1,134 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Assert +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* + +@RunWith(MockitoJUnitRunner.class) +class UpdateVfModuleVolumeInfraV1Test { + + def prefix = "UPDVfModVol_" + @Captor + static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + @Test + void testQueryAAIForVfModule() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDVfModVol_relatedVfModuleLink")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/12345") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + mockData() + UpdateVfModuleVolumeInfraV1 obj = new UpdateVfModuleVolumeInfraV1() + obj.queryAAIForVfModule(mockExecution, "true") + + Mockito.verify(mockExecution, atLeastOnce()).setVariable("UPDVfModVol_personaModelId", "ff5256d2-5a33-55df-13ab-12abad84e7ff") + } + + @Test + void testPrepVnfAdapterRest() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("") + when(mockExecution.getVariable(prefix + "aaiVolumeGroupResponse")).thenReturn(FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml")) + when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vnf1") + when(mockExecution.getVariable(prefix + "vnfVersion")).thenReturn("1") + when(mockExecution.getVariable(prefix + "AAIQueryGenericVfnResponse")).thenReturn(FileUtil.readResourceFile("__files/GenericFlows/getGenericVnfByNameResponse.xml")) + when(mockExecution.getVariable(prefix + "requestId")).thenReturn("12345") + when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") + when(mockExecution.getVariable("mso-request-id")).thenReturn("12345") + when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') + when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") + + mockData() + UpdateVfModuleVolumeInfraV1 obj = new UpdateVfModuleVolumeInfraV1() + obj.prepVnfAdapterRest(mockExecution, "true") + + Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + String expectedValue = FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml") + XmlComparator.assertXMLEquals(expectedValue, updateVolumeGroupRequest, "messageId", "notificationUrl") + } + + + private static ExecutionEntity setupMock() { + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("UpdateVfModuleVolumeInfraV1") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateVfModuleVolumeInfraV1") + 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("UpdateVfModuleVolumeInfraV1") + when(mockExecution.getProcessInstanceId()).thenReturn("UpdateVfModuleVolumeInfraV1") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + private static void mockData() { + stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/.*")) + .willReturn(aResponse() + .withStatus(200).withHeader("Content-Type", "text/xml") + .withBodyFile("UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml"))) + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy new file mode 100644 index 0000000000..523c791efc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -0,0 +1,1269 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.vcpe.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.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.HomingSolution +import org.onap.so.bpmn.mock.FileUtil + +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.patch +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.domain.AllottedResource +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.HomingSolution +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapGetter +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class CreateVcpeResCustServiceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "CVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public CreateVcpeResCustServiceTest() { + super("CreateVcpeResCustService") + } + + + // ***** preProcessRequest ***** + + @Test + @Ignore // 1802 merge + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("aaiDistDelay", "aaidelay") + verify(mex).setVariable("createVcpeServiceRequest", request) + verify(mex).setVariable("msoRequestId", "mri") + assertEquals("sii", map.get("serviceInstanceId")) + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("subscriptionServiceType", SVC) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + assertTrue(map.containsKey("subscriberInfo")) + + verify(mex).setVariable("brgWanMacAddress", "brgmac") + verify(mex).setVariable("customerLocation", ["customerLatitude":"32.897480", "customerLongitude":"-97.040443", "customerName":"some_company"]) + verify(mex).setVariable("homingService", "sniro") + assertTrue(map.containsKey("serviceInputParams")) + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test + // @Ignore + public void preProcessRequest_MissingAaiDistDelay() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + @Test + @Ignore // 1802 merge + public void preProcessRequest_EmptyParts() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + def req = request + .replace('"source"', '"sourceXXX"') + .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"') + .replace('"Customer_Location"', '"Customer_LocationXXX"') + + when(mex.getVariable("bpmnRequest")).thenReturn(req) + when(mex.getVariable("serviceInstanceId")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("createVcpeServiceRequest", req) + verify(mex).setVariable("msoRequestId", "mri") + assertNotNull(map.get("serviceInstanceId")) + assertFalse(map.get("serviceInstanceId").isEmpty()) + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("subscriptionServiceType", SVC) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + assertTrue(map.containsKey("subscriberInfo")) + + assertEquals("", map.get("brgWanMacAddress")) + assertEquals("", map.get("customerLocation")) + assertEquals("oof", map.get("homingService")) + assertTrue(map.containsKey("serviceInputParams")) + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + println reqinfo + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test + // @Ignore + public void preProcessRequest_MissingSubscriberId() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + def req = request + .replace('"globalSubscriberId"', '"globalSubscriberIdXXX"') + + when(mex.getVariable("bpmnRequest")).thenReturn(req) + when(mex.getVariable("serviceInstanceId")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + @Test + // @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + @Test + // @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + // ***** sendSyncResponse ***** + + @Test + // @Ignore + public void sendSyncResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncResponse(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncResponse(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("202", map.get(processName+"ResponseCode")) + assertEquals("Success", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf('"instanceId":"sii"') >= 0) + assertTrue(resp.indexOf('"requestId":"mri"') >= 0) + } + + @Test + // @Ignore + public void sendSyncResponse_Ex() { + ExecutionEntity mex = setupMock() + initSendSyncResponse(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.sendSyncResponse(mex) })) + } + + + // ***** prepareDecomposeService ***** + + @Test + // @Ignore + public void prepareDecomposeService() { + ExecutionEntity mex = setupMock() + initPrepareDecomposeService(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareDecomposeService(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("serviceModelInfo", "mi") + } + + @Test + // @Ignore + public void prepareDecomposeService_Ex() { + ExecutionEntity mex = setupMock() + initPrepareDecomposeService(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareDecomposeService(mex) })) + } + + + // ***** prepareCreateServiceInstance ***** + + @Test + // @Ignore + public void prepareCreateServiceInstance() { + ExecutionEntity mex = setupMock() + initPrepareCreateServiceInstance(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateServiceInstance(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("serviceInstanceName", "VCPE1") + verify(mex).setVariable("serviceDecompositionString", "mydecomp") + } + + @Test + // @Ignore + public void prepareCreateServiceInstance_Ex() { + ExecutionEntity mex = setupMock() + initPrepareCreateServiceInstance(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateServiceInstance(mex) })) + } + + + // ***** postProcessServiceInstanceCreate ***** + + @Test + // @Ignore + public void postProcessServiceInstanceCreate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessServiceInstanceCreate(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + def reqinfo = map.get(Prefix+"setUpdateDbInstancePayload") + + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("sii= 0) + assertTrue(reqinfo.indexOf("sin= 0) + } + + @Test + // @Ignore + public void postProcessServiceInstanceCreate_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessServiceInstanceCreate(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) })) + } + + @Test + // @Ignore + public void postProcessServiceInstanceCreate_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessServiceInstanceCreate(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) })) + } + + + // ***** processDecomposition ***** + + @Test + // @Ignore + public void processDecomposition() { + ExecutionEntity mex = setupMock() + def svcdecomp = initProcessDecomposition(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.processDecomposition(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfList", svcdecomp.getVnfResources()) + verify(mex).setVariable("vnfListString", '[myvnf]') + verify(mex).setVariable(Prefix+"VNFsCount", 1) + + verify(mex).setVariable("vnfModelInfo", "mymodel") + verify(mex).setVariable("vnfModelInfoString", "mymodel") + } + + @Test + // @Ignore + public void processDecomposition_EmptyNet_EmptyVnf() { + ExecutionEntity mex = setupMock() + def svcdecomp = initProcessDecomposition(mex) + + when(svcdecomp.getVnfResources()).thenReturn(new LinkedList()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.processDecomposition(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfList", svcdecomp.getVnfResources()) + verify(mex).setVariable("vnfListString", '[]') + verify(mex).setVariable(Prefix+"VNFsCount", 0) + + verify(mex).setVariable("vnfModelInfo", "") + verify(mex).setVariable("vnfModelInfoString", "") + } + + @Test + // @Ignore + public void processDecomposition_Ex() { + ExecutionEntity mex = setupMock() + def svcdecomp = initProcessDecomposition(mex) + + when(svcdecomp.getVnfResources()).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processDecomposition(mex) })) + } + + + // ***** filterVnfs ***** + + @Test + // @Ignore + public void filterVnfs() { + ExecutionEntity mex = setupMock() + def svcdecomp = initFilterVnfs(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.processDecomposition(mex) + + verify(mex).setVariable("vnfListString", '[myvnf3, myvnf5]') + } + + @Test + // @Ignore + public void filterVnfs_Null() { + ExecutionEntity mex = setupMock() + def svcdecomp = initFilterVnfs(mex) + + when(svcdecomp.getVnfResources()).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.processDecomposition(mex) + + // nothing more to check, as long as it didn't throw an exception + } + + + // ***** prepareCreateAllottedResourceTXC ***** + + @Test + // @Ignore + public void prepareCreateAllottedResourceTXC() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceTXC(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("createTXCAR", true) + verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB") + verify(mex).setVariable("allottedResourceRoleTXC", "TXCr") + verify(mex).setVariable("allottedResourceTypeTXC", "Tunnel XConn") + verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB") + } + + @Test + // @Ignore + public void prepareCreateAllottedResourceTXC_NullArList() { + ExecutionEntity mex = setupMock() + def svcdecomp = initPrepareCreateAllottedResourceTXC(mex) + + when(svcdecomp.getAllottedResources()).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex, never()).setVariable("createTXCAR", true) + verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB") + verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr") + verify(mex, never()).setVariable("allottedResourceTypeTXC", "Tunnel XConn") + verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB") + } + + @Test + // @Ignore + public void prepareCreateAllottedResourceTXC_Ex() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceTXC(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) })) + } + + + // ***** prepareCreateAllottedResourceBRG ***** + + @Test + // @Ignore + public void prepareCreateAllottedResourceBRG() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceBRG(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("createBRGAR", true) + verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB") + verify(mex).setVariable("allottedResourceRoleBRG", "BRGr") + verify(mex).setVariable("allottedResourceTypeBRG", "BRG") + verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB") + } + + @Test + // @Ignore + public void prepareCreateAllottedResourceBRG_NullArList() { + ExecutionEntity mex = setupMock() + def svcdecomp = initPrepareCreateAllottedResourceBRG(mex) + + when(svcdecomp.getAllottedResources()).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex, never()).setVariable("createBRGAR", true) + verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB") + verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr") + verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG") + verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB") + } + + @Test + // @Ignore + public void prepareCreateAllottedResourceBRG_Ex() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceBRG(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) })) + } + + + // ***** prepareVnfAndModulesCreate ***** + + @Test + // @Ignore + public void prepareVnfAndModulesCreate() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + } + + @Test + // @Ignore + public void prepareVnfAndModulesCreate_EmptyList() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + when(mex.getVariable("vnfList")).thenReturn(new LinkedList()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + } + + @Test + // @Ignore + public void prepareVnfAndModulesCreate_NullList() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + when(mex.getVariable("vnfList")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + } + + @Test + // @Ignore + public void prepareVnfAndModulesCreate_Ex() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) })) + } + + + // ***** validateVnfCreate ***** + + @Test + // @Ignore + public void validateVnfCreate() { + ExecutionEntity mex = setupMock() + initValidateVnfCreate(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.validateVnfCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"VnfsCreatedCount", 3) + } + + @Test + // @Ignore + public void validateVnfCreate_Ex() { + ExecutionEntity mex = setupMock() + initValidateVnfCreate(mex) + + when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.validateVnfCreate(mex) })) + } + + + // ***** postProcessResponse ***** + + @Test + // @Ignore + public void postProcessResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessResponse(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"Success", true) + + def reqinfo = map.get(Prefix+"CompleteMsoProcessRequest") + + assertTrue(reqinfo.indexOf("request-id>mri= 0) + assertTrue(reqinfo.indexOf("source>mysrc= 0) + assertTrue(reqinfo.indexOf("serviceInstanceId>sii= 0) + } + + @Test + // @Ignore + public void postProcessResponse_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) })) + } + + @Test + // @Ignore + public void postProcessResponse_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) })) + } + + + // ***** preProcessRollback ***** + + @Test + // @Ignore + public void preProcessRollback() { + ExecutionEntity mex = setupMock() + def wfe = initPreProcessRollback(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("prevWorkflowException", wfe) + } + + @Test + // @Ignore + public void preProcessRollback_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPreProcessRollback(mex) + + when(mex.getVariable("WorkflowException")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("prevWorkflowException")) + } + + @Test + // @Ignore + public void preProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPreProcessRollback(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("prevWorkflowException")) + } + + @Test + // @Ignore + public void preProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPreProcessRollback(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("prevWorkflowException")) + } + + + // ***** postProcessRollback ***** + + @Test + // @Ignore + public void postProcessRollback() { + ExecutionEntity mex = setupMock() + def wfe = initPostProcessRollback(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("WorkflowException", wfe) + } + + @Test + // @Ignore + public void postProcessRollback_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPostProcessRollback(mex) + + when(mex.getVariable("prevWorkflowException")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("WorkflowException")) + } + + @Test + // @Ignore + public void postProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPostProcessRollback(mex) + + when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessRollback(mex) })) + } + + @Test + // @Ignore + public void postProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPostProcessRollback(mex) + + when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("WorkflowException")) + } + + + // ***** prepareFalloutRequest ***** + + @Test + // @Ignore + public void prepareFalloutRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareFalloutRequest(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + def fo = map.get(Prefix+"falloutRequest") + + assertTrue(fo.indexOf("world= 0) + assertTrue(fo.indexOf("ErrorMessage>mymsg= 0) + assertTrue(fo.indexOf("ErrorCode>999= 0) + } + + @Test + // @Ignore + public void prepareFalloutRequest_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) })) + } + + // ***** sendSyncError ***** + + @Test + // @Ignore + public void sendSyncError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>mymsg= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test + // @Ignore + public void sendSyncError_NotWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn("not a WFE") + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test + // @Ignore + public void sendSyncError_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test + // @Ignore + public void sendSyncError_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + CreateVcpeResCustService.sendSyncError(mex) + + assertFalse(map.containsKey(processName+"ResponseCode")) + } + + + // ***** processJavaException ***** + + @Test + // @Ignore + public void processJavaException() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable("prefix", Prefix) + + def wfe = map.get("WorkflowException") + + assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage()) + } + + @Test + // @Ignore + public void processJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) + + assertFalse(map.containsKey("WorkflowException")) + } + + @Test + // @Ignore + public void processJavaException_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) + + def wfe = map.get("WorkflowException") + + assertEquals("Exception in processJavaException method", wfe.getErrorMessage()) + } + + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn("aaidelay") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("requestAction")).thenReturn("ra") + } + + private initSendSyncResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + } + + private void initPrepareDecomposeService(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}') + } + + private void initPrepareCreateServiceInstance(ExecutionEntity mex) { + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + + when(svcdecomp.toJsonStringNoRootName()).thenReturn("mydecomp") + } + + private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("serviceInstanceName")).thenReturn("sin") + } + + private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex) { + List vnflst = new LinkedList<>() + vnflst.add(makeVnf("", "")) + vnflst.add(makeVnf("2", "BRG")) + vnflst.add(makeVnf("3", "BRG")) + + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + when(svcdecomp.getVnfResources()).thenReturn(vnflst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("serviceInstanceName")).thenReturn("sin") + + return svcdecomp + } + + private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) { + List vnflst = new LinkedList<>() + vnflst.add(makeVnf("", "BRG")) + vnflst.add(makeVnf("2", "Tunnel XConn")) + vnflst.add(makeVnf("3", "")) + vnflst.add(makeVnf("4", "BRG")) + vnflst.add(makeVnf("5", "other")) + + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + when(svcdecomp.getVnfResources()).thenReturn(vnflst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("serviceInstanceName")).thenReturn("sin") + + return svcdecomp + } + + private initAwaitAaiDistribution(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) { + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + List arlst = new LinkedList<>() + + arlst.add(makeArBRG("A")) + arlst.add(makeArTXC("B")) + arlst.add(makeArBRG("C")) + + when(svcdecomp.getAllottedResources()).thenReturn(arlst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + + return svcdecomp + } + + private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) { + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + List arlst = new LinkedList<>() + + arlst.add(makeArTXC("A")) + arlst.add(makeArBRG("B")) + arlst.add(makeArTXC("C")) + + when(svcdecomp.getAllottedResources()).thenReturn(arlst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + + return svcdecomp + } + + private AllottedResource makeArTXC(String id) { + AllottedResource ar = mock(AllottedResource.class) + ModelInfo mod = mock(ModelInfo.class) + HomingSolution home = mock(HomingSolution.class) + + when(ar.toJsonStringNoRootName()).thenReturn("json"+id) + when(ar.getAllottedResourceType()).thenReturn("Tunnel XConn") + when(ar.getModelInfo()).thenReturn(mod) + when(ar.getAllottedResourceRole()).thenReturn("TXCr") + when(ar.getHomingSolution()).thenReturn(home) + + when(mod.toJsonStringNoRootName()).thenReturn("model"+id) + + when(home.getServiceInstanceId()).thenReturn("home"+id) + + return ar + } + + private AllottedResource makeArBRG(String id) { + AllottedResource ar = mock(AllottedResource.class) + ModelInfo mod = mock(ModelInfo.class) + HomingSolution home = mock(HomingSolution.class) + + when(ar.toJsonStringNoRootName()).thenReturn("json"+id) + when(ar.getAllottedResourceType()).thenReturn("BRG") + when(ar.getModelInfo()).thenReturn(mod) + when(ar.getAllottedResourceRole()).thenReturn("BRGr") + when(ar.getHomingSolution()).thenReturn(home) + + when(mod.toJsonStringNoRootName()).thenReturn("model"+id) + + when(home.getServiceInstanceId()).thenReturn("home"+id) + + return ar + } + + private initPrepareVnfAndModulesCreate(ExecutionEntity mex) { + + List vnflst = new LinkedList<>() + + vnflst.add(makeVnf("A", "BRG")) + vnflst.add(makeVnf("B", "")) + vnflst.add(makeVnf("C", "")) + vnflst.add(makeVnf("D", "Tunnel XConn")) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("vnfList")).thenReturn(vnflst) + when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2) + when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel") + when(mex.getVariable("sdncVersion")).thenReturn("myvers") + } + + private VnfResource makeVnf(String id, String role) { + ModelInfo mod = mock(ModelInfo.class) + VnfResource vnf = mock(VnfResource.class) + + when(mod.toString()).thenReturn('{"modelInfo":"mymodel'+id+'"}') + + when(vnf.toString()).thenReturn("myvnf"+id) + when(vnf.getModelInfo()).thenReturn(mod) + when(vnf.getNfRole()).thenReturn(role) + + return vnf + } + + private initValidateVnfCreate(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2) + } + + private initPostProcessResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("source")).thenReturn("mysrc") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + } + + private WorkflowException initPreProcessRollback(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + return wfe + } + + private WorkflowException initPostProcessRollback(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) + + return wfe + } + + private initPrepareFalloutRequest(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + when(wfe.getErrorCode()).thenReturn(999) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + when(mex.getVariable(Prefix+"requestInfo")).thenReturn("world") + + return wfe + } + + private initSendSyncError(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + } + + private initProcessJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy new file mode 100644 index 0000000000..b7c754938a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy @@ -0,0 +1,773 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.vcpe.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.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +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.patch +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource +import org.onap.so.bpmn.core.domain.AllottedResource +import org.onap.so.bpmn.core.domain.ModelInfo + +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapGetter +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DeleteVcpeResCustServiceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DeleteVcpeResCustServiceTest() { + super("DeleteVcpeResCustService") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + + assertEquals(Prefix, map.get("prefix")) + assertEquals(request, map.get("DeleteVcpeResCustServiceRequest")) + assertEquals("mri", map.get("msoRequestId")) + assertEquals("ra", map.get("requestAction")) + assertEquals("VID", map.get("source")) + assertEquals(CUST, map.get("globalSubscriberId")) + assertEquals(CUST, map.get("globalCustomerId")) + assertEquals("false", map.get("disableRollback")) + assertEquals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", map.get("productFamilyId")) + assertEquals(SVC, map.get("subscriptionServiceType")) + + assertEquals("mdt1", map.get("lcpCloudRegionId")) + assertEquals("8b1df54faa3b49078e3416e21370a3ba", map.get("tenantId")) + assertEquals("1707", map.get("sdncVersion")) + assertEquals("service-instance", map.get("GENGS_type")) + assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration")) + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test +// @Ignore + public void preProcessRequest_EmptyParts() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + def req = request + .replace('"source"', '"sourceXXX"') + + when(mex.getVariable("bpmnRequest")).thenReturn(req) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("DeleteVcpeResCustServiceRequest", req) + verify(mex).setVariable("msoRequestId", "mri") + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("subscriptionServiceType", SVC) + + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration")) + verify(mex).setVariable("sdncVersion", "1707") + verify(mex).setVariable("GENGS_type", "service-instance") + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + println reqinfo + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test +// @Ignore + public void preProcessRequest_MissingServiceInstanceId() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenReturn(null) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("requestAction")).thenReturn("ra") + } + + // ***** sendSyncResponse ***** + + @Test +// @Ignore + public void sendSyncResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncResponse(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncResponse(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("202", map.get(processName+"ResponseCode")) + assertEquals("Success", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf('"instanceId":"sii"') >= 0) + assertTrue(resp.indexOf('"requestId":"mri"') >= 0) + } + + @Test +// @Ignore + public void sendSyncResponse_Ex() { + ExecutionEntity mex = setupMock() + initSendSyncResponse(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.sendSyncResponse(mex) })) + } + + private initSendSyncResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + } + + // ***** prepareServiceDelete ***** + + @Test +// @Ignore + public void prepareServiceDelete() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareServiceDelete(mex) + + myMockGetAr("/aai/v11/anytxc", 200, "arGetTXCById.xml"); + myMockGetAr("/aai/v11/anybrg", 200, "arGetBRGById.xml"); + myMockGetAr("/aai/v11/other", 200, "arGetOtherById.xml"); + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareServiceDelete(mex) + + verify(mex).setVariable(Prefix+"TunnelXConn", true) + assertEquals("ar-txcA", map.get("TXC_allottedResourceId")) + + verify(mex).setVariable(Prefix+"BRG", true) + assertEquals("ar-brgB", map.get("BRG_allottedResourceId")) + + verify(mex).setVariable(Prefix+"vnfsCount", 2) + assertNotNull(map.get(Prefix+"relatedVnfIdList")) + assertEquals("[vnfX, vnfY]", map.get(Prefix+"relatedVnfIdList").toString()) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_NotFound() { + ExecutionEntity mex = setupMock() + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_Empty() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_service")).thenReturn("") + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareServiceDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"TunnelXConn", false) + assertNull(map.get("TXC_allottedResourceId")) + + verify(mex).setVariable(Prefix+"BRG", false) + assertNull(map.get("BRG_allottedResourceId")) + + assertEquals(0, map.get(Prefix+"vnfsCount")) + assertFalse(map.containsKey(Prefix+"relatedVnfIdList")) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_BpmnError() { + ExecutionEntity mex = setupMock() + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_Ex() { + ExecutionEntity mex = setupMock() + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + } + + private initPrepareServiceDelete(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(true) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("DeleteVcpeResCustServiceRequest")).thenReturn(request) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("GENGS_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml")) + } + + // ***** getAaiAr ***** + + @Test +// @Ignore + public void getAaiAr() { + myMockGetAr("/myurl/ar1", 200, "arGetBRGById.xml"); + + ExecutionEntity mex = setupMock() + initGetAaiAr(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1") + + assertEquals("BRG", type) + assertEquals("ar-brgB", id) + } + + @Test +// @Ignore + public void getAaiAr_401() { + myMockGetAr("/myurl/ar1", 401, "arGetBRGById.xml"); + + ExecutionEntity mex = setupMock() + initGetAaiAr(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1") + + assertEquals(null, type) + assertEquals(null, id) + } + + @Test +// @Ignore + public void getAaiAr_EmptyResponse() { + myMockGetAr("/myurl/ar1", 200, "empty.txt"); + + ExecutionEntity mex = setupMock() + initGetAaiAr(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1") + + assertEquals(null, type) + assertEquals(null, id) + } + + private void initGetAaiAr(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + + // ***** prepareVnfAndModulesDelete ***** + + @Test +// @Ignore + public void prepareVnfAndModulesDelete() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesDelete(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfId", "vnfB") + } + + @Test +// @Ignore + public void prepareVnfAndModulesDelete_Empty() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesDelete(mex) + + when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(new LinkedList()) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfId", "") + } + + @Test +// @Ignore + public void prepareVnfAndModulesDelete_Ex() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesDelete(mex) + + when(mex.getVariable(Prefix+"relatedVnfIdList")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) })) + } + + private initPrepareVnfAndModulesDelete(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(Arrays.asList("vnfA", "vnfB", "vnfC")) + when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(1) + } + + // ***** validateVnfDelete ***** + + @Test +// @Ignore + public void validateVnfDelete() { + ExecutionEntity mex = setupMock() + initValidateVnfDelete(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.validateVnfDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"vnfsDeletedCount", 3) + } + + @Test +// @Ignore + public void validateVnfDelete_Ex() { + ExecutionEntity mex = setupMock() + initValidateVnfDelete(mex) + + when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.validateVnfDelete(mex) })) + } + + private initValidateVnfDelete(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(2) + } + + // ***** postProcessResponse ***** + + @Test +// @Ignore + public void postProcessResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.postProcessResponse(mex) + + verify(mex).getVariable(DBGFLAG) + + assertEquals(true, map.get(Prefix+"Success")) + + def req = map.get(Prefix+"CompleteMsoProcessRequest") + + assertTrue(req.indexOf("mri= 0) + assertTrue(req.indexOf("mysrc= 0) + } + + @Test +// @Ignore + public void postProcessResponse_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) })) + } + + @Test +// @Ignore + public void postProcessResponse_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) })) + } + + private initPostProcessResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("source")).thenReturn("mysrc") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + + // ***** prepareFalloutRequest ***** + + @Test +// @Ignore + public void prepareFalloutRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareFalloutRequest(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + def fo = map.get(Prefix+"falloutRequest") + + assertTrue(fo.indexOf("world= 0) + assertTrue(fo.indexOf("ErrorMessage>mymsg= 0) + assertTrue(fo.indexOf("ErrorCode>999= 0) + } + + @Test +// @Ignore + public void prepareFalloutRequest_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.prepareFalloutRequest(mex) })) + } + + private initPrepareFalloutRequest(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + when(wfe.getErrorCode()).thenReturn(999) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + when(mex.getVariable(Prefix+"requestInfo")).thenReturn("world") + + return wfe + } + + // ***** sendSyncError ***** + + @Test +// @Ignore + public void sendSyncError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>mymsg= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_NotWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn("not a WFE") + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn(null) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + DeleteVcpeResCustService.sendSyncError(mex) + + assertFalse(map.containsKey(processName+"ResponseCode")) + } + + private initSendSyncError(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + } + + + // ***** processJavaException ***** + + @Test +// @Ignore + public void processJavaException() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable("prefix", Prefix) + + def wfe = map.get("WorkflowException") + + assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage()) + } + + @Test +// @Ignore + public void processJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) + + assertFalse(map.containsKey("WorkflowException")) + } + + @Test +// @Ignore + public void processJavaException_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) + + def wfe = map.get("WorkflowException") + + assertEquals("Exception in processJavaException method", wfe.getErrorMessage()) + } + + private initProcessJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private void myMockGetAr(String url, int status, String fileResp) { + stubFor(get(urlMatching(url)) + .willReturn(aResponse() + .withStatus(status) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VCPE/DeleteVcpeResCustService/" + fileResp))); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy new file mode 100644 index 0000000000..1e8842e68f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy @@ -0,0 +1,654 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +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.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource + +import org.onap.so.bpmn.core.RollbackData + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARBRGRB_" + String RbType = "DCARBRG_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceBRGRollbackTest() { + super("DoCreateAllottedResourceBRGRollback") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + ////verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_RollbackDisabled() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("disableRollback")).thenReturn("true") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + ////verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + data.put(RbType, "rollbackAAI", "false") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex, never()).setVariable("rollbackAAI", true) + verify(mex, never()).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAssign() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + data.put(RbType, "rollbackSDNCassign", "false") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex, never()).setVariable("rollbackSDNC", true) + verify(mex, never()).setVariable("deactivateSdnc", "myactivate") + verify(mex, never()).setVariable("deleteSdnc", "mycreate") + verify(mex, never()).setVariable("unassignSdnc", "true") + verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex, never()).setVariable("sdncDeleteRequest", "createreq") + verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI_NoAssign() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoRbStructure() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(new RollbackData()) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NullRb() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) })) + } + + @Test + @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_EmptyResponse() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + wireMockRule + .stubFor(get(urlMatching("/aai/v[0-9]+/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") })) + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_NoArPath() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + when(mex.getVariable("aaiARPath")).thenReturn(null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError404() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test + @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void postProcessRequest() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_RolledBack() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenReturn(true) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void processRollbackException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackException(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") + verify(mex).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") + verify(mex, never()).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) + } + + private RollbackData initPreProcess(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + when(mex.getVariable("rollbackAAI")).thenReturn(true) + when(mex.getVariable("rollbackSDNC")).thenReturn(true) + when(mex.getVariable("disableRollback")).thenReturn("false") + + data.put("SERVICEINSTANCE", "allottedResourceId", "myid") + + data.put(RbType, "serviceInstanceId", "sii") + data.put(RbType, "parentServiceInstanceId", "psii") + + data.put(RbType, "rollbackAAI", "true") + data.put(RbType, "aaiARPath", "mypath") + + data.put(RbType, "rollbackSDNCassign", "true") + data.put(RbType, "rollbackSDNCactivate", "myactivate") + data.put(RbType, "rollbackSDNCcreate", "mycreate") + data.put(RbType, "sdncActivateRollbackReq", "activatereq") + data.put(RbType, "sdncCreateRollbackReq", "createreq") + data.put(RbType, "sdncAssignRollbackReq", "assignreq") + + return data + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + } + + private initPostProcessRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("skipRollback")).thenReturn(false) + } + + private initProcessRollbackException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initProcessRollbackJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy new file mode 100644 index 0000000000..543bb1db05 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy @@ -0,0 +1,999 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 + +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceBRGTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARBRG_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceBRGTest() { + super("DoCreateAllottedResourceBRG") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + + assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) + assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) + assertTrue(checkMissingPreProcessRequest("vni")) + assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP")) + assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) + assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) + assertTrue(checkMissingPreProcessRequest("allottedResourceType")) + } + + + // ***** getAaiAR ***** + + @Test + @Ignore + public void getAaiAR() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.getAaiAR(mex) + + verify(mex).setVariable("foundActiveAR", true) + } + + @Test +// @Ignore + public void getAaiAR_Duplicate() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + // fail if duplicate + when(mex.getVariable("failExists")).thenReturn("true") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) + } + + @Test +// @Ignore + public void getAaiAR_NotActive() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + // not active + when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) + } + + @Test + @Ignore + public void getAaiAR_NoStatus() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.getAaiAR(mex) + + verify(mex, never()).setVariable("foundActiveAR", true) + } + + + // ***** createAaiAR ***** + + @Test + @Ignore + public void createAaiAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.createAaiAR(mex) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals("45", data.get(Prefix, "disableRollback")) + assertEquals("true", data.get(Prefix, "rollbackAAI")) + assertEquals(ARID, data.get(Prefix, "allottedResourceId")) + assertEquals("sii", data.get(Prefix, "serviceInstanceId")) + assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) + assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath")) + } + + @Test + @Ignore + public void createAaiAR_NoArid_NoModelUuids() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + // no allottedResourceId - will be generated + + when(mex.getVariable("allottedResourceId")).thenReturn(null) + + wireMockRule + .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.createAaiAR(mex) + + def arid = map.get("allottedResourceId") + assertNotNull(arid) + assertFalse(arid.isEmpty()) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals(arid, data.get(Prefix, "allottedResourceId")) + } + + @Test +// @Ignore + public void createAaiAR_MissingPsiLink() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("PSI_resourceLink")).thenReturn(null) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_HttpFailed() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + MockPutAllottedResource_500(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception")) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception")) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("sst= 0) + assertTrue(result.indexOf("gci= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("bwma= 0) + assertTrue(result.indexOf("myvni= 0) + assertTrue(result.indexOf("vbi= 0) + assertTrue(result.indexOf("miu= 0) + assertTrue(result.indexOf("mu= 0) + assertTrue(result.indexOf("mcu= 0) + assertTrue(result.indexOf("mv= 0) + assertTrue(result.indexOf("mn= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_EmptyModelInfo() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("sst= 0) + assertTrue(result.indexOf("gci= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("bwma= 0) + assertTrue(result.indexOf("myvni= 0) + assertTrue(result.indexOf("vbi= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCAssign ***** + + @Test +// @Ignore + public void preProcessSDNCAssign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) + + def req = map.get("sdncAssignRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncAssignRollbackReq") + + assertTrue(req.indexOf("assign= 0) + assertTrue(req.indexOf("CreateBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("unassign= 0) + assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCAssign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCAssign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) + } + + + // ***** preProcessSDNCCreate ***** + + @Test +// @Ignore + public void preProcessSDNCCreate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) + + def req = map.get("sdncCreateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncCreateRollbackReq") + + assertTrue(req.indexOf("create= 0) + assertTrue(req.indexOf("CreateBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("delete= 0) + assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCCreate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCCreate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) + } + + + // ***** preProcessSDNCActivate ***** + + @Test +// @Ignore + public void preProcessSDNCActivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) + + def req = map.get("sdncActivateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncActivateRollbackReq") + + assertTrue(req.indexOf("activate= 0) + assertTrue(req.indexOf("CreateBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("deactivate= 0) + assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCActivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCActivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable("rollbackData") + + assertEquals(data, map.get("rollbackData")) + + assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) + + } + + @Test +// @Ignore + public void validateSDNCResp_Get() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + + verify(mex, never()).getVariable("rollbackData") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + // unsuccessful + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + + // ***** preProcessSDNCGet ***** + + @Test +// @Ignore + public void preProcessSDNCGet_FoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("arlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCGet_NotFoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenReturn(false) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("assignlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCGet_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test + @Ignore + public void updateAaiAROrchStatus() { + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") + } + + + // ***** generateOutputs ***** + + @Test +// @Ignore + public void generateOutputs() { + ExecutionEntity mex = setupMock() + def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml") + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.generateOutputs(mex) + + verify(mex).setVariable("allotedResourceName", "namefromrequest") + + } + + @Test +// @Ignore + public void generateOutputs_BadXml() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.generateOutputs(mex) + + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test +// @Ignore + public void generateOutputs_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test +// @Ignore + public void generateOutputs_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + + // ***** preProcessRollback ***** + + @Test +// @Ignore + public void preProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRollback(mex) + + verify(mex).setVariable("prevWorkflowException", wfe) + + } + + @Test +// @Ignore + public void preProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRollback(mex) + +// verify(mex, never()).setVariable("prevWorkflowException", any()) + + } + + @Test +// @Ignore + public void preProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.preProcessRollback(mex) + + } + + @Test +// @Ignore + public void preProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.preProcessRollback(mex) + + } + + + // ***** postProcessRollback ***** + + @Test +// @Ignore + public void postProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.postProcessRollback(mex) + + verify(mex).setVariable("WorkflowException", wfe) + verify(mex).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.postProcessRollback(mex) + +// verify(mex, never()).setVariable("WorkflowException", any()) + verify(mex).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) })) + verify(mex, never()).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.postProcessRollback(mex) + verify(mex, never()).setVariable("rollbackData", null) + + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") + when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") + when(mex.getVariable("vni")).thenReturn("myvni") + when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") + when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") + when(mex.getVariable("allottedResourceRole")).thenReturn("arr") + when(mex.getVariable("allottedResourceType")).thenReturn("art") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") + when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initCreateAaiAr(ExecutionEntity mex) { + when(mex.getVariable("disableRollback")).thenReturn(45) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST) + when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") + when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") + when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"modelinvuuid", + "modelUuid":"modeluuid", + "modelCustomizationUuid":"modelcustuuid" + } + """) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") + when(mex.getVariable("globalCustomerId")).thenReturn("gci") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") + when(mex.getVariable("vni")).thenReturn("myvni") + when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"miu", + "modelUuid":"mu", + "modelCustomizationUuid":"mcu", + "modelVersion":"mv", + "modelName":"mn" + } + """) + } + + private RollbackData initPreProcessSDNC(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private initPreProcessSDNCGet(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + when(mex.getVariable("foundActiveAR")).thenReturn(true) + when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") + when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + } + + private RollbackData initValidateSDNCResp(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy new file mode 100644 index 0000000000..66cfdb635d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy @@ -0,0 +1,654 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +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.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource + +import org.onap.so.bpmn.core.RollbackData + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARTXCRB_" + String RbType = "DCARTXC_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceTXCRollbackTest() { + super("DoCreateAllottedResourceTXCRollback") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_RollbackDisabled() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("disableRollback")).thenReturn("true") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + data.put(RbType, "rollbackAAI", "false") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex, never()).setVariable("rollbackAAI", true) + verify(mex, never()).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAssign() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + data.put(RbType, "rollbackSDNCassign", "false") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex, never()).setVariable("rollbackSDNC", true) + verify(mex, never()).setVariable("deactivateSdnc", "myactivate") + verify(mex, never()).setVariable("deleteSdnc", "mycreate") + verify(mex, never()).setVariable("unassignSdnc", "true") + verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex, never()).setVariable("sdncDeleteRequest", "createreq") + verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI_NoAssign() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoRbStructure() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(new RollbackData()) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NullRb() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) })) + } + + @Test + @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_EmptyResponse() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + wireMockRule + .stubFor(get(urlMatching("/aai/v[0-9]+/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") })) + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_NoArPath() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + when(mex.getVariable("aaiARPath")).thenReturn(null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError404() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test + @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void postProcessRequest() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_RolledBack() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenReturn(true) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void processRollbackException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackException(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") + verify(mex).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") + verify(mex, never()).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) + } + + private RollbackData initPreProcess(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + when(mex.getVariable("rollbackAAI")).thenReturn(true) + when(mex.getVariable("rollbackSDNC")).thenReturn(true) + when(mex.getVariable("disableRollback")).thenReturn("false") + + data.put("SERVICEINSTANCE", "allottedResourceId", "myid") + + data.put(RbType, "serviceInstanceId", "sii") + data.put(RbType, "parentServiceInstanceId", "psii") + + data.put(RbType, "rollbackAAI", "true") + data.put(RbType, "aaiARPath", "mypath") + + data.put(RbType, "rollbackSDNCassign", "true") + data.put(RbType, "rollbackSDNCactivate", "myactivate") + data.put(RbType, "rollbackSDNCcreate", "mycreate") + data.put(RbType, "sdncActivateRollbackReq", "activatereq") + data.put(RbType, "sdncCreateRollbackReq", "createreq") + data.put(RbType, "sdncAssignRollbackReq", "assignreq") + + return data + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + } + + private initPostProcessRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("skipRollback")).thenReturn(false) + } + + private initProcessRollbackException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initProcessRollbackJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy new file mode 100644 index 0000000000..fa40c17e63 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy @@ -0,0 +1,957 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean +import org.springframework.core.io.ClassPathResource +import org.springframework.core.io.FileSystemResource +import org.springframework.core.io.Resource + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 + +import java.util.Map + +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceTXCTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARTXC_" + + @BeforeClass + public static void setUpBeforeClass() { + aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceTXCTest() { + super("DoCreateAllottedResourceTXC") + } + + + // ***** preProcessRequest ***** + + @Test + // @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + + assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) + assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) + assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) + assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) + assertTrue(checkMissingPreProcessRequest("allottedResourceType")) + } + + + // ***** getAaiAR ***** + + @Test + @Ignore + public void getAaiAR() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.getAaiAR(mex) + + verify(mex).setVariable("foundActiveAR", true) + } + + @Test + // @Ignore + public void getAaiAR_Duplicate() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + // fail if duplicate + when(mex.getVariable("failExists")).thenReturn("true") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) })) + } + + @Test + // @Ignore + public void getAaiAR_NotActive() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + // not active + when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) })) + } + + @Test + @Ignore + public void getAaiAR_NoStatus() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.getAaiAR(mex) + + verify(mex, never()).setVariable("foundActiveAR", true) + } + + + // ***** createAaiAR ***** + + @Test + @Ignore + public void createAaiAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.createAaiAR(mex) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals("45", data.get(Prefix, "disableRollback")) + assertEquals("true", data.get(Prefix, "rollbackAAI")) + assertEquals(ARID, data.get(Prefix, "allottedResourceId")) + assertEquals("sii", data.get(Prefix, "serviceInstanceId")) + assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) + assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath")) + } + + @Test + @Ignore + public void createAaiAR_NoArid_NoModelUuids() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + // no allottedResourceId - will be generated + + when(mex.getVariable("allottedResourceId")).thenReturn(null) + + wireMockRule + .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.createAaiAR(mex) + + def arid = map.get("allottedResourceId") + assertNotNull(arid) + assertFalse(arid.isEmpty()) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals(arid, data.get(Prefix, "allottedResourceId")) + } + + @Test + // @Ignore + public void createAaiAR_MissingPsiLink() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("PSI_resourceLink")).thenReturn(null) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + @Test + // @Ignore + public void createAaiAR_HttpFailed() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + MockPutAllottedResource_500(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + @Test + // @Ignore + public void createAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception")) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + @Test + // @Ignore + public void createAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception")) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + + // ***** buildSDNCRequest ***** + + @Test + // @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + String result = DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("sst= 0) + assertTrue(result.indexOf("gci= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test + // @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCAssign ***** + + @Test + // @Ignore + public void preProcessSDNCAssign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) + + def req = map.get("sdncAssignRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncAssignRollbackReq") + + assertTrue(req.indexOf("assign= 0) + assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("unassign= 0) + assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + } + + @Test + // @Ignore + public void preProcessSDNCAssign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) })) + } + + @Test + // @Ignore + public void preProcessSDNCAssign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) })) + } + + + // ***** preProcessSDNCCreate ***** + + @Test + // @Ignore + public void preProcessSDNCCreate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) + + def req = map.get("sdncCreateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncCreateRollbackReq") + + assertTrue(req.indexOf("create= 0) + assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("delete= 0) + assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test + // @Ignore + public void preProcessSDNCCreate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) })) + } + + @Test + // @Ignore + public void preProcessSDNCCreate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) })) + } + + + // ***** preProcessSDNCActivate ***** + + @Test + // @Ignore + public void preProcessSDNCActivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) + + def req = map.get("sdncActivateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncActivateRollbackReq") + + assertTrue(req.indexOf("activate= 0) + assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("deactivate= 0) + assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test + // @Ignore + public void preProcessSDNCActivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) })) + } + + @Test + // @Ignore + public void preProcessSDNCActivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test + // @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable("rollbackData") + + assertEquals(data, map.get("rollbackData")) + + assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) + + } + + @Test + // @Ignore + public void validateSDNCResp_Get() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "get") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + + verify(mex, never()).getVariable("rollbackData") + } + + @Test + // @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + // unsuccessful + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test + // @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test + // @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + + // ***** preProcessSDNCGet ***** + + @Test + // @Ignore + public void preProcessSDNCGet_FoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("arlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test + // @Ignore + public void preProcessSDNCGet_NotFoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenReturn(false) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("assignlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test + // @Ignore + public void preProcessSDNCGet_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test + @Ignore + public void updateAaiAROrchStatus() { + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.updateAaiAROrchStatus(mex, "success") + } + + + // ***** generateOutputs ***** + + @Test + // @Ignore + public void generateOutputs() { + ExecutionEntity mex = setupMock() + def txctop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml") + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(txctop) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.generateOutputs(mex) + + verify(mex).setVariable("allotedResourceName", "namefromrequest") + verify(mex).setVariable("vni", "my-vni") + verify(mex).setVariable("vgmuxBearerIP", "my-bearer-ip") + verify(mex).setVariable("vgmuxLanIP", "my-lan-ip") + + } + + @Test + // @Ignore + public void generateOutputs_BadXml() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.generateOutputs(mex) + + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test + // @Ignore + public void generateOutputs_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test + // @Ignore + public void generateOutputs_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + + // ***** preProcessRollback ***** + + @Test + // @Ignore + public void preProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRollback(mex) + + verify(mex).setVariable("prevWorkflowException", wfe) + + } + + @Test + // @Ignore + public void preProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRollback(mex) + +// verify(mex, never()).setVariable("prevWorkflowException", any()) + + } + + @Test + // @Ignore + public void preProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.preProcessRollback(mex) + + } + + @Test + // @Ignore + public void preProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.preProcessRollback(mex) + + } + + + // ***** postProcessRollback ***** + + @Test + // @Ignore + public void postProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.postProcessRollback(mex) + + verify(mex).setVariable("WorkflowException", wfe) + verify(mex).setVariable("rollbackData", null) + + } + + @Test + // @Ignore + public void postProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.postProcessRollback(mex) + +// verify(mex, never()).setVariable("WorkflowException", any()) + verify(mex).setVariable("rollbackData", null) + + } + + @Test + // @Ignore + public void postProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.postProcessRollback(mex) })) + verify(mex, never()).setVariable("rollbackData", null) + + } + + @Test + // @Ignore + public void postProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.postProcessRollback(mex) + verify(mex, never()).setVariable("rollbackData", null) + + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoCreateAllottedResourceTXC.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") + when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") + when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") + when(mex.getVariable("allottedResourceRole")).thenReturn("arr") + when(mex.getVariable("allottedResourceType")).thenReturn("art") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") + when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml")) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initCreateAaiAr(ExecutionEntity mex) { + when(mex.getVariable("disableRollback")).thenReturn(45) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST) + when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") + when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") + when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"modelinvuuid", + "modelUuid":"modeluuid", + "modelCustomizationUuid":"modelcustuuid" + } + """) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") + when(mex.getVariable("globalCustomerId")).thenReturn("gci") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + private RollbackData initPreProcessSDNC(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private initPreProcessSDNCGet(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + when(mex.getVariable("foundActiveAR")).thenReturn(true) + when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") + when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + } + + private RollbackData initValidateSDNCResp(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy new file mode 100644 index 0000000000..e8004d3d2b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy @@ -0,0 +1,606 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +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.patch +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById + +import java.util.Map + +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DDARBRG_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoDeleteAllottedResourceBRGTest() { + super("DoDeleteAllottedResourceBRG") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("sdncCallbackUrl", "sdncurn") + + assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceId")) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })) + } + + + // ***** getAaiAR ***** + + @Test + @Ignore + public void getAaiAR() { + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml") + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.getAaiAR(mex) + + verify(mex).setVariable("parentServiceInstanceId", INST) + } + + @Test +// @Ignore + public void getAaiAR_EmptyResponse() { + + // note: empty result-link + wireMockRule + .stubFor(get(urlMatching("/aai/.*/search/.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(""))) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.getAaiAR(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test + @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + String result = DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("sst= 0) + assertTrue(result.indexOf("gci= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCUnassign ***** + + @Test +// @Ignore + public void preProcessSDNCUnassign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) + + def req = map.get("sdncUnassignRequest") + + assertTrue(req.indexOf("unassign= 0) + assertTrue(req.indexOf("DeleteBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) })) + } + + + // ***** preProcessSDNCDelete ***** + + @Test +// @Ignore + public void preProcessSDNCDelete() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) + + def req = map.get("sdncDeleteRequest") + + assertTrue(req.indexOf("delete= 0) + assertTrue(req.indexOf("DeleteBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) })) + } + + + // ***** preProcessSDNCDeactivate ***** + + @Test +// @Ignore + public void preProcessSDNCDeactivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) + + def req = map.get("sdncDeactivateRequest") + + assertTrue(req.indexOf("deactivate= 0) + assertTrue(req.indexOf("DeleteBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable(Prefix+"sdncResponseSuccess") + + verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode") + verify(mex, never()).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate_FailNotFound() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + when(mex.getVariable("failNotFound")).thenReturn("true") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate") + + verify(mex).setVariable("ARNotFoundInSDNC", true) + verify(mex).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test + @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("BRG") + when(mex.getVariable("allottedResourceRole")).thenReturn("BRG") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceBRG/getAR.xml")) + when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version")) + when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") + when(mex.getVariable("globalCustomerId")).thenReturn("gci") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + private initPreProcessSDNC(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp(int code) { + return "<response-code>${code}</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy new file mode 100644 index 0000000000..6719be17a1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy @@ -0,0 +1,607 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil + +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.patch +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById + + +import java.util.Map + +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoDeleteAllottedResourceTXCTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DDARTXC_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoDeleteAllottedResourceTXCTest() { + super("DoDeleteAllottedResourceTXC") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessRequest(mex) + + //verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("sdncCallbackUrl", "sdncurn") + + assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceId")) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })) + } + + + // ***** getAaiAR ***** + + @Test + @Ignore + public void getAaiAR() { + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml") + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.getAaiAR(mex) + + verify(mex).setVariable("parentServiceInstanceId", INST) + } + + @Test +// @Ignore + public void getAaiAR_EmptyResponse() { + + // note: empty result-link + wireMockRule + .stubFor(get(urlMatching("/aai/.*/search/.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(""))) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.getAaiAR(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test + @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.updateAaiAROrchStatus(mex, "success") + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + String result = DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("sst= 0) + assertTrue(result.indexOf("gci= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCUnassign ***** + + @Test +// @Ignore + public void preProcessSDNCUnassign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) + + def req = map.get("sdncUnassignRequest") + + assertTrue(req.indexOf("unassign= 0) + assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) })) + } + + + // ***** preProcessSDNCDelete ***** + + @Test +// @Ignore + public void preProcessSDNCDelete() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) + + def req = map.get("sdncDeleteRequest") + + assertTrue(req.indexOf("delete= 0) + assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) })) + } + + + // ***** preProcessSDNCDeactivate ***** + + @Test +// @Ignore + public void preProcessSDNCDeactivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) + + def req = map.get("sdncDeactivateRequest") + + assertTrue(req.indexOf("deactivate= 0) + assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable(Prefix+"sdncResponseSuccess") + + verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode") + verify(mex, never()).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate_FailNotFound() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + when(mex.getVariable("failNotFound")).thenReturn("true") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate") + + verify(mex).setVariable("ARNotFoundInSDNC", true) + verify(mex).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test + @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("TXC") + when(mex.getVariable("allottedResourceRole")).thenReturn("TXC") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceTXC/getAR.xml")) + when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version")) + when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")) + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") + when(mex.getVariable("globalCustomerId")).thenReturn("gci") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + private initPreProcessSDNC(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp(int code) { + return "<response-code>${code}</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") + when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy new file mode 100644 index 0000000000..764e6244d4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy @@ -0,0 +1,124 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.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.delegate.DelegateExecution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean +import org.springframework.core.io.ClassPathResource +import org.springframework.core.io.Resource + +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.patch +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.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class GroovyTestBase { + + static final int PORT = 28090 + static final String LOCAL_URI = "http://localhost:" + PORT + + static final String CUST = "SDN-ETHERNET-INTERNET" + static final String SVC = "123456789" + static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET" + static final String ARID = "arId-1" + static final String VERS = "myvers" + + static final String DBGFLAG = "isDebugLogEnabled" + + static String aaiUriPfx + + String processName + + public static void setUpBeforeClass() { + aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint") + } + + public GroovyTestBase(String processName) { + this.processName = processName + } + + public boolean doBpmnError(def func) { + + try { + func() + return false; + + } catch(BpmnError e) { + return true; + } + } + + public ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn(processName) + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName) + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mex = mock(ExecutionEntity.class) + + when(mex.getId()).thenReturn("100") + when(mex.getProcessDefinitionId()).thenReturn(processName) + when(mex.getProcessInstanceId()).thenReturn(processName) + when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + when(mex.getVariable("isAsyncProcess")).thenReturn("true") + when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false") + + return mex + } + + public Map setupMap(ExecutionEntity mex) { + MapSetter mapset = new MapSetter(); + doAnswer(mapset).when(mex).setVariable(any(), any()) + return mapset.getMap(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy new file mode 100644 index 0000000000..fa5dcec4bc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import java.util.HashMap; +import java.util.Map; + +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +class MapGetter implements Answer { + final Map map; + + public MapGetter() { + map = new HashMap<>(); + } + + public MapGetter(Map map) { + this.map = map; + } + + public Map getMap() { + return map; + } + + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + return map.get(invocation.getArgumentAt(0, String.class)); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy new file mode 100644 index 0000000000..7b50c616ea --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.vcpe.scripts; + +import java.util.HashMap; +import java.util.Map; + +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +class MapSetter implements Answer { + final Map map; + + public MapSetter() { + map = new HashMap<>(); + } + + public MapSetter(Map map) { + this.map = map; + } + + public Map getMap() { + return map; + } + + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + map.put(invocation.getArgumentAt(0, String.class), invocation.getArgumentAt(1, Object.class)); + return null; + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/CreateSiSample.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/CreateSiSample.json new file mode 100644 index 0000000000..c824213423 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/CreateSiSample.json @@ -0,0 +1,72 @@ +{ + "variables": { + "bpmnRequest": { + "value": "{\n \"requestDetails\": {\n \"cloudConfiguration\": {\n \"lcpCloudRegionId\": \"mtn6\", \n \"tenantId\": \"0422ffb57ba042c0800a29dc85ca70f8\"\n }, \n \"modelInfo\": {\n \"modelInvariantUuid\": \"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f\", \n \"modelName\": \"MSO Test Network\", \n \"modelType\": \"service\", \n \"modelUuid\": \"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e\", \n \"modelVersion\": \"1.0\"\n }, \n \"owningEntity\": {\n \"owningEntityId\": \"123459af-0427-42c2-9d15-971b99b12345\", \n \"owningEntityName\": \"vSAMP10a Entity-200\"\n }, \n \"project\": {\n \"projectName\": \"vSAMP10a Project-3\"\n }, \n \"requestInfo\": {\n \"instanceName\": \"MSO-DEV-SI-1802-v6-2-19-10\", \n \"requestorId\": \"xxxxxx\", \n \"source\": \"VID\", \n \"suppressRollback\": false\n }, \n \"requestParameters\": {\n \"aLaCarte\": true, \n \"subscriptionServiceType\": \"MSO-dev-service-type\", \n \"userParams\": [\n {\n \"name\": \"someUserParam\", \n \"value\": \"someValue\"\n }\n ]\n }, \n \"subscriberInfo\": {\n \"globalSubscriberId\": \"MSO_1610_dev\", \n \"subscriberName\": \"MSO_1610_dev\"\n }\n }\n}\n", + "type": "String" + }, + "requestId": { + "value": "6dd20050-76ee-418f-a153-50720a8f3286", + "type": "String" + }, + "mso-request-id": { + "value": "6dd20050-76ee-418f-a153-50720a8f3286", + "type": "String" + }, + "isBaseVfModule": { + "value": false, + "type": "Boolean" + }, + "recipeTimeout": { + "value": 180, + "type": "Integer" + }, + "requestAction": { + "value": "createInstance", + "type": "String" + }, + "serviceInstanceId": { + "value": "", + "type": "String" + }, + "vnfId": { + "value": "", + "type": "String" + }, + "vfModuleId": { + "value": "", + "type": "String" + }, + "volumeGroupId": { + "value": "", + "type": "String" + }, + "networkId": { + "value": "", + "type": "String" + }, + "configurationId": { + "value": "", + "type": "String" + }, + "serviceType": { + "value": "", + "type": "String" + }, + "vnfType": { + "value": "", + "type": "String" + }, + "vfModuleType": { + "value": "", + "type": "String" + }, + "networkType": { + "value": "", + "type": "String" + }, + "host": { + "value": "localhost", + "type": "String" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn new file mode 100644 index 0000000000..b33aad7443 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn @@ -0,0 +1,54 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_1v2f9n5 + + + + SequenceFlow_1v2f9n5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn new file mode 100644 index 0000000000..807efae1af --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn @@ -0,0 +1,55 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1epm19d + + + SequenceFlow_1 + SequenceFlow_1epm19d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn new file mode 100644 index 0000000000..b2f280d7e9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn @@ -0,0 +1,38 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn new file mode 100644 index 0000000000..532ca867bb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn @@ -0,0 +1,53 @@ + + + + + SequenceFlow_1ipu8um + + + SequenceFlow_1l4c4k0 + + + SequenceFlow_1ipu8um + SequenceFlow_1l4c4k0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn new file mode 100644 index 0000000000..5e4400e9bd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn @@ -0,0 +1,53 @@ + + + + + SequenceFlow_11sp3s9 + + + + SequenceFlow_11sp3s9 + SequenceFlow_0q1lfmf + + + + + SequenceFlow_0q1lfmf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn new file mode 100644 index 0000000000..2867a671b6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn @@ -0,0 +1,53 @@ + + + + + SequenceFlow_1537b7m + + + SequenceFlow_1mz2mgf + + + + SequenceFlow_1537b7m + SequenceFlow_1mz2mgf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn new file mode 100644 index 0000000000..517df36c74 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn @@ -0,0 +1,37 @@ + + + + + SequenceFlow_0qi7pl3 + + + + SequenceFlow_0qi7pl3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn new file mode 100644 index 0000000000..ad4c3c816d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn @@ -0,0 +1,35 @@ + + + + + SequenceFlow_0tyavm9 + + + SequenceFlow_0tyavm9 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_defaultCloudRegionByCloudRegionId.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_defaultCloudRegionByCloudRegionId.json new file mode 100644 index 0000000000..a4190a76ee --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_defaultCloudRegionByCloudRegionId.json @@ -0,0 +1,12 @@ +{ + "cloud-owner": "att-aic", + "cloud-region-id": "mdt1", + "cloud-type": "openstack", + "owner-defined-type": "lcp", + "cloud-region-version": "aic3.0", + "identity-url": "https://localhost:5000/v2.0", + "cloud-zone": "z1", + "complex-name": "c1", + "sriov-automation": false, + "resource-version": "1503072127235" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfGet.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfGet.json new file mode 100644 index 0000000000..921918f267 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfGet.json @@ -0,0 +1,9 @@ +{ + "vnf-id": "msoVnf123", + "vnf-name": "MSO-Test-VNF-123", + "vnf-type": "vnf-type", + "orchestration-status": "active", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1525360206136" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json new file mode 100644 index 0000000000..f0936d6648 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_genericVnfsByVnfId.json @@ -0,0 +1,434 @@ +{ + "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": "192.168.10.14", + "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", + + "relationship-list": {"relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v12/business/customers/customer/e433710f-9217-458d-a79d-1c7aff376d89/service-subscriptions/service-subscription/VIRTUAL%20USP/service-instances/service-instance/2c323333-af4f-4849-af03-c862c0e93e3b", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "e433710f-9217-458d-a79d-1c7aff376d89" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "VIRTUAL USP" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "2c323333-af4f-4849-af03-c862c0e93e3b" + } + ], + "related-to-property": [ { + "property-key": "service-instance.service-instance-name", + "property-value": "kjhgfd1" + }] + }, + { + "related-to": "vserver", + "relationship-label": "tosca.relationships.HostedOn", + "related-link": "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn23a" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "e6beab145f6b49098277ac163ac1b4f3" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5" + } + ], + "related-to-property": [ { + "property-key": "vserver.vserver-name", + "property-value": "comx5000vm003" + }] + }, + { + "related-to": "vserver", + "relationship-label": "tosca.relationships.HostedOn", + "related-link": "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/14551849-1e70-45cd-bc5d-a256d49548a2", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn23a" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "e6beab145f6b49098277ac163ac1b4f3" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "14551849-1e70-45cd-bc5d-a256d49548a2" + } + ], + "related-to-property": [ { + "property-key": "vserver.vserver-name", + "property-value": "comx5000vm002" + }] + }, + { + "related-to": "vserver", + "relationship-label": "tosca.relationships.HostedOn", + "related-link": "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/48bd7f11-408f-417c-b834-b41c1b98f7d7", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn23a" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "e6beab145f6b49098277ac163ac1b4f3" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "48bd7f11-408f-417c-b834-b41c1b98f7d7" + } + ], + "related-to-property": [ { + "property-key": "vserver.vserver-name", + "property-value": "comx5000vm001" + }] + } + ]}, + + + "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/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_pserverByVnfId.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_pserverByVnfId.json new file mode 100644 index 0000000000..4b1f69aacf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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": "192.168.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/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_vfModuleByVfModuleId.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_vfModuleByVfModuleId.json new file mode 100644 index 0000000000..d79137b0cd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/AAI_vfModuleByVfModuleId.json @@ -0,0 +1,27 @@ +{ + "vf-module-id": "example-vnf-id-val-90603", + "vf-module-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": "192.168.10.14", + "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" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/mockObject.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/mockObject.json new file mode 100644 index 0000000000..2f97b47dd3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/AAI/mockObject.json @@ -0,0 +1,10 @@ +{ + "id" : "something", + "resource-version" : "1234", + "plural" : { + "singular" : [{ + "id" : "something2", + "resource-version" : "5678" + }] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/APPC/appc_error.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/APPC/appc_error.json new file mode 100644 index 0000000000..e28878d1aa --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/APPC/appc_error.json @@ -0,0 +1,21 @@ +{ + "output": { + "status": { + "code": 200, + "message": "RESULT_MESSAGE" + }, + "common-header": { + "api-ver": "API_VERSION", + "request-id": "ECOMP_REQUEST_ID", + "originator-id": "ECOMP_SYSTEM_ID", + "sub-request-id": "ECOMP_SUBREQUEST_ID", + "timestamp": "2016-08-08T23:09:00.11Z", + "flags": { + "ttl": 1000, + "force": "TRUE", + "mode": "EXCLUSIVE" + } + }, + "locked": "TRUE" + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkRequest.xml new file mode 100644 index 0000000000..34079bd23f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkRequest.xml @@ -0,0 +1,75 @@ + + mtn6 + 0422ffb57ba042c0800a29dc85ca70f8 + 8d35a433-c1db-4d54-a611-6de10aeb76f9 + Dev_Bindings_1802_1311 + CONTRAIL30_BASIC + f1fc12e8-afe4-4716-954d-ed4d21a480ad + CONTRAIL + + tbd + + + + true + false + + 2001:051111 + EXPORT + + + 1000:051113 + IMPORT + + + 1000:051112 + BOTH + + + 1000:051115 + EXPORT + + + 1000:051114 + IMPORT + + default-domain:ECOMP_MSO_DND:MSOPolicyD + default-domain:ECOMP_MSO_DND:MSOPolicyC + + + + + 107.118.41.3 + 107.118.41.45 + + 107.118.41.0/24 + true + 107.118.41.1 + 4 + 9dbb9e7e-fe18-421f-bad6-2305bd282471 + + true + + + + 107.118.42.3 + 107.118.42.45 + + 107.118.42.0/24 + true + 107.118.42.1 + 4 + 1bb4e1d2-d225-47f3-b6fc-2d0b290de1ab + + true + + true + true + false + + 3d35ca0c-2da5-4f60-84d9-3e005de335c0 + f1d1c7da-fc42-4c31-866e-cfe963e55723 + + d4515ea9-2852-4d3a-b424-9d7b6cf69d8e + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkResponse.xml new file mode 100644 index 0000000000..607dd5af92 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/createNetworkResponse.xml @@ -0,0 +1,31 @@ + + d4515ea9-2852-4d3a-b424-9d7b6cf69d8e + true + default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_1311 + 8d35a433-c1db-4d54-a611-6de10aeb76f9 + Dev_Bindings_1802_1311/ecf7e197-72db-452e-9eda-253cb642c9b7 + b6a7820c-4734-4ef2-8a73-a22c824423fa + + mtn6 + f1fc12e8-afe4-4716-954d-ed4d21a480ad + + 3d35ca0c-2da5-4f60-84d9-3e005de335c0 + f1d1c7da-fc42-4c31-866e-cfe963e55723 + + true + Dev_Bindings_1802_1311/ecf7e197-72db-452e-9eda-253cb642c9b7 + CONTRAIL30_BASIC + b6a7820c-4734-4ef2-8a73-a22c824423fa + 0422ffb57ba042c0800a29dc85ca70f8 + + + + 9dbb9e7e-fe18-421f-bad6-2305bd282471 + 27d414c7-1076-4595-aa45-4717ee992cef + + + 1bb4e1d2-d225-47f3-b6fc-2d0b290de1ab + db64710c-fbbc-4dc9-8109-3925b87268fa + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/defaultNetwork.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/defaultNetwork.json new file mode 100644 index 0000000000..dda149a560 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/defaultNetwork.json @@ -0,0 +1,10 @@ +{ + "networkTechnology": "NEUTRON", + "failIfExists": false, + "backout": true, + "networkParams": [], + "msoRequest": {}, + "contrailRequest": false, + "skipAAI": false, + "synchronous": true +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/l3NetworkBbObject.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/l3NetworkBbObject.json new file mode 100644 index 0000000000..d5d234cbf6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/l3NetworkBbObject.json @@ -0,0 +1,226 @@ +{ + "sharedNetwork": false, + "boundToVpn": false, + "externalNetwork": false, + "providerNetwork": false, + "network-id": "TEST_NETWORK_ID", + "cascaded": false, + "cloud-params": null, + "network-name": "TEST_NETWORK_NAME", + "is-bound-to-vpn": false, + "service-id": null, + "network-role-instance": null, + "orchestration-status": "Active", + "heat-stack-id": "Dev_Bindings_1802_020118/06c2445f-1ca1-4ad8-be08-454c4de443bb", + "contrail-network-fqdn": "default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_020118", + "widget-model-id": null, + "widget-model-version": null, + "physical-network-name": null, + "is-provider-network": false, + "is-shared-network": false, + "is-external-network": false, + "self-link": null, + "operational-status": null, + "subnets": { + "subnet": [ + { + "subnet-id": "209f62cf-cf0c-42f8-b13c-f038b92ef108", + "subnet-name": "", + "neutron-subnet-id": "3942ca32-5f5b-4d62-a2e4-b528b7a4318c", + "gateway-address": "192.168.41.1", + "network-start-address": "192.168.41.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.41.3", + "dhcp-end": "192.168.41.45", + "ip-assignment-direction": "", + "resource-version": "1517496965497", + "host-routes": { + "host-route": [ + { + "host-route-id": "400d286b-7e44-4514-b9b3-f70f7360ff32", + "route-prefix": "172.20.1.0/24", + "next-hop": "10.102.200.1", + "next-hop-type": "ip-address", + "resource-version": "1505857300987" + }, + { + "host-route-id": "6f038013-8b15-4eb8-914b-507489fbc8ee", + "route-prefix": "10.102.0.0/16", + "next-hop": "10.102.200.1", + "next-hop-type": "ip-address", + "resource-version": "1505857301151" + }, + { + "host-route-id": "8811c5f8-f1ed-4fa0-a505-e1be60396e28", + "route-prefix": "192.168.2.0/25", + "next-hop": "10.102.200.1", + "resource-version": "1505857301954" + } + ] + } + }, + { + "subnet-id": "971bc608-1aff-47c0-923d-92e43b699f01", + "subnet-name": "", + "neutron-subnet-id": "81a5ff92-7ca4-4756-a493-496479f0d10f", + "gateway-address": "192.168.42.1", + "network-start-address": "192.168.42.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.42.3", + "dhcp-end": "192.168.42.45", + "ip-assignment-direction": "", + "resource-version": "1517496965508" + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/cc88915e-fb95-4b16-9c1e-a0abf40d1e40", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "MSO_1610_dev" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "MSO-dev-service-type" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "cc88915e-fb95-4b16-9c1e-a0abf40d1e40" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "MSO-DEV-SI-1802-v6-2-01-nwk1" + } + ] + }, + { + "related-to": "cloud-region", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + } + ], + "related-to-property": [ + { + "property-key": "cloud-region.owner-defined-type", + "property-value": "LCP" + } + ] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "ECOMP_MSO_DND" + } + ] + }, + { + "related-to": "route-table-reference", + "related-link": "/aai/v11/network/route-table-references/route-table-reference/c87fa27e-ac15-4b3e-b7ef-866682d8ca00", + "relationship-data": [ + { + "relationship-key": "route-table-reference.route-table-reference-id", + "relationship-value": "c87fa27e-ac15-4b3e-b7ef-866682d8ca00" + } + ], + "related-to-property": [ + { + "property-key": "route-table-reference.route-table-reference-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:RTA" + } + ] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/0219d83f-7c4a-48e2-b8fc-9b20459356bc", + "relationship-data": [ + { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "0219d83f-7c4a-48e2-b8fc-9b20459356bc" + } + ], + "related-to-property": [ + { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyD" + } + ] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/e7a3560c-8b29-4611-a404-83af0b31ce64", + "relationship-data": [ + { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "e7a3560c-8b29-4611-a404-83af0b31ce64" + } + ], + "related-to-property": [ + { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyC" + } + ] + }, + { + "related-to": "vpn-binding", + "related-link": "/aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001", + "relationship-data": [ + { + "relationship-key": "vpn-binding.vpn-id", + "relationship-value": "9a7b327d9-287aa00-82c4b0-100001" + } + ], + "related-to-property": [ + { + "property-key": "vpn-binding.vpn-name", + "property-value": "MSO_VPN_TEST" + }, + { + "property-key": "vpn-binding.vpn-type" + } + ] + } + ] + }, + "ctag-assignments": [ + ], + "segmentation-assignments": [ + ], + "model-info-network": null +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/payloadUpdateCreated.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/payloadUpdateCreated.json new file mode 100644 index 0000000000..aa6320801e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/payloadUpdateCreated.json @@ -0,0 +1,216 @@ +{ + "network-id": "0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "network-name": "Dev_Bindings_1802_020118", + "network-type": "CONTRAIL30_BASIC", + "network-role": "GN_EVPN_direct", + "network-technology": "contrail", + "neutron-network-id": "1112b912-0e00-4d6d-9392-014e106399ee", + "is-bound-to-vpn": true, + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "network-role-instance": 0, + "resource-version": "1517496965485", + "orchestration-status": "Active", + "heat-stack-id": "Dev_Bindings_1802_020118/06c2445f-1ca1-4ad8-be08-454c4de443bb", + "contrail-network-fqdn": "default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_020118", + "physical-network-name": "tbd", + "is-provider-network": false, + "is-shared-network": true, + "is-external-network": false, + "subnets": { + "subnet": [ + { + "subnet-id": "209f62cf-cf0c-42f8-b13c-f038b92ef108", + "subnet-name": "", + "neutron-subnet-id": "3942ca32-5f5b-4d62-a2e4-b528b7a4318c", + "gateway-address": "192.168.41.1", + "network-start-address": "192.168.41.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.41.3", + "dhcp-end": "192.168.41.45", + "ip-assignment-direction": "", + "resource-version": "1517496965497", + "host-routes": { + "host-route": [ + { + "host-route-id": "400d286b-7e44-4514-b9b3-f70f7360ff32", + "route-prefix": "172.20.1.0/24", + "next-hop": "10.102.200.1", + "next-hop-type": "ip-address", + "resource-version": "1505857300987" + }, + { + "host-route-id": "6f038013-8b15-4eb8-914b-507489fbc8ee", + "route-prefix": "10.102.0.0/16", + "next-hop": "10.102.200.1", + "next-hop-type": "ip-address", + "resource-version": "1505857301151" + }, + { + "host-route-id": "8811c5f8-f1ed-4fa0-a505-e1be60396e28", + "route-prefix": "192.168.2.0/25", + "next-hop": "10.102.200.1", + "resource-version": "1505857301954" + } + ] + } + }, + { + "subnet-id": "971bc608-1aff-47c0-923d-92e43b699f01", + "subnet-name": "", + "neutron-subnet-id": "81a5ff92-7ca4-4756-a493-496479f0d10f", + "gateway-address": "192.168.42.1", + "network-start-address": "192.168.42.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.42.3", + "dhcp-end": "192.168.42.45", + "ip-assignment-direction": "", + "resource-version": "1517496965508" + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/cc88915e-fb95-4b16-9c1e-a0abf40d1e40", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "MSO_1610_dev" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "MSO-dev-service-type" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "cc88915e-fb95-4b16-9c1e-a0abf40d1e40" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "MSO-DEV-SI-1802-v6-2-01-nwk1" + } + ] + }, + { + "related-to": "cloud-region", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + } + ], + "related-to-property": [ + { + "property-key": "cloud-region.owner-defined-type", + "property-value": "LCP" + } + ] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "ECOMP_MSO_DND" + } + ] + }, + { + "related-to": "route-table-reference", + "related-link": "/aai/v11/network/route-table-references/route-table-reference/c87fa27e-ac15-4b3e-b7ef-866682d8ca00", + "relationship-data": [ + { + "relationship-key": "route-table-reference.route-table-reference-id", + "relationship-value": "c87fa27e-ac15-4b3e-b7ef-866682d8ca00" + } + ], + "related-to-property": [ + { + "property-key": "route-table-reference.route-table-reference-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:RTA" + } + ] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/0219d83f-7c4a-48e2-b8fc-9b20459356bc", + "relationship-data": [ + { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "0219d83f-7c4a-48e2-b8fc-9b20459356bc" + } + ], + "related-to-property": [ + { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyD" + } + ] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/e7a3560c-8b29-4611-a404-83af0b31ce64", + "relationship-data": [ + { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "e7a3560c-8b29-4611-a404-83af0b31ce64" + } + ], + "related-to-property": [ + { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyC" + } + ] + }, + { + "related-to": "vpn-binding", + "related-link": "/aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001", + "relationship-data": [ + { + "relationship-key": "vpn-binding.vpn-id", + "relationship-value": "9a7b327d9-287aa00-82c4b0-100001" + } + ], + "related-to-property": [ + { + "property-key": "vpn-binding.vpn-name", + "property-value": "MSO_VPN_TEST" + }, + { + "property-key": "vpn-binding.vpn-type" + } + ] + } + ] + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion.json new file mode 100644 index 0000000000..5addff2d70 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion.json @@ -0,0 +1,596 @@ +{ + "cloud-owner": "att-aic", + "cloud-region-id": "mtn6", + "cloud-type": "openstack", + "owner-defined-type": "LCP", + "cloud-region-version": "3.0", + "cloud-zone": "AUS1", + "complex-name": "mtn6", + "resource-version": "1485202577", + "relationship-list": {"relationship": [ + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/316fd41a-5943-4028-b537-9eace4a94387", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "316fd41a-5943-4028-b537-9eace4a94387" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1702-125" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c7910b86-8830-4b43-8d93-895f4e71ee8a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c7910b86-8830-4b43-8d93-895f4e71ee8a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_33" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/491508c7-1246-4ebc-a080-98fbe272291a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "491508c7-1246-4ebc-a080-98fbe272291a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_23" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/acaccfdb-2bf9-4ccb-b123-c54e28e8e310", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "acaccfdb-2bf9-4ccb-b123-c54e28e8e310" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-2002" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/8594c6a8-f8ff-43aa-a0b5-952fd60c9f6a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8594c6a8-f8ff-43aa-a0b5-952fd60c9f6a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_45" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/cf82a73f-de7f-4f84-8dfc-16a487c63a36", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "cf82a73f-de7f-4f84-8dfc-16a487c63a36" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-2001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/259062a4-dc9a-43f2-b46d-46f8b31bb661", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "259062a4-dc9a-43f2-b46d-46f8b31bb661" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_29" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/5102bbfc-44f3-4cd3-ae1e-0c9942653aed", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "5102bbfc-44f3-4cd3-ae1e-0c9942653aed" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_30" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/9b6d2ec3-1e58-4927-91a4-0dabe260436e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "9b6d2ec3-1e58-4927-91a4-0dabe260436e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_31" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/268c0582-a5b3-4f9f-8f4f-ea0f93620212", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "268c0582-a5b3-4f9f-8f4f-ea0f93620212" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_23" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/48627fd2-b3f2-4867-9fa3-f6425a7d22f5", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "48627fd2-b3f2-4867-9fa3-f6425a7d22f5" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_10" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fb630eb9-44a3-4a90-a0c9-e52002f9f555", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb630eb9-44a3-4a90-a0c9-e52002f9f555" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_28" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/65cc74dd-bffb-4f71-8db8-0fb6e6ac36ef", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "65cc74dd-bffb-4f71-8db8-0fb6e6ac36ef" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_26" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/29ee3893-b7d0-4420-a035-c990fc32eb1c", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "29ee3893-b7d0-4420-a035-c990fc32eb1c" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_48" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f8fb2eaa-68f7-4a1a-8adb-37ba7b3d891e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f8fb2eaa-68f7-4a1a-8adb-37ba7b3d891e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1702-126" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c1fc2c47-4986-4d42-80c3-379d5252bdb1", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c1fc2c47-4986-4d42-80c3-379d5252bdb1" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_40" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e47d1154-03b4-44a1-8196-6fb947f4d4b3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e47d1154-03b4-44a1-8196-6fb947f4d4b3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_26" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/09e0d15b-e36c-4bf5-8c2b-f4ce9256854f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "09e0d15b-e36c-4bf5-8c2b-f4ce9256854f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/7b86609c-1c79-4329-bf21-15df6db1ffe0", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7b86609c-1c79-4329-bf21-15df6db1ffe0" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c547848e-2617-4161-9154-1aa6cca60994", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c547848e-2617-4161-9154-1aa6cca60994" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/d348293a-2f7b-4925-bf21-fd59c2e52bfa", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d348293a-2f7b-4925-bf21-fd59c2e52bfa" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_32" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/92e7461d-358a-47a3-be5e-669dcf6400ef", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "92e7461d-358a-47a3-be5e-669dcf6400ef" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/01c857bf-c75e-4f1c-886c-f651a8479037", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "01c857bf-c75e-4f1c-886c-f651a8479037" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0509A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4cadeb8b-f258-436d-a998-de887f10d180", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4cadeb8b-f258-436d-a998-de887f10d180" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0511C" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/d9b00452-16c5-441f-9455-2954b93b7be7", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d9b00452-16c5-441f-9455-2954b93b7be7" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512C" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f170b669-031a-47ff-a545-61a5fbfaf884", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f170b669-031a-47ff-a545-61a5fbfaf884" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_1Bindings_324_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fb7ed40a-4c29-464c-a9d7-edc314802cc4", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb7ed40a-4c29-464c-a9d7-edc314802cc4" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f901b9d6-3779-4f0d-a925-cb7e5e84650a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f901b9d6-3779-4f0d-a925-cb7e5e84650a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-155" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e901cbc9-b964-4e8f-a363-12fe30585526", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e901cbc9-b964-4e8f-a363-12fe30585526" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4a5b95a6-4659-406e-bd39-d7909fed055f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4a5b95a6-4659-406e-bd39-d7909fed055f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-1707-ipv6-6001-badMask" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/7883684f-4ee0-460e-a277-0276e79fb8b8", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7883684f-4ee0-460e-a277-0276e79fb8b8" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/da4d0845-1e2f-4d94-a66f-bca45242c12f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "da4d0845-1e2f-4d94-a66f-bca45242c12f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_29" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c06bf62e-7c26-4c12-818f-927c3c25a38a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c06bf62e-7c26-4c12-818f-927c3c25a38a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_2" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/b09885f5-afce-400c-84dc-0a2779fc3e21", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b09885f5-afce-400c-84dc-0a2779fc3e21" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "ST-MTN6-NoBinding-1707-18-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e746082a-41dc-40ec-a06e-d1138004902e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e746082a-41dc-40ec-a06e-d1138004902e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1710-4001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f1c5642c-c7d8-4409-997f-b5b186d8892f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f1c5642c-c7d8-4409-997f-b5b186d8892f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-119" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/51e3b192-31e3-4c3e-89a9-e1f2592e15fc", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "51e3b192-31e3-4c3e-89a9-e1f2592e15fc" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_1311" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fc0ae18f-0a1f-4773-b387-5aed5b58fffb", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fc0ae18f-0a1f-4773-b387-5aed5b58fffb" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_021618" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0384d743-f69b-4cc8-9aa8-c3ae66662c44" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_020118" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/6ee51b6e-2b54-45cf-83f7-8bfa2c4ecaf3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6ee51b6e-2b54-45cf-83f7-8bfa2c4ecaf3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_Dev_HostRoutes-1802-bns-2001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/aaaa-bbbb-cccc-dddd-eeee", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "aaaa-bbbb-cccc-dddd-eeee" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "direct_dhcp_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/800bdc98-4326-4358-980d-e552e2105eaf", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "800bdc98-4326-4358-980d-e552e2105eaf" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512B" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/b11eb5fc-082d-424a-a14c-f356d1ce611d", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b11eb5fc-082d-424a-a14c-f356d1ce611d" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "DEV-1Binding-1710-0814-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4636eea4-86a3-4cd3-806d-a63f29542ba3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4636eea4-86a3-4cd3-806d-a63f29542ba3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "DEV-MTN6-NoBinding-1707-20-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/1111-2222-3333-4444-5555", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "1111-2222-3333-4444-5555" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-25180-L-06Shared_OAM_PROTECTED_NET_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/67743f38-c2ac-4309-b81c-8b05381e5522", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "67743f38-c2ac-4309-b81c-8b05381e5522" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "dev_Bindings_full_1710_0907A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/wwww-xxxx-yyyy-zzzz", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "wwww-xxxx-yyyy-zzzz" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-25180-P-ALPSGA01_oam_direct_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/ed885e04-ffe5-47fb-bb20-103e5e22ef89", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "ed885e04-ffe5-47fb-bb20-103e5e22ef89" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_Dev_HostRoutes-1802-bns-1002" + }] + }, + { + "related-to": "complex", + "related-link": "/aai/v11/cloud-infrastructure/complexes/complex/AUSTTXGR", + "relationship-data": [ { + "relationship-key": "complex.physical-location-id", + "relationship-value": "AUSTTXGR" + }] + } + ]} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion25.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion25.json new file mode 100644 index 0000000000..fadbf9c244 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegion25.json @@ -0,0 +1,596 @@ +{ + "cloud-owner": "att-aic", + "cloud-region-id": "mtn6", + "cloud-type": "openstack", + "owner-defined-type": "LCP", + "cloud-region-version": "2.5", + "cloud-zone": "AUS1", + "complex-name": "mtn6", + "resource-version": "1485202577", + "relationship-list": {"relationship": [ + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/316fd41a-5943-4028-b537-9eace4a94387", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "316fd41a-5943-4028-b537-9eace4a94387" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1702-125" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c7910b86-8830-4b43-8d93-895f4e71ee8a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c7910b86-8830-4b43-8d93-895f4e71ee8a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_33" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/491508c7-1246-4ebc-a080-98fbe272291a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "491508c7-1246-4ebc-a080-98fbe272291a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_23" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/acaccfdb-2bf9-4ccb-b123-c54e28e8e310", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "acaccfdb-2bf9-4ccb-b123-c54e28e8e310" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-2002" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/8594c6a8-f8ff-43aa-a0b5-952fd60c9f6a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8594c6a8-f8ff-43aa-a0b5-952fd60c9f6a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_45" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/cf82a73f-de7f-4f84-8dfc-16a487c63a36", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "cf82a73f-de7f-4f84-8dfc-16a487c63a36" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-2001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/259062a4-dc9a-43f2-b46d-46f8b31bb661", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "259062a4-dc9a-43f2-b46d-46f8b31bb661" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_29" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/5102bbfc-44f3-4cd3-ae1e-0c9942653aed", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "5102bbfc-44f3-4cd3-ae1e-0c9942653aed" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_30" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/9b6d2ec3-1e58-4927-91a4-0dabe260436e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "9b6d2ec3-1e58-4927-91a4-0dabe260436e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_31" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/268c0582-a5b3-4f9f-8f4f-ea0f93620212", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "268c0582-a5b3-4f9f-8f4f-ea0f93620212" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_23" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/48627fd2-b3f2-4867-9fa3-f6425a7d22f5", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "48627fd2-b3f2-4867-9fa3-f6425a7d22f5" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_10" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fb630eb9-44a3-4a90-a0c9-e52002f9f555", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb630eb9-44a3-4a90-a0c9-e52002f9f555" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_28" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/65cc74dd-bffb-4f71-8db8-0fb6e6ac36ef", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "65cc74dd-bffb-4f71-8db8-0fb6e6ac36ef" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_26" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/29ee3893-b7d0-4420-a035-c990fc32eb1c", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "29ee3893-b7d0-4420-a035-c990fc32eb1c" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_48" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f8fb2eaa-68f7-4a1a-8adb-37ba7b3d891e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f8fb2eaa-68f7-4a1a-8adb-37ba7b3d891e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1702-126" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c1fc2c47-4986-4d42-80c3-379d5252bdb1", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c1fc2c47-4986-4d42-80c3-379d5252bdb1" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_40" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e47d1154-03b4-44a1-8196-6fb947f4d4b3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e47d1154-03b4-44a1-8196-6fb947f4d4b3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_26" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/09e0d15b-e36c-4bf5-8c2b-f4ce9256854f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "09e0d15b-e36c-4bf5-8c2b-f4ce9256854f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/7b86609c-1c79-4329-bf21-15df6db1ffe0", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7b86609c-1c79-4329-bf21-15df6db1ffe0" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c547848e-2617-4161-9154-1aa6cca60994", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c547848e-2617-4161-9154-1aa6cca60994" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/d348293a-2f7b-4925-bf21-fd59c2e52bfa", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d348293a-2f7b-4925-bf21-fd59c2e52bfa" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_32" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/92e7461d-358a-47a3-be5e-669dcf6400ef", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "92e7461d-358a-47a3-be5e-669dcf6400ef" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/01c857bf-c75e-4f1c-886c-f651a8479037", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "01c857bf-c75e-4f1c-886c-f651a8479037" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0509A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4cadeb8b-f258-436d-a998-de887f10d180", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4cadeb8b-f258-436d-a998-de887f10d180" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0511C" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/d9b00452-16c5-441f-9455-2954b93b7be7", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d9b00452-16c5-441f-9455-2954b93b7be7" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512C" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f170b669-031a-47ff-a545-61a5fbfaf884", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f170b669-031a-47ff-a545-61a5fbfaf884" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_1Bindings_324_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fb7ed40a-4c29-464c-a9d7-edc314802cc4", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb7ed40a-4c29-464c-a9d7-edc314802cc4" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f901b9d6-3779-4f0d-a925-cb7e5e84650a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f901b9d6-3779-4f0d-a925-cb7e5e84650a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-155" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e901cbc9-b964-4e8f-a363-12fe30585526", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e901cbc9-b964-4e8f-a363-12fe30585526" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4a5b95a6-4659-406e-bd39-d7909fed055f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4a5b95a6-4659-406e-bd39-d7909fed055f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-1707-ipv6-6001-badMask" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/7883684f-4ee0-460e-a277-0276e79fb8b8", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7883684f-4ee0-460e-a277-0276e79fb8b8" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/da4d0845-1e2f-4d94-a66f-bca45242c12f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "da4d0845-1e2f-4d94-a66f-bca45242c12f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_29" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c06bf62e-7c26-4c12-818f-927c3c25a38a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c06bf62e-7c26-4c12-818f-927c3c25a38a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_2" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/b09885f5-afce-400c-84dc-0a2779fc3e21", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b09885f5-afce-400c-84dc-0a2779fc3e21" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "ST-MTN6-NoBinding-1707-18-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e746082a-41dc-40ec-a06e-d1138004902e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e746082a-41dc-40ec-a06e-d1138004902e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1710-4001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f1c5642c-c7d8-4409-997f-b5b186d8892f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f1c5642c-c7d8-4409-997f-b5b186d8892f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-119" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/51e3b192-31e3-4c3e-89a9-e1f2592e15fc", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "51e3b192-31e3-4c3e-89a9-e1f2592e15fc" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_1311" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fc0ae18f-0a1f-4773-b387-5aed5b58fffb", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fc0ae18f-0a1f-4773-b387-5aed5b58fffb" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_021618" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0384d743-f69b-4cc8-9aa8-c3ae66662c44" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_020118" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/6ee51b6e-2b54-45cf-83f7-8bfa2c4ecaf3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6ee51b6e-2b54-45cf-83f7-8bfa2c4ecaf3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_Dev_HostRoutes-1802-bns-2001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/aaaa-bbbb-cccc-dddd-eeee", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "aaaa-bbbb-cccc-dddd-eeee" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "direct_dhcp_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/800bdc98-4326-4358-980d-e552e2105eaf", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "800bdc98-4326-4358-980d-e552e2105eaf" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512B" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/b11eb5fc-082d-424a-a14c-f356d1ce611d", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b11eb5fc-082d-424a-a14c-f356d1ce611d" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "DEV-1Binding-1710-0814-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4636eea4-86a3-4cd3-806d-a63f29542ba3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4636eea4-86a3-4cd3-806d-a63f29542ba3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "DEV-MTN6-NoBinding-1707-20-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/1111-2222-3333-4444-5555", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "1111-2222-3333-4444-5555" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-25180-L-06Shared_OAM_PROTECTED_NET_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/67743f38-c2ac-4309-b81c-8b05381e5522", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "67743f38-c2ac-4309-b81c-8b05381e5522" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "dev_Bindings_full_1710_0907A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/wwww-xxxx-yyyy-zzzz", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "wwww-xxxx-yyyy-zzzz" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-25180-P-ALPSGA01_oam_direct_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/ed885e04-ffe5-47fb-bb20-103e5e22ef89", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "ed885e04-ffe5-47fb-bb20-103e5e22ef89" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_Dev_HostRoutes-1802-bns-1002" + }] + }, + { + "related-to": "complex", + "related-link": "/aai/v11/cloud-infrastructure/complexes/complex/AUSTTXGR", + "relationship-data": [ { + "relationship-key": "complex.physical-location-id", + "relationship-value": "AUSTTXGR" + }] + } + ]} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegionError.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegionError.json new file mode 100644 index 0000000000..97611c1d62 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAICloudRegionError.json @@ -0,0 +1,596 @@ +{ + "cloud-owner": "att-aic", + "cloud-region-id": "ERROR", + "cloud-type": "openstack", + "owner-defined-type": "LCP", + "cloud-region-version": "3.0", + "cloud-zone": "AUS1", + "complex-name": "mtn6", + "resource-version": "1485202577", + "relationship-list": {"relationship": [ + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/316fd41a-5943-4028-b537-9eace4a94387", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "316fd41a-5943-4028-b537-9eace4a94387" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1702-125" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c7910b86-8830-4b43-8d93-895f4e71ee8a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c7910b86-8830-4b43-8d93-895f4e71ee8a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_33" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/491508c7-1246-4ebc-a080-98fbe272291a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "491508c7-1246-4ebc-a080-98fbe272291a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_23" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/acaccfdb-2bf9-4ccb-b123-c54e28e8e310", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "acaccfdb-2bf9-4ccb-b123-c54e28e8e310" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-2002" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/8594c6a8-f8ff-43aa-a0b5-952fd60c9f6a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8594c6a8-f8ff-43aa-a0b5-952fd60c9f6a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_45" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/cf82a73f-de7f-4f84-8dfc-16a487c63a36", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "cf82a73f-de7f-4f84-8dfc-16a487c63a36" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-2001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/259062a4-dc9a-43f2-b46d-46f8b31bb661", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "259062a4-dc9a-43f2-b46d-46f8b31bb661" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_29" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/5102bbfc-44f3-4cd3-ae1e-0c9942653aed", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "5102bbfc-44f3-4cd3-ae1e-0c9942653aed" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_30" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/9b6d2ec3-1e58-4927-91a4-0dabe260436e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "9b6d2ec3-1e58-4927-91a4-0dabe260436e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_31" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/268c0582-a5b3-4f9f-8f4f-ea0f93620212", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "268c0582-a5b3-4f9f-8f4f-ea0f93620212" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_23" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/48627fd2-b3f2-4867-9fa3-f6425a7d22f5", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "48627fd2-b3f2-4867-9fa3-f6425a7d22f5" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_10" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fb630eb9-44a3-4a90-a0c9-e52002f9f555", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb630eb9-44a3-4a90-a0c9-e52002f9f555" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_28" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/65cc74dd-bffb-4f71-8db8-0fb6e6ac36ef", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "65cc74dd-bffb-4f71-8db8-0fb6e6ac36ef" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_26" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/29ee3893-b7d0-4420-a035-c990fc32eb1c", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "29ee3893-b7d0-4420-a035-c990fc32eb1c" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_48" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f8fb2eaa-68f7-4a1a-8adb-37ba7b3d891e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f8fb2eaa-68f7-4a1a-8adb-37ba7b3d891e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1702-126" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c1fc2c47-4986-4d42-80c3-379d5252bdb1", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c1fc2c47-4986-4d42-80c3-379d5252bdb1" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_40" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e47d1154-03b4-44a1-8196-6fb947f4d4b3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e47d1154-03b4-44a1-8196-6fb947f4d4b3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_26" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/09e0d15b-e36c-4bf5-8c2b-f4ce9256854f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "09e0d15b-e36c-4bf5-8c2b-f4ce9256854f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/7b86609c-1c79-4329-bf21-15df6db1ffe0", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7b86609c-1c79-4329-bf21-15df6db1ffe0" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c547848e-2617-4161-9154-1aa6cca60994", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c547848e-2617-4161-9154-1aa6cca60994" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/d348293a-2f7b-4925-bf21-fd59c2e52bfa", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d348293a-2f7b-4925-bf21-fd59c2e52bfa" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_TEST_1702_A_int_HngwProtectedOam.OAM_net_32" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/92e7461d-358a-47a3-be5e-669dcf6400ef", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "92e7461d-358a-47a3-be5e-669dcf6400ef" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "oam-net" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/01c857bf-c75e-4f1c-886c-f651a8479037", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "01c857bf-c75e-4f1c-886c-f651a8479037" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0509A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4cadeb8b-f258-436d-a998-de887f10d180", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4cadeb8b-f258-436d-a998-de887f10d180" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0511C" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/d9b00452-16c5-441f-9455-2954b93b7be7", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d9b00452-16c5-441f-9455-2954b93b7be7" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512C" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f170b669-031a-47ff-a545-61a5fbfaf884", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f170b669-031a-47ff-a545-61a5fbfaf884" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_1Bindings_324_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fb7ed40a-4c29-464c-a9d7-edc314802cc4", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb7ed40a-4c29-464c-a9d7-edc314802cc4" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f901b9d6-3779-4f0d-a925-cb7e5e84650a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f901b9d6-3779-4f0d-a925-cb7e5e84650a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-155" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e901cbc9-b964-4e8f-a363-12fe30585526", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e901cbc9-b964-4e8f-a363-12fe30585526" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4a5b95a6-4659-406e-bd39-d7909fed055f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4a5b95a6-4659-406e-bd39-d7909fed055f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-1707-ipv6-6001-badMask" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/7883684f-4ee0-460e-a277-0276e79fb8b8", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7883684f-4ee0-460e-a277-0276e79fb8b8" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/da4d0845-1e2f-4d94-a66f-bca45242c12f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "da4d0845-1e2f-4d94-a66f-bca45242c12f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_29" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/c06bf62e-7c26-4c12-818f-927c3c25a38a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c06bf62e-7c26-4c12-818f-927c3c25a38a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Mobility_ATM_1707_int_HngwOamNetVto.HNGWOAMNETVTO.OAM_net_2" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/b09885f5-afce-400c-84dc-0a2779fc3e21", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b09885f5-afce-400c-84dc-0a2779fc3e21" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "ST-MTN6-NoBinding-1707-18-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/e746082a-41dc-40ec-a06e-d1138004902e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e746082a-41dc-40ec-a06e-d1138004902e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1710-4001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/f1c5642c-c7d8-4409-997f-b5b186d8892f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f1c5642c-c7d8-4409-997f-b5b186d8892f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-119" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/51e3b192-31e3-4c3e-89a9-e1f2592e15fc", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "51e3b192-31e3-4c3e-89a9-e1f2592e15fc" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_1311" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/fc0ae18f-0a1f-4773-b387-5aed5b58fffb", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fc0ae18f-0a1f-4773-b387-5aed5b58fffb" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_021618" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0384d743-f69b-4cc8-9aa8-c3ae66662c44" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_Bindings_1802_020118" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/6ee51b6e-2b54-45cf-83f7-8bfa2c4ecaf3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6ee51b6e-2b54-45cf-83f7-8bfa2c4ecaf3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_Dev_HostRoutes-1802-bns-2001" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/aaaa-bbbb-cccc-dddd-eeee", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "aaaa-bbbb-cccc-dddd-eeee" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "direct_dhcp_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/800bdc98-4326-4358-980d-e552e2105eaf", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "800bdc98-4326-4358-980d-e552e2105eaf" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "Dev_NoBinding-1707-0512B" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/b11eb5fc-082d-424a-a14c-f356d1ce611d", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b11eb5fc-082d-424a-a14c-f356d1ce611d" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "DEV-1Binding-1710-0814-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/4636eea4-86a3-4cd3-806d-a63f29542ba3", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4636eea4-86a3-4cd3-806d-a63f29542ba3" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "DEV-MTN6-NoBinding-1707-20-1000A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/1111-2222-3333-4444-5555", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "1111-2222-3333-4444-5555" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-25180-L-06Shared_OAM_PROTECTED_NET_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/67743f38-c2ac-4309-b81c-8b05381e5522", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "67743f38-c2ac-4309-b81c-8b05381e5522" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "dev_Bindings_full_1710_0907A" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/wwww-xxxx-yyyy-zzzz", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "wwww-xxxx-yyyy-zzzz" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-25180-P-ALPSGA01_oam_direct_net_1" + }] + }, + { + "related-to": "l3-network", + "related-link": "/aai/v11/network/l3-networks/l3-network/ed885e04-ffe5-47fb-bb20-103e5e22ef89", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "ed885e04-ffe5-47fb-bb20-103e5e22ef89" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MSO_Dev_HostRoutes-1802-bns-1002" + }] + }, + { + "related-to": "complex", + "related-link": "/aai/v11/cloud-infrastructure/complexes/complex/AUSTTXGR", + "relationship-data": [ { + "relationship-key": "complex.physical-location-id", + "relationship-value": "AUSTTXGR" + }] + } + ]} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json new file mode 100644 index 0000000000..181494dff2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json @@ -0,0 +1,141 @@ +{ + "network-id": "467e3349-bec1-4922-bcb1-d0bb041bce30", + "network-name": "vprobes_pktinternal_net_4_1806", + "network-type": "CONTRAIL30_BASIC", + "network-role": "NetworkPktinternalInt2.pktinternal_int", + "network-technology": "", + "is-bound-to-vpn": false, + "service-id": "eb68dedb-840d-4bd4-a745-d9fcd8fc8468", + "network-role-instance": 0, + "resource-version": "1527285069624", + "orchestration-status": "Assigned", + "physical-network-name": "tbd", + "is-provider-network": false, + "is-shared-network": false, + "is-external-network": false, + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/eb68dedb-840d-4bd4-a745-d9fcd8fc8468/service-data/networks/network/467e3349-bec1-4922-bcb1-d0bb041bce30/network-data/network-topology/", + "subnets": { + "subnet": [ + { + "subnet-id": "46aee427-3aa0-4c1f-beb6-edf6caae2dc1", + "subnet-name": "vprobes_pktinternal_net_4_1806_subnet_1", + "gateway-address": "192.168.224.1", + "network-start-address": "192.168.224.0", + "cidr-mask": "21", + "ip-version": "4", + "orchestration-status": "PendingCreate", + "dhcp-enabled": false, + "dhcp-start": "192.168.224.3", + "dhcp-end": "192.168.224.5", + "subnet-role": "DHCP", + "ip-assignment-direction": "true", + "resource-version": "1527285068387", + "host-routes": { + "host-route": [ + { + "host-route-id": "1de02743-580a-4f99-8285-3ba6eadb0892", + "route-prefix": "", + "next-hop": "", + "resource-version": "1527285059650" + } + ] + } + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Mobility/service-instances/service-instance/eb68dedb-840d-4bd4-a745-d9fcd8fc8468", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "Mobility" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "eb68dedb-840d-4bd4-a745-d9fcd8fc8468" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eb68dedb-840d-4bd4-a745-d9fcd8fc8468" + } + ] + }, + { + "related-to": "cloud-region", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/DYH1A", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "DYH1A" + } + ], + "related-to-property": [ + { + "property-key": "cloud-region.owner-defined-type", + "property-value": "lcp" + } + ] + }, + { + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/att-aic/DYH1A/tenants/tenant/2871503957144f72b3cf481b379828ec", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "DYH1A" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "2871503957144f72b3cf481b379828ec" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "APP-C-24595-T-IST-04A" + } + ] + }, + { + "related-to": "vpn-binding", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/vpn-bindings/vpn-binding/13e94b71-3ce1-4988-ab0e-61208fc91f1c", + "relationship-data": [ + { + "relationship-key": "vpn-binding.vpn-id", + "relationship-value": "13e94b71-3ce1-4988-ab0e-61208fc91f1c" + } + ], + "related-to-property": [ + { + "property-key": "vpn-binding.vpn-name", + "property-value": "vMDNS" + }, + { + "property-key": "vpn-binding.vpn-type" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponse.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponse.json new file mode 100644 index 0000000000..b22f389c40 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponse.json @@ -0,0 +1,166 @@ +{ + "network-id": "0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "network-name": "Dev_Bindings_1802_020118", + "network-type": "CONTRAIL30_BASIC", + "network-role": "GN_EVPN_direct", + "network-technology": "contrail", + "neutron-network-id": "1112b912-0e00-4d6d-9392-014e106399ee", + "is-bound-to-vpn": true, + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "network-role-instance": 0, + "resource-version": "1517496965485", + "orchestration-status": "Active", + "heat-stack-id": "Dev_Bindings_1802_020118/06c2445f-1ca1-4ad8-be08-454c4de443bb", + "contrail-network-fqdn": "default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_020118", + "physical-network-name": "tbd", + "is-provider-network": false, + "is-shared-network": true, + "is-external-network": false, + "subnets": {"subnet": [ + { + "subnet-id": "209f62cf-cf0c-42f8-b13c-f038b92ef108", + "subnet-name": "", + "neutron-subnet-id": "3942ca32-5f5b-4d62-a2e4-b528b7a4318c", + "gateway-address": "192.168.41.1", + "network-start-address": "192.168.41.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.41.3", + "dhcp-end": "192.168.41.45", + "ip-assignment-direction": "", + "resource-version": "1517496965497" + }, + { + "subnet-id": "971bc608-1aff-47c0-923d-92e43b699f01", + "subnet-name": "", + "neutron-subnet-id": "81a5ff92-7ca4-4756-a493-496479f0d10f", + "gateway-address": "192.168.42.1", + "network-start-address": "192.168.42.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.42.3", + "dhcp-end": "192.168.42.45", + "ip-assignment-direction": "", + "resource-version": "1517496965508" + } + ]}, + "relationship-list": {"relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/cc88915e-fb95-4b16-9c1e-a0abf40d1e40", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "MSO_1610_dev" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "MSO-dev-service-type" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "cc88915e-fb95-4b16-9c1e-a0abf40d1e40" + } + ], + "related-to-property": [ { + "property-key": "service-instance.service-instance-name", + "property-value": "MSO-DEV-SI-1802-v6-2-01-nwk1" + }] + }, + { + "related-to": "cloud-region", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + } + ], + "related-to-property": [ { + "property-key": "cloud-region.owner-defined-type", + "property-value": "LCP" + }] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "0422ffb57ba042c0800a29dc85ca70f8" + } + ], + "related-to-property": [ { + "property-key": "tenant.tenant-name", + "property-value": "ECOMP_MSO_DND" + }] + }, + { + "related-to": "route-table-reference", + "related-link": "/aai/v11/network/route-table-references/route-table-reference/c87fa27e-ac15-4b3e-b7ef-866682d8ca00", + "relationship-data": [ { + "relationship-key": "route-table-reference.route-table-reference-id", + "relationship-value": "c87fa27e-ac15-4b3e-b7ef-866682d8ca00" + }], + "related-to-property": [ { + "property-key": "route-table-reference.route-table-reference-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:RTA" + }] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/0219d83f-7c4a-48e2-b8fc-9b20459356bc", + "relationship-data": [ { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "0219d83f-7c4a-48e2-b8fc-9b20459356bc" + }], + "related-to-property": [ { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyD" + }] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/e7a3560c-8b29-4611-a404-83af0b31ce64", + "relationship-data": [ { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "e7a3560c-8b29-4611-a404-83af0b31ce64" + }], + "related-to-property": [ { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyC" + }] + }, + { + "related-to": "vpn-binding", + "related-link": "/aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001", + "relationship-data": [ { + "relationship-key": "vpn-binding.vpn-id", + "relationship-value": "9a7b327d9-287aa00-82c4b0-100001" + }], + "related-to-property": [ + { + "property-key": "vpn-binding.vpn-name", + "property-value": "MSO_VPN_TEST" + }, + {"property-key": "vpn-binding.vpn-type"} + ] + } + ]} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponseEmptyUri.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponseEmptyUri.json new file mode 100644 index 0000000000..c581e54ef0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIResponseEmptyUri.json @@ -0,0 +1,53 @@ +{ + "network-id": "0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "network-name": "Dev_Bindings_1802_020118", + "network-type": "CONTRAIL30_BASIC", + "network-role": "GN_EVPN_direct", + "network-technology": "contrail", + "neutron-network-id": "1112b912-0e00-4d6d-9392-014e106399ee", + "is-bound-to-vpn": true, + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "network-role-instance": 0, + "resource-version": "1517496965485", + "orchestration-status": "Active", + "heat-stack-id": "Dev_Bindings_1802_020118/06c2445f-1ca1-4ad8-be08-454c4de443bb", + "contrail-network-fqdn": "default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_020118", + "physical-network-name": "tbd", + "is-provider-network": false, + "is-shared-network": true, + "is-external-network": false, + "subnets": {"subnet": [ + { + "subnet-id": "209f62cf-cf0c-42f8-b13c-f038b92ef108", + "subnet-name": "", + "neutron-subnet-id": "3942ca32-5f5b-4d62-a2e4-b528b7a4318c", + "gateway-address": "192.168.41.1", + "network-start-address": "192.168.41.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.41.3", + "dhcp-end": "192.168.41.45", + "ip-assignment-direction": "", + "resource-version": "1517496965497" + }, + { + "subnet-id": "971bc608-1aff-47c0-923d-92e43b699f01", + "subnet-name": "", + "neutron-subnet-id": "81a5ff92-7ca4-4756-a493-496479f0d10f", + "gateway-address": "192.168.42.1", + "network-start-address": "192.168.42.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.42.3", + "dhcp-end": "192.168.42.45", + "ip-assignment-direction": "", + "resource-version": "1517496965508" + } + ]}, + "relationship-list": {"relationship": [] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIVpnBindingTestResponse.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIVpnBindingTestResponse.json new file mode 100644 index 0000000000..5d9231d4c6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryAAIVpnBindingTestResponse.json @@ -0,0 +1,891 @@ +{ + "vpn-id": "13e94b71-3ce1-4988-ab0e-61208fc91f1c", + "vpn-name": "vMDNS", + "resource-version": "1510956324462", + "relationship-list": {"relationship": [ + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/b3376949-5487-4a74-9029-332c07720c07", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "b3376949-5487-4a74-9029-332c07720c07" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vEPDG-FN-26642-T-01_hsl_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/d0b8ecd3-aee4-48ba-8bc5-222d3fb08162", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d0b8ecd3-aee4-48ba-8bc5-222d3fb08162" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_Shared_oam_protected_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/34305bd0-ad54-4349-8567-6f65ea09e750", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "34305bd0-ad54-4349-8567-6f65ea09e750" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_vEPDG-FN_swu_direct_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/dfa4972a-ed82-43cd-98be-ed73bb3406a9", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "dfa4972a-ed82-43cd-98be-ed73bb3406a9" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_Shared_EXN_INTERNET_NET_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/93556256-aa23-449d-a2fd-3a9c034f232a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "93556256-aa23-449d-a2fd-3a9c034f232a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_CORE-NSD-TOAM0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/7ce01c3a-5998-4908-85f6-ab29bc507a92", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7ce01c3a-5998-4908-85f6-ab29bc507a92" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B-VSHAKEN_CORE-NSD-TOAM0_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/016d3722-999b-4133-b4e6-8a1088bab664", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "016d3722-999b-4133-b4e6-8a1088bab664" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND-vepdg-FN-Shared_oam_protected_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/80038196-9eae-452c-ad06-1f3fef1bef9f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "80038196-9eae-452c-ad06-1f3fef1bef9f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_VPMS-FN-26071-T-BE-01_cdr_direct_net420" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/f5f38447-dc62-4969-90a3-c60474f9c0ac", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f5f38447-dc62-4969-90a3-c60474f9c0ac" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_Shared_OAM_DIRECT_NET_3" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/58b374aa-01ca-4a39-99b9-889c2f7ae908", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "58b374aa-01ca-4a39-99b9-889c2f7ae908" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_OAM_MGMT_NET_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/efe0dfca-18e7-4992-a63a-041b9f8271e0", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "efe0dfca-18e7-4992-a63a-041b9f8271e0" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_APN-dns_int_apn_dns_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/dab7e704-6a6e-4c53-9a80-fb5857a43b6f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "dab7e704-6a6e-4c53-9a80-fb5857a43b6f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B-VSHAKEN_CORE-NSD-TOAM0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/634653b3-9084-41d9-ad6a-40863a3d666f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "634653b3-9084-41d9-ad6a-40863a3d666f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-01A_int_fw_dns_trusted_net_5" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/6117b35e-c029-4308-85e6-007c24014484", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6117b35e-c029-4308-85e6-007c24014484" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-24595-D-T001_vprobes_int_mgmt_net_2" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/eb1ce51b-d10f-4b08-9166-345335b9f73b", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "eb1ce51b-d10f-4b08-9166-345335b9f73b" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_OAMP_NSD_ISBC0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/468f83be-4abb-4901-950b-e399b77a09a0", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "468f83be-4abb-4901-950b-e399b77a09a0" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_IRPR-TOAM0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/103d17dc-6575-427c-a2c1-301493e08ec0", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "103d17dc-6575-427c-a2c1-301493e08ec0" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_segw_hsl_direct_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/305214f8-64be-4209-8a0d-10b6dfb77dd1", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "305214f8-64be-4209-8a0d-10b6dfb77dd1" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_vMDS_FN_int_fw_dns_trusted_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/7989a6d2-ba10-4a5d-8f15-4520bc833090", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7989a6d2-ba10-4a5d-8f15-4520bc833090" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02AShared_cor_direct_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/f040ebf4-76ad-4b05-a766-1deec26549ae", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f040ebf4-76ad-4b05-a766-1deec26549ae" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vEPDG-FN-26642-T-01_gn_untrusted_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/26d6038b-4b9e-4fe5-bcff-9af7586651cc", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "26d6038b-4b9e-4fe5-bcff-9af7586651cc" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-24595-D-T001_vprobes_pktinternal_net_10" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/9e78d3f4-85b5-40b8-803e-c3a0ab6d6165", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "9e78d3f4-85b5-40b8-803e-c3a0ab6d6165" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_MNS_Shared_oam_protected_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/a2de22f9-eb91-452e-aff5-e81a1a679ef6", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "a2de22f9-eb91-452e-aff5-e81a1a679ef6" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_Shared_GN_DIRECT_NET_01" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/6d6b7254-72d2-4731-80d6-8e8375d959e9", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6d6b7254-72d2-4731-80d6-8e8375d959e9" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_VDBE-PED-DMZ0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/21819ac4-95c4-490f-ba7c-0ad92920f805", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "21819ac4-95c4-490f-ba7c-0ad92920f805" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_FN_int_pktinternal_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/98ff6827-320a-4b71-bd2b-df2bd20b6855", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "98ff6827-320a-4b71-bd2b-df2bd20b6855" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_Shared_oam_protected_net_2" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/e229ab86-279c-4505-a08a-91e373293e20", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "e229ab86-279c-4505-a08a-91e373293e20" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_Shared_OAM_DIRECT_NET_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/bb722f93-2d1a-42a5-bd11-57ad30ff1085", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "bb722f93-2d1a-42a5-bd11-57ad30ff1085" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_segw_hsl_direct_net_2" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/0399443d-1fc6-42a6-934c-77030d751916", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0399443d-1fc6-42a6-934c-77030d751916" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_VDBE-PED-DMZ0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/d259ec74-304d-4bd2-bbd6-93c201acba42", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "d259ec74-304d-4bd2-bbd6-93c201acba42" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A__vprobes_int_mgmt_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/f69fb458-e2bd-4d0f-9a47-430d18cbebfd", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f69fb458-e2bd-4d0f-9a47-430d18cbebfd" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_VPMS-FN-26071-T-BE-01_cdr_direct_net4" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/0f18b91f-ee79-403b-a081-8c0a89650641", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0f18b91f-ee79-403b-a081-8c0a89650641" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_VPMS-FN_int_pktinternal_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/90fdbbbb-42bb-41ff-9356-db245466a4fc", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "90fdbbbb-42bb-41ff-9356-db245466a4fc" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_Shared_oam_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/0e66adce-d5dd-4968-bcb2-83f0281424db", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0e66adce-d5dd-4968-bcb2-83f0281424db" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B-VSHAKEN_VDBF-MIS-UDAT0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/db572383-dbd7-4d5e-93cb-8c7c1d209a90", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "db572383-dbd7-4d5e-93cb-8c7c1d209a90" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_TRST_VIF_ISBC0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/478b7f86-8544-48e5-95f1-568dfd18730d", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "478b7f86-8544-48e5-95f1-568dfd18730d" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_Shared_GN_DIRECT_NET_01" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/0f725895-5224-4016-b49a-d9d016eaafff", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0f725895-5224-4016-b49a-d9d016eaafff" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_Shared_OAM_DIRECT_NET_2" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/9cd47b0c-ee58-46f0-9ec5-b4db504dd59b", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "9cd47b0c-ee58-46f0-9ec5-b4db504dd59b" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "MNS-FN-25180-T-01Shared_oam_protected_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/f95259c9-f5c6-4861-a9f4-b6eec199b33f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "f95259c9-f5c6-4861-a9f4-b6eec199b33f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_Shared_oam_protected_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/caf98ee4-2496-4c92-a41c-b6a50efcc29f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "caf98ee4-2496-4c92-a41c-b6a50efcc29f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_MGM-CORE-NSD-TOAM0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/754739cb-5371-4d5b-a02a-489587d17443", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "754739cb-5371-4d5b-a02a-489587d17443" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_Shared_OAM_DIRECT_NET_4" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/8cd7add8-0cfc-4f65-bbf8-d0f25a0dbc70", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8cd7add8-0cfc-4f65-bbf8-d0f25a0dbc70" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_VDBE-MIS-UDAT0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/7093921f-bed8-4866-bb3c-a2b8c376ca69", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "7093921f-bed8-4866-bb3c-a2b8c376ca69" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_VIRPR-TDAT0_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/691da8b2-805e-4dd1-aaf5-b0e37414c662", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "691da8b2-805e-4dd1-aaf5-b0e37414c662" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_int_pktmirror_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/00eaa0b3-90df-4b43-a850-9d30abb7fded", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "00eaa0b3-90df-4b43-a850-9d30abb7fded" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-01AShared_oam_protected_net_5" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/6ba57200-c61a-46be-821b-88b3fa169b66", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6ba57200-c61a-46be-821b-88b3fa169b66" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_OAM_MGMT_NET_3" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/8e32ec2c-47a1-4514-b21a-2806e23f0437", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8e32ec2c-47a1-4514-b21a-2806e23f0437" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B-VSHAKENb_VDBF-PSD-DMZ0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/a755ddd0-512a-444d-9f38-97b3eff70f85", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "a755ddd0-512a-444d-9f38-97b3eff70f85" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_UNTR_VSE_ISBC0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/c7bde85d-1c12-467c-ae6f-57bdf5c1d380", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c7bde85d-1c12-467c-ae6f-57bdf5c1d380" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B-VSHAKENb_VDBF-PSD-DMZ0_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/0933fcec-9e78-4045-a21a-8258e18cb78e", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "0933fcec-9e78-4045-a21a-8258e18cb78e" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_vdbe_oam_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/6a26a729-d9ce-4619-a20e-38597205ba7d", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "6a26a729-d9ce-4619-a20e-38597205ba7d" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vEPDG-FN-26642-T-01_swu_direct_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/c1a06665-518b-408b-bfe0-8f393204baf6", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c1a06665-518b-408b-bfe0-8f393204baf6" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_OAM_MGMT_NET_2" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/fb51398b-7622-4570-9bd6-e29c82621d44", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "fb51398b-7622-4570-9bd6-e29c82621d44" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02B_OAM_MGMT_NET_4" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/92072731-1c40-45c2-a218-5e75b713b312", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "92072731-1c40-45c2-a218-5e75b713b312" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_TRST_VIF_ISBC0_net_0001" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/c6d94632-fd6b-4bfe-993e-377b0368476b", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c6d94632-fd6b-4bfe-993e-377b0368476b" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-01AShared_int_ha_net_5" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/84516ef3-e371-4039-908e-83cd2b55a4a1", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "84516ef3-e371-4039-908e-83cd2b55a4a1" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "VPMS-FN-26071-T-BE-01_vprobes_int_mgmt_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/2c4f3adc-1a45-4484-8fb6-9eeac99eb922", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "2c4f3adc-1a45-4484-8fb6-9eeac99eb922" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_VDBE-MIS-UDAT0_net_0" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/1fea0624-dac2-4997-904d-34ca1bc12fa9", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "1fea0624-dac2-4997-904d-34ca1bc12fa9" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02AShared_cps_internal_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/8ab98982-05b7-45b2-828d-648da3d6cc0f", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8ab98982-05b7-45b2-828d-648da3d6cc0f" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vEPDG-FN-26642-T-01_swu_direct_fn_net_2" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/c8934d59-24a8-41cc-af9d-2026ef261843", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c8934d59-24a8-41cc-af9d-2026ef261843" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APPC-24595-T-IST-02A_Shared_oam_protected_net_vrar_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/c741fe5b-bf27-4ad9-b30d-20518e115495", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c741fe5b-bf27-4ad9-b30d-20518e115495" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_int_apn_dns_fn_net_PB_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/8285fbae-ec25-44f7-ac52-89a968d45a2b", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "8285fbae-ec25-44f7-ac52-89a968d45a2b" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-T2B_vEPDG-FN_swu_direct_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/65e6d4b0-0c96-4bfa-bdd6-2baa16df322a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "65e6d4b0-0c96-4bfa-bdd6-2baa16df322a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-DND_vEPDG-FN_gn_untrusted_fn_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/38e51c7b-adc2-491a-a036-3189645b007c", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "38e51c7b-adc2-491a-a036-3189645b007c" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vprobes_pktinternal_net_2_1806" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/4d210b09-b6ce-41b3-95a6-5e4dffea9ca2", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "4d210b09-b6ce-41b3-95a6-5e4dffea9ca2" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vprobes_pktinternal_net_3_1806" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/c5df1c57-3c85-4abc-973f-a1ffb13e391a", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "c5df1c57-3c85-4abc-973f-a1ffb13e391a" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_1" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/467e3349-bec1-4922-bcb1-d0bb041bce30", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "467e3349-bec1-4922-bcb1-d0bb041bce30" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "vprobes_pktinternal_net_4_1806" + }] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v12/network/l3-networks/l3-network/1596f4d2-66b5-4627-96f2-c26794154530", + "relationship-data": [ { + "relationship-key": "l3-network.network-id", + "relationship-value": "1596f4d2-66b5-4627-96f2-c26794154530" + }], + "related-to-property": [ { + "property-key": "l3-network.network-name", + "property-value": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_2" + }] + } + ]} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryIdAAIResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryIdAAIResponse.xml new file mode 100644 index 0000000000..6dd91c64c9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/queryIdAAIResponse.xml @@ -0,0 +1,145 @@ + + 8d35a433-c1db-4d54-a611-6de10aeb76f9 + Dev_Bindings_1802_1311 + CONTRAIL30_BASIC + GN_EVPN_direct + contrail + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + 1517430804756 + pending-create + tbd + true + true + false + + + 9dbb9e7e-fe18-421f-bad6-2305bd282471 + + 107.118.41.1 + 107.118.41.0 + 24 + 4 + pending-create + true + 107.118.41.3 + 107.118.41.45 + + true + 1517430804770 + + + 1bb4e1d2-d225-47f3-b6fc-2d0b290de1ab + + 107.118.42.1 + 107.118.42.0 + 24 + 4 + pending-create + true + 107.118.42.3 + 107.118.42.45 + + true + 1517430804782 + + + + + service-instance + /aai/v11/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/f1d1c7da-fc42-4c31-866e-cfe963e55723 + + customer.global-customer-id + MSO_1610_dev + + + service-subscription.service-type + MSO-dev-service-type + + + service-instance.service-instance-id + f1d1c7da-fc42-4c31-866e-cfe963e55723 + + + service-instance.service-instance-name + MSO-DEV-SI-1802-v6-1-31-nwk1 + + + + cloud-region + /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6 + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn6 + + + cloud-region.owner-defined-type + LCP + + + + tenant + /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8 + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn6 + + + tenant.tenant-id + 0422ffb57ba042c0800a29dc85ca70f8 + + + tenant.tenant-name + ECOMP_MSO_DND + + + + network-policy + /aai/v11/network/network-policies/network-policy/0219d83f-7c4a-48e2-b8fc-9b20459356bc + + network-policy.network-policy-id + 0219d83f-7c4a-48e2-b8fc-9b20459356bc + + + network-policy.network-policy-fqdn + default-domain:ECOMP_MSO_DND:MSOPolicyD + + + + network-policy + /aai/v11/network/network-policies/network-policy/e7a3560c-8b29-4611-a404-83af0b31ce64 + + network-policy.network-policy-id + e7a3560c-8b29-4611-a404-83af0b31ce64 + + + network-policy.network-policy-fqdn + default-domain:ECOMP_MSO_DND:MSOPolicyC + + + + vpn-binding + /aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001 + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + MSO_VPN_TEST + + + vpn-binding.vpn-type + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/unassignNetworkBB_queryAAIResponse_.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/unassignNetworkBB_queryAAIResponse_.json new file mode 100644 index 0000000000..f076c9044c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/unassignNetworkBB_queryAAIResponse_.json @@ -0,0 +1,162 @@ +{ + "network-id": "0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "network-name": "Dev_Bindings_1802_020118", + "network-type": "CONTRAIL30_BASIC", + "network-role": "GN_EVPN_direct", + "network-technology": "contrail", + "neutron-network-id": "1112b912-0e00-4d6d-9392-014e106399ee", + "is-bound-to-vpn": true, + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "network-role-instance": 0, + "resource-version": "1517496965485", + "orchestration-status": "Active", + "heat-stack-id": "Dev_Bindings_1802_020118/06c2445f-1ca1-4ad8-be08-454c4de443bb", + "contrail-network-fqdn": "default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_020118", + "physical-network-name": "tbd", + "is-provider-network": false, + "is-shared-network": true, + "is-external-network": false, + "subnets": {"subnet": [ + { + "subnet-id": "209f62cf-cf0c-42f8-b13c-f038b92ef108", + "subnet-name": "", + "neutron-subnet-id": "3942ca32-5f5b-4d62-a2e4-b528b7a4318c", + "gateway-address": "192.168.41.1", + "network-start-address": "192.168.41.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.41.3", + "dhcp-end": "192.168.41.45", + "ip-assignment-direction": "", + "resource-version": "1517496965497" + }, + { + "subnet-id": "971bc608-1aff-47c0-923d-92e43b699f01", + "subnet-name": "", + "neutron-subnet-id": "81a5ff92-7ca4-4756-a493-496479f0d10f", + "gateway-address": "192.168.42.1", + "network-start-address": "192.168.42.0", + "cidr-mask": "24", + "ip-version": "4", + "orchestration-status": "Active", + "dhcp-enabled": true, + "dhcp-start": "192.168.42.3", + "dhcp-end": "192.168.42.45", + "ip-assignment-direction": "", + "resource-version": "1517496965508" + } + ]}, + "relationship-list": {"relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/cc88915e-fb95-4b16-9c1e-a0abf40d1e40", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "MSO_1610_dev" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "MSO-dev-service-type" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "cc88915e-fb95-4b16-9c1e-a0abf40d1e40" + } + ], + "related-to-property": [ { + "property-key": "service-instance.service-instance-name", + "property-value": "MSO-DEV-SI-1802-v6-2-01-nwk1" + }] + }, + { + "related-to": "cloud-region", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtn6" + } + ], + "related-to-property": [ { + "property-key": "cloud-region.owner-defined-type", + "property-value": "LCP" + }] + }, + { + "related-to": "vf-module", + "related-link": "aai/v11/network/generic-vnfs/generic-vnf/105df7e5-0b3b-49f7-a837-4864b62827c4/vf-modules/vf-module/d9217058-95a0-49ee-b9a9-949259e89349", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "105df7e5-0b3b-49f7-a837-4864b62827c4" + }, + { + "relationship-key": "vf-module.vf-module-id", + "relationship-value": "d9217058-95a0-49ee-b9a9-949259e89349" + } + ], + "related-to-property": [ { + "property-key": "tenant.tenant-name", + "property-value": "ECOMP_MSO_DND" + }] + }, + { + "related-to": "route-table-reference", + "related-link": "/aai/v11/network/route-table-references/route-table-reference/c87fa27e-ac15-4b3e-b7ef-866682d8ca00", + "relationship-data": [ { + "relationship-key": "route-table-reference.route-table-reference-id", + "relationship-value": "c87fa27e-ac15-4b3e-b7ef-866682d8ca00" + }], + "related-to-property": [ { + "property-key": "route-table-reference.route-table-reference-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:RTA" + }] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/0219d83f-7c4a-48e2-b8fc-9b20459356bc", + "relationship-data": [ { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "0219d83f-7c4a-48e2-b8fc-9b20459356bc" + }], + "related-to-property": [ { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyD" + }] + }, + { + "related-to": "network-policy", + "related-link": "/aai/v11/network/network-policies/network-policy/e7a3560c-8b29-4611-a404-83af0b31ce64", + "relationship-data": [ { + "relationship-key": "network-policy.network-policy-id", + "relationship-value": "e7a3560c-8b29-4611-a404-83af0b31ce64" + }], + "related-to-property": [ { + "property-key": "network-policy.network-policy-fqdn", + "property-value": "default-domain:ECOMP_MSO_DND:MSOPolicyC" + }] + }, + { + "related-to": "vpn-binding", + "related-link": "/aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001", + "relationship-data": [ { + "relationship-key": "vpn-binding.vpn-id", + "relationship-value": "9a7b327d9-287aa00-82c4b0-100001" + }], + "related-to-property": [ + { + "property-key": "vpn-binding.vpn-name", + "property-value": "MSO_VPN_TEST" + }, + {"property-key": "vpn-binding.vpn-type"} + ] + } + ]} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/updateContrailAAIPayloadRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/updateContrailAAIPayloadRequest.xml new file mode 100644 index 0000000000..92fec2dc64 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/Network/updateContrailAAIPayloadRequest.xml @@ -0,0 +1,149 @@ + + 8d35a433-c1db-4d54-a611-6de10aeb76f9 + Dev_Bindings_1802_1311 + CONTRAIL30_BASIC + GN_EVPN_direct + contrail + b6a7820c-4734-4ef2-8a73-a22c824423fa + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + 1517430804756 + Created + Dev_Bindings_1802_1311/ecf7e197-72db-452e-9eda-253cb642c9b7 + default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_1311 + tbd + true + true + false + + + 9dbb9e7e-fe18-421f-bad6-2305bd282471 + 27d414c7-1076-4595-aa45-4717ee992cef + 107.118.41.1 + 107.118.41.0 + 24 + 4 + Created + true + 107.118.41.3 + 107.118.41.45 + 1517430804770 + + true + + + 1bb4e1d2-d225-47f3-b6fc-2d0b290de1ab + db64710c-fbbc-4dc9-8109-3925b87268fa + 107.118.42.1 + 107.118.42.0 + 24 + 4 + Created + true + 107.118.42.3 + 107.118.42.45 + 1517430804782 + + true + + + + + service-instance + /aai/v11/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/f1d1c7da-fc42-4c31-866e-cfe963e55723 + + customer.global-customer-id + MSO_1610_dev + + + service-subscription.service-type + MSO-dev-service-type + + + service-instance.service-instance-id + f1d1c7da-fc42-4c31-866e-cfe963e55723 + + + service-instance.service-instance-name + MSO-DEV-SI-1802-v6-1-31-nwk1 + + + + cloud-region + /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6 + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn6 + + + cloud-region.owner-defined-type + LCP + + + + tenant + /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/0422ffb57ba042c0800a29dc85ca70f8 + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn6 + + + tenant.tenant-id + 0422ffb57ba042c0800a29dc85ca70f8 + + + tenant.tenant-name + ECOMP_MSO_DND + + + + network-policy + /aai/v11/network/network-policies/network-policy/0219d83f-7c4a-48e2-b8fc-9b20459356bc + + network-policy.network-policy-id + 0219d83f-7c4a-48e2-b8fc-9b20459356bc + + + network-policy.network-policy-fqdn + default-domain:ECOMP_MSO_DND:MSOPolicyD + + + + network-policy + /aai/v11/network/network-policies/network-policy/e7a3560c-8b29-4611-a404-83af0b31ce64 + + network-policy.network-policy-id + e7a3560c-8b29-4611-a404-83af0b31ce64 + + + network-policy.network-policy-fqdn + default-domain:ECOMP_MSO_DND:MSOPolicyC + + + + vpn-binding + /aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001 + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + MSO_VPN_TEST + + + vpn-binding.vpn-type + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf new file mode 100644 index 0000000000..09634c199b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf @@ -0,0 +1,107 @@ +{ + "transactionId": "testRequestId", + "requestId": "testRequestId", + "requestState": "complete", + "statusMessage": "", + "solutionInfo": { + "licenseInfo": [ + { + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ], + "resourceModuleName": "vHNPortalaaS_primary_1", + "serviceResourceId": "testResourceIdAR" + }, + { + "entitlementPoolList": [ + "91d563e8-e714-4393-8f99-cc480144a05e", + "21d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "31d563e8-e714-4393-8f99-cc480144a05e", + "71d563e8-e714-4393-8f99-cc480144a05e" + ], + "resourceModuleName": "vHNPortalaaS_secondary_1", + "serviceResourceId": "testResourceIdVNF" + } + ], + "placementInfo": [ + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "vnfHostName", + "variableValue": "MDTNJ01" + }, + { + "variableName": "aicClli", + "variableValue": "KDTNJ01" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "dfwtx", + "inventoryType": "service", + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceInstanceId": "testSIID1", + "serviceResourceId": "testResourceIdAR" + }, + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "vnfHostName", + "variableValue": "testVnfHostname2" + }, + { + "variableName": "aicClli", + "variableValue": "testAicClli2" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "testCloudRegionId2", + "inventoryType": "service", + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceInstanceId": "testSIID2", + "serviceResourceId": "testResourceIdAR2" + }, + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "aicClli", + "variableValue": "testAicClli3" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "testCloudRegionId3", + "inventoryType": "cloud", + "resourceModuleName": "VNF", + "serviceInstanceId": "", + "serviceResourceId": "testResourceIdVNF" + } + ] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net new file mode 100644 index 0000000000..ac9b466ab7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net @@ -0,0 +1,165 @@ +{ + "transactionId": "testRequestId", + "requestId": "testRequestId", + "requestState": "complete", + "statusMessage": "", + "solutionInfo": { + "licenseInfo": [ + { + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ], + "resourceModuleName": "vHNPortalaaS_primary_1", + "serviceResourceId": "testResourceIdAR" + }, + { + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05n", + "j1d563e8-e714-4393-8f99-cc480144a05n" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05n", + "b1d563e8-e714-4393-8f99-cc480144a05n" + ], + "resourceModuleName": "net", + "serviceResourceId": "testResourceIdNet2" + }, + { + "entitlementPoolList": [ + "91d563e8-e714-4393-8f99-cc480144a05e", + "21d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "31d563e8-e714-4393-8f99-cc480144a05e", + "71d563e8-e714-4393-8f99-cc480144a05e" + ], + "resourceModuleName": "vHNPortalaaS_secondary_1", + "serviceResourceId": "testResourceIdVNF" + } + ], + "placementInfo": [ + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "vnfHostName", + "variableValue": "MDTNJ01" + }, + { + "variableName": "aicClli", + "variableValue": "KDTNJ01" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "dfwtx", + "inventoryType": "service", + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceInstanceId": "testSIID1", + "serviceResourceId": "testResourceIdAR" + }, + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "vnfHostName", + "variableValue": "testVnfHostname2" + }, + { + "variableName": "aicClli", + "variableValue": "testAicClli2" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "testCloudRegionId2", + "inventoryType": "service", + "resourceModuleName": "ALLOTTED_RESOURCE", + "serviceInstanceId": "testSIID2", + "serviceResourceId": "testResourceIdAR2" + }, + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "vnfHostName", + "variableValue": "testVnfHostNameNet" + }, + { + "variableName": "aicClli", + "variableValue": "testAicClliNet" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "testCloudRegionIdNet", + "inventoryType": "service", + "resourceModuleName": "NETWORK", + "serviceInstanceId": "testServiceInstanceIdNet", + "serviceResourceId": "testResourceIdNet" + }, + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "aicClli", + "variableValue": "testAicClliNet2" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "testCloudRegionIdNet2", + "inventoryType": "cloud", + "resourceModuleName": "NETWORK", + "serviceInstanceId": "", + "serviceResourceId": "testResourceIdNet2" + }, + { + "assignmentInfo": [ + { + "variableName": "cloudOwner", + "variableValue": "aic" + }, + { + "variableName": "aicClli", + "variableValue": "testAicClli3" + }, + { + "variableName": "aicVersion", + "variableValue": "3.0" + } + ], + "cloudRegionId": "testCloudRegionId3", + "inventoryType": "cloud", + "resourceModuleName": "VNF", + "serviceInstanceId": "", + "serviceResourceId": "testResourceIdVNF" + } + ] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound new file mode 100644 index 0000000000..2150a053fb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound @@ -0,0 +1,15 @@ +{ + "requestState": "", + "responseTime": "", + "solutionInfo": { + "placementInfo": [], + "licenseInfo": { + "featureGroupId": "" + } + }, + "percentProgress": "", + "requestId": "02c2e322-5839-4c97-9d46-0a5fa6bb642e", + "startTime": "", + "statusMessage": "No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8", + "requestType": "" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException new file mode 100644 index 0000000000..b82688428e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException @@ -0,0 +1,9 @@ +{ + "requestError": { + "policyException": { + "requestId": "ae81d9a8-c949-493a-999c-f76c80503233", + "text": "Message content size exceeds the allowable limit", + "messageId": "SVC0001" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException new file mode 100644 index 0000000000..6cc78a7cdb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException @@ -0,0 +1,12 @@ +{ + "requestError": { + "serviceException": { + "variables": [ + "severity", 400 + ], + "requestId": "ae81d9a8-c949-493a-999c-f76c80503233", + "text": "SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8", + "messageId": "SVC0001" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml new file mode 100644 index 0000000000..90c668c576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 2.5 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml new file mode 100644 index 0000000000..9b651f25e3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 3.0 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_400.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_400.xml new file mode 100644 index 0000000000..a5640b2b26 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_400.xml @@ -0,0 +1,6 @@ + + +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 + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_500.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_500.xml new file mode 100644 index 0000000000..02996a13ea --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_500.xml @@ -0,0 +1,80 @@ + + + JBoss Web/7.2.2.Final-redhat-1 - JBWEB000064: Error report + + + + +

JBWEB000065: HTTP Status 500 - java.lang.NullPointerException

+
+

+ JBWEB000309: type + JBWEB000066: Exception report +

+

+ JBWEB000068: message + java.lang.NullPointerException +

+

+ JBWEB000069: description + JBWEB000145: The server encountered an internal error that + prevented it from fulfilling this request. + +

+

+ JBWEB000070: exception +

org.jboss.resteasy.spi.UnhandledException:
+				java.lang.NullPointerException
+				org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365)
+				org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233)
+				org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209)
+				org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
+				org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
+				javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
+				org.onap.so.logger.LogFilter.doFilter(LogFilter.java:35)
+			
+

+

+ JBWEB000071: root cause +

java.lang.NullPointerException
+				org.onap.so.adapters.network.NetworkAdapterRest$CreateNetworkVolumesTask.run(NetworkAdapterRest.java:128)
+				org.onap.so.adapters.network.NetworkAdapterRest.createNetwork(NetworkAdapterRest.java:64)
+				sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+				sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
+				sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+				java.lang.reflect.Method.invoke(Method.java:606)
+				org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
+				org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
+				org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
+				org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
+				org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
+				org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
+				javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
+				org.onap.so.logger.LogFilter.doFilter(LogFilter.java:35)
+			
+

+

+ JBWEB000072: note + JBWEB000073: The full stack trace of the root cause is available + in the JBoss Web/7.2.2.Final-redhat-1 logs. + +

+
+

JBoss Web/7.2.2.Final-redhat-1

+ + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_Success.xml new file mode 100644 index 0000000000..90177f1c6d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetworkResponse_Success.xml @@ -0,0 +1,24 @@ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + + 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 + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryInstance_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryInstance_Success.xml new file mode 100644 index 0000000000..ca5145c226 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryInstance_Success.xml @@ -0,0 +1,4 @@ + + service-instance + https://aai-conexus-e2e.test.com:8443/aai/v8/business/customers/customer/8310000058863/service-subscriptions/service-subscription/vMOG/service-instances/service-instance/f70e927b-6087-4974-9ef8-c5e4d5847ca4 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName2_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName2_AAIResponse_Success.xml new file mode 100644 index 0000000000..d6f7737a2a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName2_AAIResponse_Success.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4_3 + 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 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNameActive_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNameActive_AAIResponse_Success.xml new file mode 100644 index 0000000000..03b37814b1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNameActive_AAIResponse_Success.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_2 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + active + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + active + true + subnetName + + + + + 413 + 4132176 + + + + 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 + + + + route-table-reference + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_404.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_404.xml new file mode 100644 index 0000000000..5cda12da2f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_404.xml @@ -0,0 +1,19 @@ + + 404 + HTTP method: GET Not Found + <Fault> + <requestError> + <serviceException> + <messageId>SVC3001</messageId> + <text>Resource not found for %1 using id %2 (msg=%3) (ec=%4)</text> + <variables> + <variable>GETl3Networks</variable> + <variable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> + <variable>Node Not Found:No Node of type l3Network found for properties: (network-id = null)</variable> + <variable>ERR.5.4.6114</variable> + </variables> + </serviceException> + </requestError> +</Fault> + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml new file mode 100644 index 0000000000..4eadb1061e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + 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 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_404.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_404.xml new file mode 100644 index 0000000000..5cda12da2f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_404.xml @@ -0,0 +1,19 @@ + + 404 + HTTP method: GET Not Found + <Fault> + <requestError> + <serviceException> + <messageId>SVC3001</messageId> + <text>Resource not found for %1 using id %2 (msg=%3) (ec=%4)</text> + <variables> + <variable>GETl3Networks</variable> + <variable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> + <variable>Node Not Found:No Node of type l3Network found for properties: (network-id = null)</variable> + <variable>ERR.5.4.6114</variable> + </variables> + </serviceException> + </requestError> +</Fault> + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml new file mode 100644 index 0000000000..e06d27ea88 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml @@ -0,0 +1,73 @@ + + + 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 + + + + + 413 + 4132176 + + + + 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 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml new file mode 100644 index 0000000000..6e319c4c73 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + 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 + true + + + string + 192.10.16.0/24 + 192.10.16.100/24 + ip-address + + + string + 192.110.17.0/24 + 192.110.17.110/24 + ip-address + + + + + + + 413 + 4132176 + + + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..79cc14ada3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + 13979:105757 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml new file mode 100644 index 0000000000..db134a1127 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 5938baec-03ca-2bd5-a3f1-d54x123e253a + refFQDN1 + 12345 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml new file mode 100644 index 0000000000..34b4a036c4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 5938baec-03ca-2bd5-a3f1-d54x123e253a + refFQDN2 + 12345 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml new file mode 100644 index 0000000000..c01d0a4f61 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + + + 13979:105708 + EXPORT + 1504025599510 + + + 13979:105707 + IMPORT + 1504025599519 + + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v8/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/v8/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/v8/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml new file mode 100644 index 0000000000..5f1c2cafa5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v8/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/v8/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/v8/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml new file mode 100644 index 0000000000..eedbda9343 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml new file mode 100644 index 0000000000..4f87e1a1da --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml @@ -0,0 +1,15 @@ + + + + + + + 79ec9006-3695-4fcc-93a8-be6f9e248beb + 200 + OK + + <output xmlns="org:onap:sdnc:northbound: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/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..836b3c8055 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateNetworkV2mock/sdncCreateNetworkTopologySimResponse.xml @@ -0,0 +1,17 @@ + + + + + + + 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/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/DoCreateServiceInstanceInput.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/DoCreateServiceInstanceInput.json new file mode 100644 index 0000000000..45b09a1f59 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/DoCreateServiceInstanceInput.json @@ -0,0 +1,42 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "Test", +"modelVersion": "1.0" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "mdt1", +"tenantId": "88a6ca3ee0394ade9403f075db23167e" +}, +"owningEntity": { +"owningEntityId": "a", +"owningEntityName": "a" +}, +"project": { +"projectName": "temp project" +}, +"subscriberInfo": { +"globalSubscriberId": "some subscriber id", +"subscriberName": "some subscriber name" +}, +"requestInfo": { +"productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", +"source": "VID", +"suppressRollback": true, +"requestorId": "xxxxxx" +}, +"requestParameters": { +"subscriptionServiceType": "MOG", +"aLaCarte": false, +"userParams": [ +{ +"name": "someUserParam", +"value": "someValue" +} +] +} +} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/SetupServiceDecompJson.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/SetupServiceDecompJson.json new file mode 100644 index 0000000000..e7960b7273 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/SetupServiceDecompJson.json @@ -0,0 +1,36 @@ +{ + "requestDetails": { + "serviceInstance": { + "serviceInstanceId": "MSORefactorTest3", + "serviceInstanceName": "bensServiceInstance3", + "serviceType": "MSO-dev-service-type", + "serviceRole": "abc", + "modelInvariantUuid": "d214abcc-2083-11e7-93ae-92361f002671", + "modelUuid": "c4503baa-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelName": "MSOTADevInfra_vSAMP12_Service", + "environmentContext": "Luna", + "workloadContext": "Oxygen", + "orchestrationStatus": "ACTIVE" + }, + "project": { + "projectName": "vSAMP12 Project" + }, + "owningEntity": { + "owningEntityId": "MSO-Test-OE", + "owningEntityName": "MSO-Test123" + }, + "customer": { + "subscriptionServiceType": "MSO-dev-service-type", + "globalSubscriberId": "MSO_1610_dev" + }, + "request": { + "sdncRequestId": "736c7370-640b-4f7a-975d-320f73340dd3", + "callbackURL": "abc", + "requestId": "223c2e74-a23a-4ab8-bddb-2c2431dcb67f", + "productFamilyId": "abc", + "callbackUrl": "http://localhost:8080/adapters/rest/SDNCNotify", + "serviceId": "123" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_createServiceInstance_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_createServiceInstance_AAIResponse_Success.xml new file mode 100644 index 0000000000..eedbda9343 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_createServiceInstance_AAIResponse_Success.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml new file mode 100644 index 0000000000..be820b83b1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + 8310000058863 + Mobility + INFRA + 1452288058 + + + vMOG + 1452288058 + + + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + gg0e927b-6087-5574-9ef8-c5e4d5847db5 + V1.0 + vMOG-AKRON-1234 + 1462561835 + + + + + + + tenant + https://aai-conexus-e2e.test.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/396d61752cf04c3b8ca2afcb4ee049e9/ + + tenant.tenant-id + 396d61752cf04c3b8ca2afcb4ee049e9 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + AAIAIC25 + + + tenant.tenant-name + vMOG-AKRON-PROD + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleCallbackException.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleCallbackException.xml new file mode 100644 index 0000000000..1ede44427a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleCallbackException.xml @@ -0,0 +1,7 @@ + + + {{MESSAGE-ID}} + INTERNAL + Exception during create VF Create VF Module: Unable to determine specific VF Module Type: Nimbus_LU2_PXMC_Svc/PXMC_09_20_2016_v2 3::Pxmc09202016V2..pxmc_base.yaml..module-2 with version = 3.0 + true + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeCallbackResponse.xml new file mode 100644 index 0000000000..a421355aba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeCallbackResponse.xml @@ -0,0 +1,53 @@ + + + {{MESSAGE-ID}} + true + d485ecee-957c-4a0a-8b95-27a22b90103f + + + mmsc_vol_1 + a73e0fe9-1ce8-49c2-8fef-e2788605be29 + + + mmsc_vol_2 + 37b6455a-5ea8-463a-89e3-0efeaf7b7c6d + + + nemsfe_vol_1 + b7ff1c21-d138-49a3-bf13-4cfd91efaf48 + + + nemsbe_vol_1 + a5988471-cd42-44d8-b078-64f2f13d3d4c + + + mmsc_vol_5 + f7b91c1e-ab8c-413a-a850-ba80a246c7e0 + + + nemsfe_vol_2 + 957ea3f3-2d4a-4707-bfd2-ba66f42037c2 + + + mmsc_vol_3 + de6fccfe-d61a-48b0-b03b-87bf1bf749b3 + + + mmsc_vol_4 + 76162310-2c38-4c32-981c-5c2880190077 + + + + RDM2WAGPLCP + e585e4f4-9452-437a-b294-45a2d6d3b7a3 + + c30b9453-4b68-4c2e-aacf-58a5ba648bf5 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + 1bbab536a19b4756926e7d0ec1eb543c + true + 78987 + ZRDM1MMSC01_base_vol/7f74e5e1-5fc1-4593-ac7e-cc9899a106ef + + ZRDM1MMSC01_base_vol/7f74e5e1-5fc1-4593-ac7e-cc9899a106ef + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeRequest.xml new file mode 100644 index 0000000000..34604f1edd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/CreateVfModuleVolumeRequest.xml @@ -0,0 +1,24 @@ + + + 123abc + d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 + CREATE_VF_MODULE_VOL + SoapUI-bns-create-base-vol-1001-1 + + + Test/vSAMP12 + vSAMP12::base::module-0 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 897deadc2b954a6bac6d3c197fb3525e + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + + + + value1" + value2" + value3" + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/GenericVnf.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/GenericVnf.xml new file mode 100644 index 0000000000..aea1a46017 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/GenericVnf.xml @@ -0,0 +1,38 @@ + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/RollbackVfModuleVolumeCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/RollbackVfModuleVolumeCallbackResponse.xml new file mode 100644 index 0000000000..6ab9416617 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/RollbackVfModuleVolumeCallbackResponse.xml @@ -0,0 +1,5 @@ + + + {{MESSAGE-ID}} + true + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json new file mode 100644 index 0000000000..6853daa4b1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request.json @@ -0,0 +1,71 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1", + "modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelInstanceName": "vSAMP12" + } + } + } + ], + "requestParameters": { + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + {"name": "vnfName", "value": "STMTN5MMSC20" }, + {"name": "vnfName2", "value": "US1117MTSNJVBR0246" }, + {"name": "vnfNmInformation", "value": "" }, + {"name": "vnfType", "value": "pcrf-capacity" }, + {"name": "vnfId", "value": "skask" }, + {"name": "vnfStackId", "value": "slowburn" }, + {"name": "vnfStatus", "value": "created" }, + {"name": "aicCloudRegion", "value": "MDTWNJ21" }, + {"name": "availabilityZone", "value": "slcp3-esx-az01" }, + {"name": "oamNetworkName", "value": "VLAN-OAM-1323" }, + {"name": "vmName", "value": "slcp34246vbc246ceb" }, + {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" }, + {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" }, + {"name": "vlc_sctp_b_route_prefixes", + "value": [ + { "interface_route_table_routes_route_prefix": "107.239.41.163/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.164/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.165/32" } + ]} + ] + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json new file mode 100644 index 0000000000..de99a6da56 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_VID_request_noreqparm.json @@ -0,0 +1,45 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test/vSAMP12", + "modelVersion": "1" + } + } + } + ] + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..02b43ff186 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + simpleCinderVolume_201604071 + simpleCinderVolume_201604071 + simpleCinderVolume_201604071 + simple_cinder_master + Pending + 1460134360 + + + tenant + https://aai-ext1.test.com:8443/aai/v6/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..1574310474 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_404.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_404.xml new file mode 100644 index 0000000000..96e906f9bf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_404.xml @@ -0,0 +1,31 @@ + + + 94f0f72f-4be1-49ed-8410-702396797163 + MSOTESTVOL103H-vSAMP12_base_vol_module-0 + + Test/vSAMP12 + Pending + 1469203133 + + + tenant + https://aai-ext1.test.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/e444c311b27a45dc9522f2370d70f90f/ + + tenant.tenant-id + e444c311b27a45dc9522f2370d70f90f + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn6 + + + tenant.tenant-name + MSOCustomer1 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..7aa9c3e8ac --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + 8424bb3c-c3e7-4553-9662-469649ed9379 + MSOTESTVOL103W-vSAMP12_base_vol_module-0 + + simple_cinder_master + Pending + ee6478e5-ea33-3346-ac12-ab121484a3fe + 1460134360 + + + tenant + https://aai-ext1.test.com:8443/aai/v6/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..1574310474 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/getSIUrlById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/getSIUrlById.xml new file mode 100644 index 0000000000..416689e10c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/getSIUrlById.xml @@ -0,0 +1,6 @@ + + + service-instance + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_HasVfModRelationship.xml new file mode 100644 index 0000000000..7e2a676283 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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://localhost: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://localhost: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://localhost: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/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request.json new file mode 100644 index 0000000000..808e371191 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request.json @@ -0,0 +1,77 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "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" + }, + "subscriberInfo": { + "globalSubscriberId": "MSO_1610_dev_id", + "subscriberName": "MSO_1610_dev_name" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "MDTWNJ21", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "PCRF::module-0-2", + "source": "VID", + "suppressRollback": true + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", + "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12..base..module-0", + "modelVersion": "1" + } + } + }, + { + "relatedInstance": { + "instanceId": "123456", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "SERVICE_MODEL_NAME", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "skask", + "instanceName": "skask-test", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "skask", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelInstanceName": "vSAMP12 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "aLaCarte": false, + "userParams": [{ + "name": "vlc_sctp_b_route_prefixes", + "value": [ + { "interface_route_table_routes_route_prefix": "107.239.41.163/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.164/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.165/32" } + ]}] + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json new file mode 100644 index 0000000000..b51741f879 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json @@ -0,0 +1,79 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "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" + }, + "subscriberInfo": { + "globalSubscriberId": "MSO_1610_dev_id", + "subscriberName": "MSO_1610_dev_name" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "MDTWNJ21", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "PCRF::module-0-2", + "source": "VID", + "suppressRollback": true + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", + "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12..base..module-0", + "modelVersion": "1" + } + } + }, + { + "relatedInstance": { + "instanceId": "123456", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "SERVICE_MODEL_NAME", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "skask", + "instanceName": "skask-test", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "skask", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelInstanceName": "vSAMP12 1" + } + } + } + ], + "requestParameters": { + "usePreload": false, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + }, + { + "name": "sgi_protected_subnet_id", + "value": "thisissomefakevalue" + } + ] + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_userParam.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_userParam.json new file mode 100644 index 0000000000..68de099c16 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/CreateVfModule_VID_request_userParam.json @@ -0,0 +1,77 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "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" + }, + "subscriberInfo": { + "globalSubscriberId": "MSO_1610_dev_id", + "subscriberName": "MSO_1610_dev_name" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "MDTWNJ21", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "PCRF::module-0-2", + "source": "VID", + "suppressRollback": true + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", + "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12..base..module-0", + "modelVersion": "1" + } + } + }, + { + "relatedInstance": { + "instanceId": "123456", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "SERVICE_MODEL_NAME", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "skask", + "instanceName": "skask-test", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "skask", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelInstanceName": "vSAMP12 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "aLaCarte": false, + "userParams": [{ + "name": "vlc_sctp_b_route_prefixes", + "value": [ + { "interface_route_table_routes_route_prefix": "107.239.41.163/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.164/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.165/32" } + ]} + ]} + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DBUpdateResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DBUpdateResponse.xml new file mode 100644 index 0000000000..0942e09e31 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBAdapter.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBAdapter.xml new file mode 100644 index 0000000000..5a36d741d0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBAdapter.xml @@ -0,0 +1 @@ +Notified \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBUpdateResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBUpdateResponse.xml new file mode 100644 index 0000000000..0ae5b79484 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Database/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteGenericVNFV1/sdncAdapterResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteGenericVNFV1/sdncAdapterResponse.xml new file mode 100644 index 0000000000..ca195324d3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteGenericVNFV1/sdncAdapterResponse.xml @@ -0,0 +1,7 @@ + + + + <output xmlns="org:onap:sdnctl:vnf"><svc-request-id>1660b8da-0a94-442d-8ed5-ea079e3c67c8</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><vnf-information><vnf-id>8925b50d-de67-44c1-b984-e7ce7b0f4dae</vnf-id></vnf-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>8925b50d-de67-44c1-b984-e7ce7b0f4dae</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion25_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion25_AAIResponse_Success.xml new file mode 100644 index 0000000000..90c668c576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion25_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 2.5 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml new file mode 100644 index 0000000000..9b651f25e3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 3.0 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteAAIResponse_Failure500_RESTFault.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteAAIResponse_Failure500_RESTFault.xml new file mode 100644 index 0000000000..4ce7048950 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteAAIResponse_Failure500_RESTFault.xml @@ -0,0 +1,19 @@ + + 500 + HTTP method: GET Internal Server Error + <Fault> + <requestError> + <serviceException> + <messageId>SVC3002</messageId> + <text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text> + <variables> + <variable>PUT customer</variable> + <variable>SubName32</variable> + <variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [12312442454112] violates a uniqueness constraint [service-instance-id]</variable> + <variable>ERR.5.4.5105</variable> + </variables> + </serviceException> + </requestError> +</Fault> + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml new file mode 100644 index 0000000000..c12bcd49c9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml new file mode 100644 index 0000000000..b108fb25ab --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..1d198caf5d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse.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/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteNetworkV2mock/sdncDeleteNetworkTopologySimResponse_noExtraTag.xml new file mode 100644 index 0000000000..bc0eab88a7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleCallbackResponse.xml new file mode 100644 index 0000000000..74a3beb221 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/DeleteVfModuleVolumeCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/DeleteVfModuleVolumeCallbackResponse.xml new file mode 100644 index 0000000000..25aa45afd9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/DeleteVfModuleVolumeCallbackResponse.xml @@ -0,0 +1,5 @@ + + + {{MESSAGE-ID}} + true + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json new file mode 100644 index 0000000000..c6cc1ca428 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/deleteVfModuleVolume_VID_request_st.json @@ -0,0 +1,17 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "0b01b8c2-8416-11e6-ae22-56b6b6499611", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "MDTWNJ21", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "source": "VID" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml new file mode 100644 index 0000000000..fd10548cef --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml @@ -0,0 +1,42 @@ + + 78987 + MSOTESTVOL102a-vSAMP12_base_vol_module-0 + + Test/vSAMP12 + Pending + 0000020 + + + generic-vnf + https://aai-ext1.test.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.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 + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModule_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModule_VID_request.json new file mode 100644 index 0000000000..c75c32d498 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DeleteVfModule_VID_request.json @@ -0,0 +1,50 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "973ed047-d251-4fb9-bf1a-65b8949e0a73", +"modelNameVersionId": "973ed047-d251-4fb9-bf1a-65b8949e0a73", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceId": "973ed047-d251-4fb9-bf1a-65b8949e0a73", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "00000000-0000-0000-0000-000000000000", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "a27ce5a9-29c4-4c22-a017-6615ac73c721", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "a27ce5a9-29c4-4c22-a017-6615ac73c721", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"userParams": {} +} +} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/DoCreateVfModuleRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/DoCreateVfModuleRequest.xml new file mode 100644 index 0000000000..4aaa56f79a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/DoCreateVfModuleRequest.xml @@ -0,0 +1,31 @@ + + + test-VF-0011 + CREATE_VF_MODULE + VID + MIS/1604/0026/SW_INTERNET + + + skask + STMTN5MMSC20 + myvnftype + PCRF::module-0-2 + STMTN5MMSC21-MMSC::model-1-0 + 00000000-0000-0000-0000-000000000000 + 1.0 + 00000000-0000-0000-0000-000000000000 + MDTWNJ21 + fba1bd1e195a404cacb9ce17a9b2b421 + 78987 + + + STMTN5MMSC20 + vpe-tenant-123 + MDTWNJ21 + false + asn-1234 + release-for-aero-something + MTJWNJA4LCP + svc-provide-number-1234 + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/cloudRegion_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/cloudRegion_AAIResponse_Success.xml new file mode 100644 index 0000000000..90c668c576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/cloudRegion_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 2.5 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml new file mode 100644 index 0000000000..f78d38f802 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/createVnfARequest.xml @@ -0,0 +1,169 @@ + + RDM2WAGPLCP + fba1bd1e195a404cacb9ce17a9b2b421 + skask + skask-test + PCRF::module-0-2 + cb510af0-5b21-4bc7-86d9-323cb396ce32 + vRRaas + PCRF::module-0-2 + 1.0 + cb510af0-5b21-4bc7-86d9-323cb396ced3 + + 12345 + null + null + 12345 + true + 12345 + true + + + vf_module_id + cb510af0-5b21-4bc7-86d9-323cb396ce32 + + + vrra_Internal-Network1_ips + null + + + ADIG_SRIOV_2_subnet_id + + + + vrra_ADIGOam.OAM_v6_ips + null + + + vnf_name + skask-test + + + ADIGOam.OAM_v6_subnet_id + + + + workload_context + null + + + vf_module_name + PCRF::module-0-2 + + + vnf_id + skask + + + ADIG_SRIOV_2_v6_subnet_id + + + + vrra_ADIG_SRIOV_1_ips + null + + + ADIG_SRIOV_1_v6_subnet_id + + + + ADIG_SRIOV_1_subnet_id + + + + ADIG_SRIOV_2_net_name + ADIG_SRIOV_2 + + + ADIGOam.OAM_subnet_id + + + + ADIGOam.OAM_net_id + 491c7cef-a3f4-4990-883e-b0af397466d0 + + + environment_context + null + + + ADIG_SRIOV_1_net_fqdn + + + + ADIGOam.OAM_net_name + ADIGOAM.OAM + + + vrra_name_0 + frkdevRvrra24 + + + vrra_ADIG_SRIOV_2_ips + null + + + ADIG_SRIOV_2_net_fqdn + + + + vrra_Internal-Network2_ips + null + + + ADIG_SRIOV_1_net_name + ADIG_SRIOV_1 + + + vrra_ADIG_SRIOV_1_v6_ips + null + + + vrra_ADIGOam.OAM_ips + null + + + vrra_Internal-Network1_v6_ips + null + + + ADIGOam.OAM_net_fqdn + + + + vrra_names + frkdevRvrra24 + + + ADIG_SRIOV_1_net_id + 491c7cef-a3f4-4990-883e-b0af397466d0 + + + vrra_Internal-Network2_v6_ips + null + + + vrra_ADIG_SRIOV_2_v6_ips + null + + + ADIG_SRIOV_2_net_id + 491c7cef-a3f4-4990-883e-b0af397466d0 + + + vf_module_index + index + + + availability_zone_0 + frkde-esx-az01 + + + + + testRequestId + MIS/1604/0026/SW_INTERNET + + testRequestId-1503410089303-1513204371234 + http://localhost:28080/mso/WorkflowMesssage/VNFAResponse/testRequestId-1503410089303-1513204371234 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/getGenericVnfResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/getGenericVnfResponse.xml new file mode 100644 index 0000000000..be5130ead8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/getGenericVnfResponse.xml @@ -0,0 +1,28 @@ + + 6d2e2469-8708-47c3-a0d4-73fa28a8a50b + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + created + false + false + introvert + 2.0 + 0000020 + + + baseVfModuleId + PCRF::module-0-0 + introvert + 2.0 + false + baseVfModuleHeatStackId + Created + 0000074 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/sdncGetResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/sdncGetResponse.xml new file mode 100644 index 0000000000..20b5462729 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule/sdncGetResponse.xml @@ -0,0 +1,195 @@ + + + 2681784d-118e-4485-929f-2ae3212f5c07-1507707098467 + 200 + OK + + + + vnfID-1712_26 + + 200 + synccomplete + 2017-09-19T143942.327Z + Y + activate-vnf-request + + + + vRRaaS + vnfID-1712_26 + + + ae322537-d081-4a01-95a5-c1448116d0c5 + + + + + + frkde-esx-az01 + + + vrra + 1 + + ADIGOam.OAM + ADIGOAM.OAM + + NMLAN + 10.66.132.113 + 10.66.132.115 + 32 + EIPAM + + VPEADIG1d77c-1086-41ec-b7f3-94bb30936807 + + + ADIG_SRIOV_1 + ADIG_SRIOV_1 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936808 + [,] + + + ADIG_SRIOV_2 + ADIG_SRIOV_2 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936809 + [,] + + + Internal-Network1 + + INTERNAL + 24 + OTHER + 128.0.0.1 + 128.0.0.0 + + VRR-STMTN5MMSC20-INT1 + 12 + VMX-INT1 + + + Internal-Network2 + + INTERNAL + 24 + OTHER + 128.0.0.1 + 128.0.0.0 + + VRR-STMTN5MMSC20-INT2 + 12 + VMX-INT2 + + + frkdevRvrra24 + b05a42c3-28ea-4d18-8653-6515125acc1a + + + Activated + + ADIGOam.OAM + ADIGOAM.OAM + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936807 + + + ADIG_SRIOV_2 + ADIG_SRIOV_2 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936809 + + + ADIG_SRIOV_1 + ADIG_SRIOV_1 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936808 + + + + + FRN1 + 4027 + att-aic + + b73c6911-be64-448a-bb4b-7b7a7006507a + 5.0 + MOW AVPN vMX AV vPE Service + d48764b1-043d-4783-89e3-8817602dc833 + + 65001 + wl3900-1712-46db-99be-de9eb963a6cf26 + DE + vnfID-1712_26 + 26VRR_mtrnj151rv2 + + + 778c2ed5-77a8-426e-94fe-51a4d40199c4 + + + + cb510af0-5b21-4bc7-86d9-323cb396ced4 + + + c91330e5-8e1a-459b-95ee-d682046cbeca + 3 + MowAvpnVmxAvVpe..base_vRE_AV..module-0 + f9f41064-cbe7-4e94-ac4c-93d9c54af317 + + Activated + RR + FRNKGEFF + PROV + + NMLAN + 10.66.132.113 + 10.66.132.115 + 32 + EIPAM + + + 07bc0630-11d2-4c08-9c8f-75b036db1f4d + 3.0 + MOW AVPN vMX AV vPE + 31d077f6-356f-436e-b447-1997faff4c68 + + 31d077f6-356f-436e-b447-1997faff4c68 + + + ADIGOam.OAM + ADIGOAM.OAM + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936807 + + + ADIG_SRIOV_2 + ADIG_SRIOV_2 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936809 + + + ADIG_SRIOV_1 + ADIG_SRIOV_1 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936808 + + 1710vPEPROJECTS297135PROJECT + 26VRR_mtrnj151rv2-affinity + + + Completed + + + VNN1CA52LCP + skask + afd0f02a-1ddb-43bb-aded-5113e46e82ae + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + 33d209df14ac4c08ad60747185d2f3e0 + bd1b3789-6474-4935-94b2-90b656e035d0 + ZVNN1MOGX01 - VF AUG 1module-0 + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnf.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnf.xml new file mode 100644 index 0000000000..50e4347e5f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnf.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/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnfVfModule.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnfVfModule.xml new file mode 100644 index 0000000000..f60260d85b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/GenericVnfVfModule.xml @@ -0,0 +1,26 @@ + + a27ce5a9-29c4-4c22-a017-6615ac73c721 + STMTN5MMSC21 + mmsc-capacity + SDN-MOBILITY + vMMSC + pending-create + false + false + 0000021 + + + 973ed047-d251-4fb9-bf1a-65b8949e0a73 + STMTN5MMSC21-MMSC::module-0-0 + 973ed047-d251-4fb9-bf1a-65b8949e0a73 + 1.0 + true + FILLED-IN-BY-MSO + pending-create + 0000073 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/deactivateSDNCRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/deactivateSDNCRequest.xml new file mode 100644 index 0000000000..69884c5534 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/deactivateSDNCRequest.xml @@ -0,0 +1,36 @@ + + + testReqId + svcInstId_test + deactivate + vf-module-topology-operation + http://localhost:28080/mso/SDNCAdapterCallbackService + generic-resource + + + + testRequestId + DeleteVfModuleInstance + VID + + + + + + + + 12345 + + + + skask + + + + cb510af0-5b21-4bc7-86d9-323cb396ce32 + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/sdncAdapterWorkflowRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/sdncAdapterWorkflowRequest.xml new file mode 100644 index 0000000000..a03c28c91e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/sdncAdapterWorkflowRequest.xml @@ -0,0 +1,37 @@ + + + testReqId + cb510af0-5b21-4bc7-86d9-323cb396ce32 + delete + vnf-topology-operation + http://localhost:28080/mso/SDNCAdapterCallbackService + + + + testRequestId + DisconnectVNFRequest + VID + + + + + + 12345 + 12345 + 12345 + notsurewecare + + + cb510af0-5b21-4bc7-86d9-323cb396ce32 + PCRF::module-0-2 + PCRF::module-0-2 + skask + skask-test + vRRaas + RDM2WAGPLCP + fba1bd1e195a404cacb9ce17a9b2b421 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/vnfAdapterRestV1Request.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/vnfAdapterRestV1Request.xml new file mode 100644 index 0000000000..abb30b3c2c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleRollback/vnfAdapterRestV1Request.xml @@ -0,0 +1,14 @@ + + null + null + skask + cb510af0-5b21-4bc7-86d9-323cb396ce32 + null + true + + testRequestId + 12345 + + 12345-1513795852327 + http://localhost:18080/mso/WorkflowMessage/VNFAResponse/null-1513795852327 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeCallbackResponse.xml new file mode 100644 index 0000000000..a421355aba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeCallbackResponse.xml @@ -0,0 +1,53 @@ + + + {{MESSAGE-ID}} + true + d485ecee-957c-4a0a-8b95-27a22b90103f + + + mmsc_vol_1 + a73e0fe9-1ce8-49c2-8fef-e2788605be29 + + + mmsc_vol_2 + 37b6455a-5ea8-463a-89e3-0efeaf7b7c6d + + + nemsfe_vol_1 + b7ff1c21-d138-49a3-bf13-4cfd91efaf48 + + + nemsbe_vol_1 + a5988471-cd42-44d8-b078-64f2f13d3d4c + + + mmsc_vol_5 + f7b91c1e-ab8c-413a-a850-ba80a246c7e0 + + + nemsfe_vol_2 + 957ea3f3-2d4a-4707-bfd2-ba66f42037c2 + + + mmsc_vol_3 + de6fccfe-d61a-48b0-b03b-87bf1bf749b3 + + + mmsc_vol_4 + 76162310-2c38-4c32-981c-5c2880190077 + + + + RDM2WAGPLCP + e585e4f4-9452-437a-b294-45a2d6d3b7a3 + + c30b9453-4b68-4c2e-aacf-58a5ba648bf5 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + 1bbab536a19b4756926e7d0ec1eb543c + true + 78987 + ZRDM1MMSC01_base_vol/7f74e5e1-5fc1-4593-ac7e-cc9899a106ef + + ZRDM1MMSC01_base_vol/7f74e5e1-5fc1-4593-ac7e-cc9899a106ef + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml new file mode 100644 index 0000000000..38e8662787 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeNoRollbackRequest.xml @@ -0,0 +1,24 @@ + + + 123abc + d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 + CREATE_VF_MODULE_VOL + SoapUI-bns-create-base-vol-1001-1 + + + Test/vSAMP12 + vSAMP12::base::module-0 + false + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 897deadc2b954a6bac6d3c197fb3525e + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + + + + value1" + value2" + value3" + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml new file mode 100644 index 0000000000..62d1aba771 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/CreateVfModuleVolumeRequest.xml @@ -0,0 +1,24 @@ + + + 123abc + d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 + CREATE_VF_MODULE_VOL + SoapUI-bns-create-base-vol-1001-1 + + + Test/vSAMP12 + vSAMP12::base::module-0 + true + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 897deadc2b954a6bac6d3c197fb3525e + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + + + + value1" + value2" + value3" + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/GenericVnf.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/GenericVnf.xml new file mode 100644 index 0000000000..aea1a46017 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/GenericVnf.xml @@ -0,0 +1,38 @@ + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/RollbackVfModuleVolumeCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/RollbackVfModuleVolumeCallbackResponse.xml new file mode 100644 index 0000000000..6ab9416617 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/RollbackVfModuleVolumeCallbackResponse.xml @@ -0,0 +1,5 @@ + + + {{MESSAGE-ID}} + true + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json new file mode 100644 index 0000000000..6cc84c79b6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_VID_request.json @@ -0,0 +1,104 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL103W-vSAMP12_base_vol_module-0", + "source": "VID", + "callbackUrl": "{do we support this???}" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1" + } + } + }, + { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test/vSAMP12", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "backoutOnFailure": true, + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + { + "name": "vnfName", + "value": "STMTN5MMSC20" + }, + { + "name": "vnfName2", + "value": "US1117MTSNJVBR0246" + }, + { + "name": "vnfNmInformation", + "value": "" + }, + { + "name": "vnfType", + "value": "pcrf-capacity" + }, + { + "name": "vnfId", + "value": "skask" + }, + { + "name": "vnfStackId", + "value": "slowburn" + }, + { + "name": "vnfStatus", + "value": "created" + }, + { + "name": "aicCloudRegion", + "value": "MDTWNJ21" + }, + { + "name": "availabilityZone", + "value": "slcp3-esx-az01" + }, + { + "name": "oamNetworkName", + "value": "VLAN-OAM-1323" + }, + { + "name": "vmName", + "value": "slcp34246vbc246ceb" + }, + { + "name": "ipagNetworkId", + "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" + }, + { + "name": "vpeNetworkId", + "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" + } + ] + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..02b43ff186 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_createVolumeName_AAIResponse_Success.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + simpleCinderVolume_201604071 + simpleCinderVolume_201604071 + simpleCinderVolume_201604071 + simple_cinder_master + Pending + 1460134360 + + + tenant + https://aai-ext1.test.com:8443/aai/v6/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..1574310474 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_deleteVolumeName_AAIResponse_Success.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..5e8913f335 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_queryVolumeName_AAIResponse_Success.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + 8424bb3c-c3e7-4553-9662-469649ed9379 + MSOTESTVOL103W-vSAMP12_base_vol_module-0 + + simple_cinder_master + Pending + 1460134360 + + + tenant + https://aai-ext1.test.com:8443/aai/v6/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml new file mode 100644 index 0000000000..1574310474 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV1/createVfModuleVolume_updateVolumeName_AAIResponse_Success.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml new file mode 100644 index 0000000000..90c668c576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 2.5 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/vnfAdapterDeleteRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/vnfAdapterDeleteRequest.xml new file mode 100644 index 0000000000..fd6c228cba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModuleVolumeV2/vnfAdapterDeleteRequest.xml @@ -0,0 +1,13 @@ + + null + 12345 + 12345 + null + true + + 12345 + 12345 + + 580b5601-9260-4d19-abed-e671ac42c429 + http://localhost:18080/mso/WorkflowMessage/VNFAResponse/580b5601-9260-4d19-abed-e671ac42c429 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoCreateVfModule_getVnfResponse.xml new file mode 100644 index 0000000000..b8c2cfdad0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/getGenericVnfResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/getGenericVnfResponse.xml new file mode 100644 index 0000000000..be5130ead8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/getGenericVnfResponse.xml @@ -0,0 +1,28 @@ + + 6d2e2469-8708-47c3-a0d4-73fa28a8a50b + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + created + false + false + introvert + 2.0 + 0000020 + + + baseVfModuleId + PCRF::module-0-0 + introvert + 2.0 + false + baseVfModuleHeatStackId + Created + 0000074 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/sdncAdapterWorkflowRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/sdncAdapterWorkflowRequest.xml new file mode 100644 index 0000000000..9829fd2dbf --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoDeleteVfModule/sdncAdapterWorkflowRequest.xml @@ -0,0 +1,36 @@ + + + + testReqId + 12345 + release + vnf-topology-operation + http://localhost:8090/SDNCAdapterCallback + + + + 12345 + DisconnectVNFRequest + VID + + + + + + 12345 + 12345 + 123456789 + notsurewecare + + + 12345 + null + vfModuleName_test + 12345 + + + null + 19123c2924c648eb8e42a3c1f14b7682 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml new file mode 100644 index 0000000000..90c668c576 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + att-aic + RDM2WAGPLCP + 2.5 + RDM2WAGPLCP + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/getGenericVnfResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/getGenericVnfResponse.xml new file mode 100644 index 0000000000..be5130ead8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/getGenericVnfResponse.xml @@ -0,0 +1,28 @@ + + 6d2e2469-8708-47c3-a0d4-73fa28a8a50b + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + created + false + false + introvert + 2.0 + 0000020 + + + baseVfModuleId + PCRF::module-0-0 + introvert + 2.0 + false + baseVfModuleHeatStackId + Created + 0000074 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncActivateRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncActivateRequest.xml new file mode 100644 index 0000000000..6fa8bfedc9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncActivateRequest.xml @@ -0,0 +1,36 @@ + + + testReqId + MIS/1604/0026/SW_INTERNET + activate + vnf-topology-operation + http://localhost:8090/SDNCAdapter + + + + testRequestId + ChangeVNFActivateRequest + PORTAL + + + + + + 12345 + skask + dontcare + + + cb510af0-5b21-4bc7-86d9-323cb396ce32 + PCRF::module-0-2 + abc + skask + skask-test + vRRaas + fba1bd1e195a404cacb9ce17a9b2b421 + RDM2WAGPLCP + Y + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncChangeAssignRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncChangeAssignRequest.xml new file mode 100644 index 0000000000..c57dec4d86 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncChangeAssignRequest.xml @@ -0,0 +1,36 @@ + + + testReqId + MIS/1604/0026/SW_INTERNET + changeassign + vnf-topology-operation + http://localhost:8090/SDNCAdapter + + + + testRequestId + ChangeVNFActivateRequest + PORTAL + + + + + + 12345 + skask + dontcare + + + cb510af0-5b21-4bc7-86d9-323cb396ce32 + PCRF::module-0-2 + abc + skask + skask-test + vRRaas + fba1bd1e195a404cacb9ce17a9b2b421 + MDTWNJ21 + Y + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncGetResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncGetResponse.xml new file mode 100644 index 0000000000..20b5462729 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncGetResponse.xml @@ -0,0 +1,195 @@ + + + 2681784d-118e-4485-929f-2ae3212f5c07-1507707098467 + 200 + OK + + + + vnfID-1712_26 + + 200 + synccomplete + 2017-09-19T143942.327Z + Y + activate-vnf-request + + + + vRRaaS + vnfID-1712_26 + + + ae322537-d081-4a01-95a5-c1448116d0c5 + + + + + + frkde-esx-az01 + + + vrra + 1 + + ADIGOam.OAM + ADIGOAM.OAM + + NMLAN + 10.66.132.113 + 10.66.132.115 + 32 + EIPAM + + VPEADIG1d77c-1086-41ec-b7f3-94bb30936807 + + + ADIG_SRIOV_1 + ADIG_SRIOV_1 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936808 + [,] + + + ADIG_SRIOV_2 + ADIG_SRIOV_2 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936809 + [,] + + + Internal-Network1 + + INTERNAL + 24 + OTHER + 128.0.0.1 + 128.0.0.0 + + VRR-STMTN5MMSC20-INT1 + 12 + VMX-INT1 + + + Internal-Network2 + + INTERNAL + 24 + OTHER + 128.0.0.1 + 128.0.0.0 + + VRR-STMTN5MMSC20-INT2 + 12 + VMX-INT2 + + + frkdevRvrra24 + b05a42c3-28ea-4d18-8653-6515125acc1a + + + Activated + + ADIGOam.OAM + ADIGOAM.OAM + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936807 + + + ADIG_SRIOV_2 + ADIG_SRIOV_2 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936809 + + + ADIG_SRIOV_1 + ADIG_SRIOV_1 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936808 + + + + + FRN1 + 4027 + att-aic + + b73c6911-be64-448a-bb4b-7b7a7006507a + 5.0 + MOW AVPN vMX AV vPE Service + d48764b1-043d-4783-89e3-8817602dc833 + + 65001 + wl3900-1712-46db-99be-de9eb963a6cf26 + DE + vnfID-1712_26 + 26VRR_mtrnj151rv2 + + + 778c2ed5-77a8-426e-94fe-51a4d40199c4 + + + + cb510af0-5b21-4bc7-86d9-323cb396ced4 + + + c91330e5-8e1a-459b-95ee-d682046cbeca + 3 + MowAvpnVmxAvVpe..base_vRE_AV..module-0 + f9f41064-cbe7-4e94-ac4c-93d9c54af317 + + Activated + RR + FRNKGEFF + PROV + + NMLAN + 10.66.132.113 + 10.66.132.115 + 32 + EIPAM + + + 07bc0630-11d2-4c08-9c8f-75b036db1f4d + 3.0 + MOW AVPN vMX AV vPE + 31d077f6-356f-436e-b447-1997faff4c68 + + 31d077f6-356f-436e-b447-1997faff4c68 + + + ADIGOam.OAM + ADIGOAM.OAM + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936807 + + + ADIG_SRIOV_2 + ADIG_SRIOV_2 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936809 + + + ADIG_SRIOV_1 + ADIG_SRIOV_1 + 491c7cef-a3f4-4990-883e-b0af397466d0 + VPEADIG1d77c-1086-41ec-b7f3-94bb30936808 + + 1710vPEPROJECTS297135PROJECT + 26VRR_mtrnj151rv2-affinity + + + Completed + + + VNN1CA52LCP + skask + afd0f02a-1ddb-43bb-aded-5113e46e82ae + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + 33d209df14ac4c08ad60747185d2f3e0 + bd1b3789-6474-4935-94b2-90b656e035d0 + ZVNN1MOGX01 - VF AUG 1module-0 + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncTopologyRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncTopologyRequest.xml new file mode 100644 index 0000000000..79ab33d45c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/sdncTopologyRequest.xml @@ -0,0 +1,11 @@ + + + testReqId + MIS/1604/0026/SW_INTERNET + query + /VNF-API:vnfs/vnf-list/12345 + http://localhost:8090/SDNCAdapter + mobility + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/vnfAdapterRestRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/vnfAdapterRestRequest.xml new file mode 100644 index 0000000000..d9268872b3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/DoUpdateVfModule/vnfAdapterRestRequest.xml @@ -0,0 +1,170 @@ + + RDM2WAGPLCP + fba1bd1e195a404cacb9ce17a9b2b421 + skask + cb510af0-5b21-4bc7-86d9-323cb396ce32 + abc + vRRaas + 1.0 + cb510af0-5b21-4bc7-86d9-323cb396ced3 + PCRF::module-0-2 + 12345 + 12345 + 12345 + 12345 + true + 12345 + false + + + vf_module_id + cb510af0-5b21-4bc7-86d9-323cb396ce32 + + + vrra_Internal-Network1_ips + null + + + ADIG_SRIOV_2_subnet_id + + + + vrra_ADIGOam.OAM_v6_ips + null + + + vnf_name + skask-test + + + ADIGOam.OAM_v6_subnet_id + + + + workload_context + null + + + vf_module_name + PCRF::module-0-2 + + + vnf_id + skask + + + ADIG_SRIOV_2_v6_subnet_id + + + + vrra_ADIG_SRIOV_1_ips + null + + + ADIG_SRIOV_1_v6_subnet_id + + + + ADIG_SRIOV_1_subnet_id + + + + vrr_flavor_name + ns.c16r32d128.v1 + + + ADIG_SRIOV_2_net_name + ADIG_SRIOV_2 + + + ADIGOam.OAM_subnet_id + + + + ADIGOam.OAM_net_id + 491c7cef-a3f4-4990-883e-b0af397466d0 + + + environment_context + null + + + ADIG_SRIOV_1_net_fqdn + + + + ADIGOam.OAM_net_name + ADIGOAM.OAM + + + vrra_name_0 + frkdevRvrra24 + + + vrra_ADIG_SRIOV_2_ips + null + + + ADIG_SRIOV_2_net_fqdn + + + + vrra_Internal-Network2_ips + null + + + ADIG_SRIOV_1_net_name + ADIG_SRIOV_1 + + + vrra_ADIG_SRIOV_1_v6_ips + null + + + vrra_ADIGOam.OAM_ips + null + + + vrra_Internal-Network1_v6_ips + null + + + vrr_image_name + MDT17 + + + ADIGOam.OAM_net_fqdn + + + + vrra_names + frkdevRvrra24 + + + ADIG_SRIOV_1_net_id + 491c7cef-a3f4-4990-883e-b0af397466d0 + + + vrra_Internal-Network2_v6_ips + null + + + vrra_ADIG_SRIOV_2_v6_ips + null + + + ADIG_SRIOV_2_net_id + 491c7cef-a3f4-4990-883e-b0af397466d0 + + + availability_zone_0 + nova + + + + testRequestId + MIS/1604/0026/SW_INTERNET + + testRequestId-1503410089303-1513287018300 + http://localhost:28080/mso/WorkflowMesssage/VNFAResponse/testRequestId-1503410089303-1513287018300 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/MsoCompletionRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/MsoCompletionRequest.xml new file mode 100644 index 0000000000..d5175f4dc9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/MsoCompletionRequest.xml @@ -0,0 +1,11 @@ + + + null + DELETE + null + + E2E Service Instance was deleted successfully. + DeleteCustomE2EServiceInstance + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/SDNCDeleteResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/SDNCDeleteResponse.xml new file mode 100644 index 0000000000..e380ce7ed2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/SDNCDeleteResponse.xml @@ -0,0 +1,212 @@ + + + + + + Y + SK-2016-10-22-001 + + + SUCCESS + ERROR + + + 15001417 + + ALPRTR2 + 1.1.1.2 + + 1255.ae81 + VDBE + VIRTUAL + + ALPVDBE1 + 3.1.1.0/22 + ae81 + 3:1:1::0/22 + + + 1995.ae81 + ASBG + VIRTUAL + + ALPASBG1 + 3.1.1.0/22 + ae81 + 3:1:1::0/22 + + + 85.xe-10/0/2 + BGF2 + PHYSICAL + xe-10/0/2 + ALPBGF2 + 3.1.2.0/22 + + 3:1:2::0/22 + + + 85.xe-10/0/1 + BGF1 + PHYSICAL + xe-10/0/1 + ALPBGF1 + 3.1.2.0/22 + + 3:1:2::0/22 + + 2 + + + ALPRTR1 + 1.1.1.1 + + 1255.ae81 + VDBE + VIRTUAL + + ALPVDBE1 + 3.1.1.0/22 + ae81 + 3:1:1::0/22 + + + 1995.ae81 + ASBG + VIRTUAL + + ALPASBG1 + 3.1.1.0/22 + ae81 + 3:1:1::0/22 + + + 85.xe-10/0/2 + BGF2 + PHYSICAL + xe-10/0/2 + ALPBGF2 + 3.1.2.0/22 + + 3:1:2::0/22 + + + 85.xe-10/0/1 + BGF1 + PHYSICAL + xe-10/0/1 + ALPBGF1 + 3.1.2.0/22 + + 3:1:2::0/22 + + 1 + + + + 15001418 + + SANRTR1 + 2.1.1.1 + + 1255.ae81 + VDBE + VIRTUAL + + SANVDBE1 + 4.1.1.0/22 + ae81 + 4:1:1::0/22 + + + 1995.ae81 + ASBG + VIRTUAL + + SANASBG1 + 4.1.1.0/22 + ae81 + 4:1:1::0/22 + + + 85.xe-10/0/2 + BGF2 + PHYSICAL + xe-10/0/2 + SANBGF2 + 4.1.2.0/22 + + 4:1:2::0/22 + + + 85.xe-10/0/1 + BGF1 + PHYSICAL + xe-10/0/1 + SANBGF1 + 4.1.2.0/22 + + 4:1:2::0/22 + + 1 + + + SANRTR2 + 2.1.1.2 + + 1255.ae81 + VDBE + VIRTUAL + + SANVDBE1 + 4.1.1.0/22 + ae81 + 4:1:1::0/22 + + + 1995.ae81 + ASBG + VIRTUAL + + SANASBG1 + 4.1.1.0/22 + ae81 + 4:1:1::0/22 + + + 85.xe-10/0/2 + BGF2 + PHYSICAL + xe-10/0/2 + SANBGF2 + 4.1.2.0/22 + + 4:1:2::0/22 + + + 85.xe-10/0/1 + BGF1 + PHYSICAL + xe-10/0/1 + SANBGF1 + 4.1.2.0/22 + + 4:1:2::0/22 + + 2 + + + COLLABORATE + DISABLE + custid-888 + SII-2016-10-22-001 + CUSTOMER + 100668 + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/aaiGetResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/aaiGetResponse.xml new file mode 100644 index 0000000000..c367b5c959 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/aaiGetResponse.xml @@ -0,0 +1,33 @@ + + 1234 + volte-service + testservicetype + testservicerole + volte service + c1d4305f-cdbd-4bbe-9069-a2f4978fd89e + d4df5c27-98a1-4812-a8aa-c17f055b7a3f + 1508838121849 + create + + + service-instance + /aai/v11/business/customers/customer/test_customer/service-subscription/example-service-type/service-instance/1234_1 + + customer.global-customer-id + test_customer + + + service-subscription.service-type + test_customer + + + service-instance.service-instance-id + 1234_1 + + + service-instance.service-instance-name + volte-service_vEPC + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getARUrlById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getARUrlById.xml new file mode 100644 index 0000000000..e178583a34 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getARUrlById.xml @@ -0,0 +1,6 @@ + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml new file mode 100644 index 0000000000..a472996121 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfByNameResponse.xml @@ -0,0 +1,23 @@ + + + 2f1cc940-455f-4ee2-9411-a7899cd4f124 + testVnfName123 + mmsc-capacity + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + vMMSC + pending-create + testReVer123 + + + nothing + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/ + + l3-network.network-id + c597ab81-fece-49f4-a4f5-710cebb13c29 + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml new file mode 100644 index 0000000000..8ba178cc1c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse.xml @@ -0,0 +1,90 @@ + + + 2f1cc940-455f-4ee2-9411-a7899cd4f124 + testVnfName123 + mmsc-capacity + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + vMMSC + pending-create + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/ + + l3-network.network-id + c597ab81-fece-49f4-a4f5-710cebb13c29 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/ + + l3-network.network-id + 53956c91-6e5e-49aa-88dd-535f57e66e70 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/ + + l3-network.network-id + 44e0d9e0-9334-4ec6-9344-07a96dac629f + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/ + + l3-network.network-id + ac49d99b-5daf-4624-9f8e-188b126ea166 + + + + + + + + 802767b3-18a6-4432-96db-25522786aee0 + ZRDM1MMSC03 + mmsc-capacity + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + vMMSC + pending-create + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/ + + l3-network.network-id + c597ab81-fece-49f4-a4f5-710cebb13c29 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/ + + l3-network.network-id + 53956c91-6e5e-49aa-88dd-535f57e66e70 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/ + + l3-network.network-id + 44e0d9e0-9334-4ec6-9344-07a96dac629f + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/ + + l3-network.network-id + ac49d99b-5daf-4624-9f8e-188b126ea166 + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml new file mode 100644 index 0000000000..8ba178cc1c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getGenericVnfResponse_hasRelationships.xml @@ -0,0 +1,90 @@ + + + 2f1cc940-455f-4ee2-9411-a7899cd4f124 + testVnfName123 + mmsc-capacity + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + vMMSC + pending-create + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/ + + l3-network.network-id + c597ab81-fece-49f4-a4f5-710cebb13c29 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/ + + l3-network.network-id + 53956c91-6e5e-49aa-88dd-535f57e66e70 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/ + + l3-network.network-id + 44e0d9e0-9334-4ec6-9344-07a96dac629f + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/ + + l3-network.network-id + ac49d99b-5daf-4624-9f8e-188b126ea166 + + + + + + + + 802767b3-18a6-4432-96db-25522786aee0 + ZRDM1MMSC03 + mmsc-capacity + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + vMMSC + pending-create + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/c597ab81-fece-49f4-a4f5-710cebb13c29/ + + l3-network.network-id + c597ab81-fece-49f4-a4f5-710cebb13c29 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/53956c91-6e5e-49aa-88dd-535f57e66e70/ + + l3-network.network-id + 53956c91-6e5e-49aa-88dd-535f57e66e70 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/44e0d9e0-9334-4ec6-9344-07a96dac629f/ + + l3-network.network-id + 44e0d9e0-9334-4ec6-9344-07a96dac629f + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/ac49d99b-5daf-4624-9f8e-188b126ea166/ + + l3-network.network-id + ac49d99b-5daf-4624-9f8e-188b126ea166 + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getNotFound.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getNotFound.xml new file mode 100644 index 0000000000..f66c9c4fb8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getNotFound.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentSIUrlById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentSIUrlById.xml new file mode 100644 index 0000000000..c29133e539 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentSIUrlById.xml @@ -0,0 +1,6 @@ + + + service-instance + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0027%252FSW_INTERNET + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentServiceInstance.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentServiceInstance.xml new file mode 100644 index 0000000000..bc810c6014 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getParentServiceInstance.xml @@ -0,0 +1,30 @@ + + MIS/1604/0027/SW_INTERNET + 123456789 + + + cvlan-tag + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/ + + cvlan-tag.cvlan-tag + 2003 + + + port-group.interface-id + slcp1447vbc.ipag + + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + vce + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSINoRelations.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSINoRelations.xml new file mode 100644 index 0000000000..e52b26ac00 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlById.xml new file mode 100644 index 0000000000..416689e10c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlById.xml @@ -0,0 +1,6 @@ + + + service-instance + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getSIUrlByIdVipr.xml new file mode 100644 index 0000000000..28c739a0af --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getServiceInstance.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getServiceInstance.xml new file mode 100644 index 0000000000..e377c70474 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/GenericFlows/getServiceInstance.xml @@ -0,0 +1,30 @@ + + MIS/1604/0026/SW_INTERNET + 123456789 + + + cvlan-tag + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/ + + cvlan-tag.cvlan-tag + 2003 + + + port-group.interface-id + slcp1447vbc.ipag + + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + vce + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ConfigVnf_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ConfigVnf_VID_request.json new file mode 100644 index 0000000000..04040028c3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ConfigVnf_VID_request.json @@ -0,0 +1,39 @@ +{ +"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": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"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": { +"payload": "{\"request-parameters\":{\"host-ip-address\":\"10.10.10.10\"},\"configuration- parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}" +} +} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json new file mode 100644 index 0000000000..c1491d128b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/CreateVnfInfraRequest.json @@ -0,0 +1,46 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelInstanceName": "vSAMP12 1", + "modelCustomizationUuid": "customizationId123" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "testVnfName123", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{serviceInstanceId}", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1.0" + } + } + } + ], + "requestParameters": { + }, + "platform": { + "platformName": "platform name" + }, + "lineOfBusiness": { + "lineOfBusinessName": "line of business names" + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteCustomE2EService.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteCustomE2EService.json new file mode 100644 index 0000000000..661a89ec99 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteCustomE2EService.json @@ -0,0 +1,21 @@ +{ + "requestDetails": { + "requestInfo": { + "callbackUrl": "http://localhost:28080/simulada/CCD/AsyncRequestStatus", + "source": "CCD", + "instanceName": "USOSTCDALTX0101VFHN31" + }, + "subscriberInfo": { + "globalSubscriberId": "38829939920000", + "subscriberName": "Fern Hill Real Estate LLC 31" + }, + "requestParameters": { + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + } + ] + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json new file mode 100644 index 0000000000..e8d9fc29b1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DeleteVnfInfraRequestCascadeDelete.json @@ -0,0 +1,39 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelInstanceName": "vSAMP12 1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "testVnfName123", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{serviceInstanceId}", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "{parent service model name}", + "modelVersion": "1.0" + } + } + } + ], + "requestParameters": { + "cascadeDelete": true + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoCreateServiceInstance_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoCreateServiceInstance_request.json new file mode 100644 index 0000000000..640e16b634 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoCreateServiceInstance_request.json @@ -0,0 +1,186 @@ +{ "serviceResources" : { + "modelInfo" : { + "modelName" : "MSOTADevInfra_vSAMP10a_Service", + "modelUuid" : "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantUuid" : "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion" : "1.0" + }, + "serviceType" : "PortMirroring", + "serviceRole" : "InfraRole", + "environmentContext" : "Luna", + "workloadContext" : "Oxygen", + "serviceVnfs": [ + + { "modelInfo" : { + "modelName" : "vSAMP10a", + "modelUuid" : "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUuid" : "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "68dc9a92-214c-11e7-93ae-92361f002671", + "modelInstanceName" : "vSAMP10a 1" + }, + "toscaNodeType" : "VF", + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null, + "multiStageDesign" : null, + "vfModules": [ + { + "modelInfo" : { + "modelName" : "NetworkFqdnTest4", + "modelUuid" : "025606c1-4223-11e7-9252-005056850d2e", + "modelInvariantUuid" : "06bd0a18-65c0-4418-83c7-5b0d13cba01a", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "06bd0a18-65c0-4418-83c7-5b0d13cba01a" + }, "isBase" : true, + "vfModuleLabel" : "label", + "initialCount" : 0, + "hasVolumeGroup" : true + }, + { + "modelInfo" : { + "modelName" : "NetworkFqdnTest3", + "modelUuid" : "02560575-4223-11e7-9252-005056850d2e", + "modelInvariantUuid" : "06bd0a18-65c0-4418-83c7-5b0d13cba0bb", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "06bd0a18-65c0-4418-83c7-5b0d13cba0bb" + }, "isBase" : true, + "vfModuleLabel" : "label", + "initialCount" : 0, + "hasVolumeGroup" : false + }, + { + "modelInfo" : { + "modelName" : "NetworkFqdnTest5", + "modelUuid" : "025607e4-4223-11e7-9252-005056850d2e", + "modelInvariantUuid" : "06bd0a18-65c0-4418-83c7-5b0d14cba01a", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "06bd0a18-65c0-4418-83c7-5b0d14cba01a" + }, "isBase" : false, + "vfModuleLabel" : "label", + "initialCount" : 0, + "hasVolumeGroup" : false + }, + { + "modelInfo" : { + "modelName" : "vSAMP10aDEV::PCM::module-2", + "modelUuid" : "7774b4e4-7d37-11e7-bb31-be2e44b06b34", + "modelInvariantUuid" : "93e9c1d2-7d37-11e7-bb31-be2e44b06b34", + "modelVersion" : "2", + "modelCustomizationUuid" : "6728bee8-7d3a-11e7-bb31-be2e44b06b34" + }, "isBase" : false, + "vfModuleLabel" : "PCM", + "initialCount" : 0, + "hasVolumeGroup" : true + }, + { + "modelInfo" : { + "modelName" : "vSAMP10aDEV::PCM::module-1", + "modelUuid" : "066de97e-253e-11e7-93ae-92361f002671", + "modelInvariantUuid" : "64efd51a-2544-11e7-93ae-92361f002671", + "modelVersion" : "2", + "modelCustomizationUuid" : "b4ea86b4-253f-11e7-93ae-92361f002671" + }, "isBase" : false, + "vfModuleLabel" : "PCM", + "initialCount" : 0, + "hasVolumeGroup" : true + }, + { + "modelInfo" : { + "modelName" : "vSAMP10aDEV::base::module-0", + "modelUuid" : "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantUuid" : "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion" : "2", + "modelCustomizationUuid" : "cb82ffd8-252a-11e7-93ae-92361f002671" + }, "isBase" : true, + "vfModuleLabel" : "base", + "initialCount" : 1, + "hasVolumeGroup" : true + }, + { + "modelInfo" : { + "modelName" : "vSAMP10a::base::module-0", + "modelUuid" : "02560de2-4223-11e7-9252-005056850d2e", + "modelInvariantUuid" : null, + "modelVersion" : "2", + "modelCustomizationUuid" : "MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4" + }, "isBase" : true, + "vfModuleLabel" : "base", + "initialCount" : 1, + "hasVolumeGroup" : true + }, + { + "modelInfo" : { + "modelName" : "base::module-0", + "modelUuid" : "02561381-4223-11e7-9252-005056850d2e", + "modelInvariantUuid" : null, + "modelVersion" : "1", + "modelCustomizationUuid" : "MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5" + }, "isBase" : true, + "vfModuleLabel" : "module-0", + "initialCount" : 1, + "hasVolumeGroup" : false + }, + { + "modelInfo" : { + "modelName" : "vSAMP10a::PCM::module-1", + "modelUuid" : "02560f1b-4223-11e7-9252-005056850d2e", + "modelInvariantUuid" : null, + "modelVersion" : "1", + "modelCustomizationUuid" : "MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8" + }, "isBase" : true, + "vfModuleLabel" : "PCM", + "initialCount" : 1, + "hasVolumeGroup" : true + } + ] + } + ], + "serviceNetworks": [], + "serviceAllottedResources": [ + { + "modelInfo" : { + "modelName" : "Tunnel_Xconn", + "modelUuid" : "f6b7d4c6-e8a4-46e2-81bc-31cad5072842", + "modelInvariantUuid" : "b7a1b78e-6b6b-4b36-9698-8c9530da14af", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "5b9bee43-f537-4fb3-9e8b-4de9f714d28a", + "modelInstanceName" : "Pri_Tunnel_Xconn 9" + }, + "toscaNodeType" : null, + "allottedResourceType" : null, + "allottedResourceRole" : null, + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null + } + ], + "serviceConfigs": [ + { + "modelInfo" : { + "modelName" : "Mulder", + "modelUuid" : "025606c1-4fff-11e7-9252-005056850d2e", + "modelInvariantUuid" : "025606c1-4eee-11e7-9252-005056850d2e", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "025606c1-4ddd-11e7-9252-005056850d2e", + "modelInstanceName" : "X_FILES_001" + }, + "toscaNodeType" : "Scully" + }, + { + "modelInfo" : { + "modelName" : "Krychuk", + "modelUuid" : "025606c1-5fff-11e7-9252-005056850d2e", + "modelInvariantUuid" : "025606c1-5eee-11e7-9252-005056850d2e", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "025606c1-5ddd-11e7-9252-005056850d2e", + "modelInstanceName" : "X_FILES_002" + }, + "toscaNodeType" : "Skinner" + } + ] + }} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoScaleE2EServiceInstance.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoScaleE2EServiceInstance.json new file mode 100644 index 0000000000..dd3ff6841e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/DoScaleE2EServiceInstance.json @@ -0,0 +1,38 @@ +{ + "service": + { + "serviceType":"example-service-type", + "globalSubscriberId":"test_custormer", + "resources": + [ + { + "resourceInstanceId":"ns111", + "scaleType":"SCALE_NS", + "scaleNsData": + { + "scaleNsByStepsData": + { + "numberOfSteps":"4", + "aspectId":"TIC_EDGE_HW", + "scalingDirection":"UP" + } + } + }, + { + "resourceInstanceId":"ns333", + "scaleType":"SCALE_NS", + "scaleNsData": + { + "scaleNsByStepsData": + { + "numberOfSteps":"4", + "aspectId":"TIC_EDGE_HW", + "scalingDirection":"UP" + } + } + } + ], + "serviceInstanceName":"service1" + }, + "operationId":"15c01683-4f15-45e7-b213-dcbfe6f42a1b" + } \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/ReplaceVnf_VID_request.json new file mode 100644 index 0000000000..7c9717244b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json new file mode 100644 index 0000000000..9564f705ae --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVfModule_VID_request.json @@ -0,0 +1,62 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelInvariantUuid": "introvert", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "STMTN5MMSC21-MMSC::model-1-0", + "modelVersion": "1", + "modelCustomizationUuid": "MODEL12345" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "MDTWNJ21", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "PCRF::module-0", + "instanceId": "supercool", + "source": "VID", + "suppressRollback": true + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "123456", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "SERVICE_MODEL_NAME", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "skask", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "skask", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "modelInstanceName": "vSAMP12 1" + } + } + } + ], + "requestParameters": { + "usePreload": false, + "userParams": [ + { + "name": "someUserParam", + "value": "someValue" + }, + { + "name": "sgi_protected_subnet_id", + "value": "thisissomefakevalue" + } + ] + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json new file mode 100644 index 0000000000..5ce8546a41 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/UpdateVnf_VID_request.json @@ -0,0 +1,56 @@ +{ +"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": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"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" + }, + { + "name": "vlc_sctp_b_route_prefixes", + "value": [ + { "interface_route_table_routes_route_prefix": "107.239.41.163/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.164/32" }, + { "interface_route_table_routes_route_prefix": "107.239.41.165/32" } + ]} +] +} +} +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json new file mode 100644 index 0000000000..eb2d9faa2a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json @@ -0,0 +1,16 @@ +{ +"requestDetails": { +"cloudConfiguration": { +"lcpCloudRegionId": "mdt1", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"source": "VID", +"requestorId": "xxxxxx" +}, +"requestParameters": { +"payload": +"{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" +} +} +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json new file mode 100644 index 0000000000..7b369ab97e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json @@ -0,0 +1,70 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelVersion": "10" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "{some project name}" + }, + "subscriberInfo": { + "globalSubscriberId": "{some subscriber id}" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "xxxxxx" + }, + "requestParameters": { + "subscriptionServiceType": "VMX", + "aLaCarte": false, + "userParams": [ + { + "service": { + "modelInfo": { + "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" + }, + "instanceParams": [], + "resources": { + "networks": [ + { + "modelInfo": { + "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", + "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf970" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + } + }, + { + "modelInfo": { + "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", + "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf970" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + } + } + ] + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json new file mode 100644 index 0000000000..51caddd48a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json @@ -0,0 +1,125 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelVersion": "10.0" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "{some project name}" + }, + "subscriberInfo": { + "globalSubscriberId": "{some subscriber id}" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "xxxxxx" + }, + "requestParameters": { + "subscriptionServiceType": "VMX", + "aLaCarte": false, + "userParams": [ + { + "service": { + "modelInfo": { + "modelType": "service", + "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" + }, + "instanceParams": [], + "resources": { + "vnfs": [ + { + "modelInfo": { + "modelType": "vnf", + "modelName": "2016-73_MOW-AVPN-vPE-BV-L", + "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8", + "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0", + "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "platform": { + "platformName": "test" + }, + "lineOfBusiness": { + "lineOfBusinessName": "someValue" + }, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "instanceParams": [], + "vfModules": [ + { + "modelInfo": { + "modelType": "vfModule", + "modelName": "201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0", + "modelVersionId": "4c75f813-fa91-45a4-89d0-790ff5f1ae79", + "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f" + }, + "instanceParams": [ + { + "vmx_int_net_len": "24" + } + ] + }, + { + "modelInfo": { + "modelType": "vfModule", + "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", + "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240", + "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8" + }, + "instanceParams": [ + { + "availability_zone_0": "mtpocdv-kvm-az01", + "vre_a_volume_size_0": "100" + } + ] + }, + { + "modelInfo": { + "modelType": "vfModule", + "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", + "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240", + "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8" + }, + "instanceParams": [ + { + "availability_zone_0": "mtpocdv-kvm-az01", + "vre_a_volume_size_0": "50" + } + ] + }, + { + "modelInfo": { + "modelType": "vfModule", + "modelName": "201673MowAvpnVpeBvL..AVPN_vPFE_BV..module-2", + "modelVersionId": "f555558f-d538-4876-8ffa-b102650fad64", + "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf969" + }, + "instanceParams": [ + { + "availability_zone_0": "mtpocdv-kvm-az01", + "vmx_vpfe_int_ip_0": "192.168.0.16" + } + ] + } + ] + } + ] + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policyAbortResponse.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policyAbortResponse.json new file mode 100644 index 0000000000..c315b1ed1d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policyAbortResponse.json @@ -0,0 +1 @@ +{"decision":"PERMIT","details":"Abort"} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policySkipResponse.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policySkipResponse.json new file mode 100644 index 0000000000..7cbdebb6b3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Policy/policySkipResponse.json @@ -0,0 +1 @@ +{"decision":"PERMIT","details":"Skip"} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateServiceInstance.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateServiceInstance.json new file mode 100644 index 0000000000..5a6460b62d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateServiceInstance.json @@ -0,0 +1,7 @@ +{ + "ActivateServiceInstance": { + "serviceInstance": { + "@class": "inventory.aai.onap.org.v12.ServiceInstance" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateVnfSchema.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateVnfSchema.json new file mode 100644 index 0000000000..57ab9c2799 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/ActivateVnfSchema.json @@ -0,0 +1,13 @@ +{ + "ActivateVnf": { + "serviceInstance": { + "@class": "inventory.aai.onap.org.v12.ServiceInstance" + }, + "customer": { + "@class": "inventory.aai.onap.org.v12.Customer" + }, + "genericVnf": { + "@class": "inventory.aai.onap.org.v12.GenericVnf" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignServiceInstanceSchema.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignServiceInstanceSchema.json new file mode 100644 index 0000000000..7c35761461 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignServiceInstanceSchema.json @@ -0,0 +1,16 @@ +{ + "AssignServiceInstance": { + "serviceInstance": { + "@class": "inventory.aai.onap.org.v12.ServiceInstance" + }, + "project": { + "@class": "inventory.aai.onap.org.v12.Project" + }, + "owningEntity": { + "@class": "inventory.aai.onap.org.v12.OwningEntity" + }, + "customer": { + "@class": "inventory.aai.onap.org.v12.Customer" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignVnfSchema.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignVnfSchema.json new file mode 100644 index 0000000000..7fff5ca3ce --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Schemas/AssignVnfSchema.json @@ -0,0 +1,13 @@ +{ + "AssignVnf": { + "serviceInstance": { + "@class": "inventory.aai.onap.org.v12.ServiceInstance" + }, + "customer": { + "@class": "inventory.aai.onap.org.v12.Customer" + }, + "genericVnf": { + "@class": "inventory.aai.onap.org.v12.GenericVnf" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/sdncUpdateNetworkTopologySimResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/sdncUpdateNetworkTopologySimResponse.xml new file mode 100644 index 0000000000..836b3c8055 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/sdncUpdateNetworkTopologySimResponse.xml @@ -0,0 +1,17 @@ + + + + + + + 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/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml new file mode 100644 index 0000000000..a5640b2b26 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_400.xml @@ -0,0 +1,6 @@ + + +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 + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml new file mode 100644 index 0000000000..02996a13ea --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_500.xml @@ -0,0 +1,80 @@ + + + JBoss Web/7.2.2.Final-redhat-1 - JBWEB000064: Error report + + + + +

JBWEB000065: HTTP Status 500 - java.lang.NullPointerException

+
+

+ JBWEB000309: type + JBWEB000066: Exception report +

+

+ JBWEB000068: message + java.lang.NullPointerException +

+

+ JBWEB000069: description + JBWEB000145: The server encountered an internal error that + prevented it from fulfilling this request. + +

+

+ JBWEB000070: exception +

org.jboss.resteasy.spi.UnhandledException:
+				java.lang.NullPointerException
+				org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365)
+				org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233)
+				org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209)
+				org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
+				org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
+				javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
+				org.onap.so.logger.LogFilter.doFilter(LogFilter.java:35)
+			
+

+

+ JBWEB000071: root cause +

java.lang.NullPointerException
+				org.onap.so.adapters.network.NetworkAdapterRest$CreateNetworkVolumesTask.run(NetworkAdapterRest.java:128)
+				org.onap.so.adapters.network.NetworkAdapterRest.createNetwork(NetworkAdapterRest.java:64)
+				sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+				sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
+				sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+				java.lang.reflect.Method.invoke(Method.java:606)
+				org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
+				org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
+				org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
+				org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
+				org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
+				org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
+				javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
+				org.onap.so.logger.LogFilter.doFilter(LogFilter.java:35)
+			
+

+

+ JBWEB000072: note + JBWEB000073: The full stack trace of the root cause is available + in the JBoss Web/7.2.2.Final-redhat-1 logs. + +

+
+

JBoss Web/7.2.2.Final-redhat-1

+ + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml new file mode 100644 index 0000000000..0faec794b0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetworkResponse_Success.xml @@ -0,0 +1,24 @@ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + + 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 + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml new file mode 100644 index 0000000000..ca5145c226 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryInstance_Success.xml @@ -0,0 +1,4 @@ + + service-instance + https://aai-conexus-e2e.test.com:8443/aai/v8/business/customers/customer/8310000058863/service-subscriptions/service-subscription/vMOG/service-instances/service-instance/f70e927b-6087-4974-9ef8-c5e4d5847ca4 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml new file mode 100644 index 0000000000..e06d27ea88 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml @@ -0,0 +1,73 @@ + + + 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 + + + + + 413 + 4132176 + + + + 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 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml new file mode 100644 index 0000000000..24ee1df9c8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + 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 + + + + + 413 + 4132176 + + + + 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 + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..79cc14ada3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + 13979:105757 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml new file mode 100644 index 0000000000..db134a1127 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 5938baec-03ca-2bd5-a3f1-d54x123e253a + refFQDN1 + 12345 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml new file mode 100644 index 0000000000..34b4a036c4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 5938baec-03ca-2bd5-a3f1-d54x123e253a + refFQDN2 + 12345 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml new file mode 100644 index 0000000000..c01d0a4f61 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + + + 13979:105708 + EXPORT + 1504025599510 + + + 13979:105707 + IMPORT + 1504025599519 + + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v8/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/v8/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/v8/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml new file mode 100644 index 0000000000..5f1c2cafa5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v8/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/v8/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/v8/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml new file mode 100644 index 0000000000..eedbda9343 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml new file mode 100644 index 0000000000..03d63f9f05 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml @@ -0,0 +1,44 @@ + + + 78987 + MSOTESTVOL102a-vSAMP12_base_vol_module-0 + + Test/vSAMP12 + Pending + 0000020 + + + tenant + /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 + /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 + + + vf-module.vf-module-id + 6a1dc898-b590-47b9-bbf0-34424a7a2ec3 + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json new file mode 100644 index 0000000000..603c1f452f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json @@ -0,0 +1,64 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test/vSAMP12", + "modelVersion": "1", + "modelInstanceName": "vSAMP12" + } + } + } + ], + "requestParameters": { + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + {"name": "vnfName", "value": "STMTN5MMSC20" }, + {"name": "vnfName2", "value": "US1117MTSNJVBR0246" }, + {"name": "vnfNmInformation", "value": "" }, + {"name": "vnfType", "value": "pcrf-capacity" }, + {"name": "vnfId", "value": "skask" }, + {"name": "vnfStackId", "value": "slowburn" }, + {"name": "vnfStatus", "value": "created" }, + {"name": "aicCloudRegion", "value": "MDTWNJ21" }, + {"name": "availabilityZone", "value": "slcp3-esx-az01" }, + {"name": "oamNetworkName", "value": "VLAN-OAM-1323" }, + {"name": "vmName", "value": "slcp34246vbc246ceb" }, + {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" }, + {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" } + ] + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json new file mode 100644 index 0000000000..f32ba2994b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json @@ -0,0 +1,64 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff-x", + "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test/vSAMP12", + "modelVersion": "1", + "modelInstanceName": "vSAMP12" + } + } + } + ], + "requestParameters": { + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + {"name": "vnfName", "value": "STMTN5MMSC20" }, + {"name": "vnfName2", "value": "US1117MTSNJVBR0246" }, + {"name": "vnfNmInformation", "value": "" }, + {"name": "vnfType", "value": "pcrf-capacity" }, + {"name": "vnfId", "value": "skask" }, + {"name": "vnfStackId", "value": "slowburn" }, + {"name": "vnfStatus", "value": "created" }, + {"name": "aicCloudRegion", "value": "MDTWNJ21" }, + {"name": "availabilityZone", "value": "slcp3-esx-az01" }, + {"name": "oamNetworkName", "value": "VLAN-OAM-1323" }, + {"name": "vmName", "value": "slcp34246vbc246ceb" }, + {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" }, + {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" } + ] + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml new file mode 100644 index 0000000000..8f8d150970 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml @@ -0,0 +1,38 @@ + + RDM2WAGPLCP + + 2f1cc940-455f-4ee2-9411-a7899cd4f124 + testVnfName123 + null + MSOTESTVOL102a-vSAMP12_base_vol_module-0 + + vnf1 + 1 + + + + + vnf_id + 2f1cc940-455f-4ee2-9411-a7899cd4f124 + + + vnf_name + testVnfName123 + + + vf_module_id + null + + + vf_module_name + MSOTESTVOL102a-vSAMP12_base_vol_module-0 + + + true + + 12345 + 12345 + + 12345-1513275871414 + http://localhost:28080/mso/WorkflowMessage/VNFAResponse/12345-1513275871414 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml new file mode 100644 index 0000000000..4087ab8f5f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml @@ -0,0 +1,29 @@ + + 6a1dc898-b590-47b9-bbf0-34424a7a2ec3 + MSOST10606-vSAMP12_MTN6_base_module-0 + MSOST10606-vSAMP12_MTN6_base_module-0/81b01583-690c-4ec3-9c58-0eafa7a90be7 + active + true + 1475077639 + ff5256d2-5a33-55df-13ab-12abad84e7ff + 1.0 + + + volume-group + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/volume-groups/volume-group/064bd1c6-e377-4009-a744-e958eec6e727/ + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mtn6 + + + volume-group.volume-group-id + 064bd1c6-e377-4009-a744-e958eec6e727 + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml new file mode 100644 index 0000000000..2be546162f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml @@ -0,0 +1,37 @@ + + + + 36e20198-c67a-464b-96d0-aaa99eb2639e + 5b9b15d0-5dd7-47dc-95b9-0440c340a3ba + 1.0 + BRGmodelname + 013bd784-9bca-4919-ae2f-ae57af27bad9 + + + parent-service-instance-id + consuming-service-instance-id + namefromrequest + brg + allottedresourceidfromrequest + + + fq-name + + d1 + drole + + vlan-tag + + s2 + srole + + txc-id + + 1 + 123 + a.b.c.d + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml new file mode 100644 index 0000000000..c2d197a2d8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml @@ -0,0 +1,24 @@ + + + + 36e20198-c67a-464b-96d0-aaa99eb2639e + 5b9b15d0-5dd7-47dc-95b9-0440c340a3ba + 1.0 + TXCmodelname + 013bd784-9bca-4919-ae2f-ae57af27bad9 + + + parent-service-instance-id + consuming-service-instance-id + namefromrequest + tunnelxconn + allottedresourceidfromrequest + + + my-vni + my-bearer-ip + my-lan-ip + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml new file mode 100644 index 0000000000..bb7f4c20fd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + TunnelXConn + TunnelXConn + TunnelXConn + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json new file mode 100644 index 0000000000..81fdcc76d0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json @@ -0,0 +1,127 @@ +{ "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" : "6ea0b528-e303-4686-aa77-aa2fcbdccb96", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "da86dd87-43c5-458c-b226-5315b7be9ad5", + "modelInstanceName" : "vHNF for DHV Test 17" + }, + "toscaNodeType" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null, + "vfModules": [ + { + "modelInfo" : { + "modelName" : "VhnfForDhvTest..base_TEST..module-0", + "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0a", + "modelInvariantUuid" : "f5696ec0-ec71-4916-bf3b-93a654efcba4", + "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" : "TunnelXConn", + "allottedResourceRole" : "TunnelXConn", + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null, + "homingSolution": { + "inventoryType": "service", + "serviceInstanceId": "MIS%252F1604%252F0027%252FSW_INTERNET", + "vnfHostname": "MDTNJ01", + "cloudOwner": "aic", + "cloudRegionId": "dfwtx", + "aicClli": "KDTNJ01", + "aicVersion": "3.0", + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ] + } + }, + { + "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" : "BRG", + "allottedResourceRole" : "BRG", + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null, + "homingSolution": { + "inventoryType": "service", + "serviceInstanceId": "MIS%252F1604%252F0027%252FSW_INTERNET", + "vnfHostname": "MDTNJ01", + "cloudOwner": "aic", + "cloudRegionId": "dfwtx", + "aicClli": "KDTNJ01", + "aicVersion": "3.0", + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ] + } + } + ] + }} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json new file mode 100644 index 0000000000..80692b27f5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json @@ -0,0 +1,11 @@ +{ "serviceResources" : { + "modelInfo" : { + "modelName" : "MSO Test Network", + "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", + "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", + "modelVersion" : null + }, + "serviceVnfs": [], + "serviceNetworks": [], + "serviceAllottedResources": [] + }} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml new file mode 100644 index 0000000000..b9d88d15db --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml @@ -0,0 +1,7 @@ + + SDN-ETHERNET-INTERNET + SDN-ETHERNET-INTERNET + 1490627351232 + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json new file mode 100644 index 0000000000..dc4669e8d9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json @@ -0,0 +1,40 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "instanceName":"VCPE1", + "source":"VID", + "suppressRollback":"false", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json new file mode 100644 index 0000000000..dc9ac49a4e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json @@ -0,0 +1,39 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "source":"VID", + "suppressRollback":"false", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json new file mode 100644 index 0000000000..d5b0713d9f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json @@ -0,0 +1,39 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "source":"VID", + "suppressRollback":"true", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml new file mode 100644 index 0000000000..3cb31464d5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml @@ -0,0 +1,31 @@ + + ar-brgB + Active + BRG + BRG + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml new file mode 100644 index 0000000000..65cee9f662 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml @@ -0,0 +1,31 @@ + + ar-txcA + Active + TunnelXConn + TunnelXConn + TunnelXConn + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml new file mode 100644 index 0000000000..932dbfb2ca --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml @@ -0,0 +1,6 @@ + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/ar-brgB + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml new file mode 100644 index 0000000000..e0511873b6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml @@ -0,0 +1,35 @@ + + + MIS/1604/0026/SW_INTERNET + 123456789 + + + generic-vnf + /aai/v7/generic-vnf/vnfX + + + l3-network + /aai/v7/l3-network/netA + + + generic-vnf + /aai/v7/generic-vnf/vnfY + + + l3-network + /aai/v7/l3-network/netB + + + l3-network + /aai/v7/l3-network/netC + + + allotted-resource + /aai/v11/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/ar-txcA + + + allotted-resource + /aai/v11/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/ar-brgB + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml new file mode 100644 index 0000000000..feb535c238 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml @@ -0,0 +1,8 @@ + + MIS/1604/0026/SW_INTERNET + SDN-MOBILITY + 123456789 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml new file mode 100644 index 0000000000..1c4f13d642 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml @@ -0,0 +1,6 @@ + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/ar-txcA + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json new file mode 100644 index 0000000000..dc4669e8d9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json @@ -0,0 +1,40 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "instanceName":"VCPE1", + "source":"VID", + "suppressRollback":"false", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml new file mode 100644 index 0000000000..8b8863e29c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml @@ -0,0 +1,36 @@ + + + + generic-vnf + /aai/v7/generic-vnf/vnfX + + + l3-network + /aai/v7/l3-network/netA + + + generic-vnf + /aai/v7/generic-vnf/vnfY/ + + + l3-network + /aai/v7/l3-network/netB + + + l3-network + /aai/v7/l3-network/netC + + + allotted-resource + /aai/v11/anytxc + + + allotted-resource + /aai/v11/anybrg + + + allotted-resource + /aai/v11/other + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..2be546162f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml @@ -0,0 +1,37 @@ + + + + 36e20198-c67a-464b-96d0-aaa99eb2639e + 5b9b15d0-5dd7-47dc-95b9-0440c340a3ba + 1.0 + BRGmodelname + 013bd784-9bca-4919-ae2f-ae57af27bad9 + + + parent-service-instance-id + consuming-service-instance-id + namefromrequest + brg + allottedresourceidfromrequest + + + fq-name + + d1 + drole + + vlan-tag + + s2 + srole + + txc-id + + 1 + 123 + a.b.c.d + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml new file mode 100644 index 0000000000..e352ff8f1f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml @@ -0,0 +1,8 @@ + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml new file mode 100644 index 0000000000..8c3976b828 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + BRGr + BRGt + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml new file mode 100644 index 0000000000..650d608fb0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + txc + BRG + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml new file mode 100644 index 0000000000..14c7410995 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml @@ -0,0 +1,38 @@ + + MIS/1604/0026/SW_INTERNET + 123456789 + + Active + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + + + cvlan-tag + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/ + + cvlan-tag.cvlan-tag + 2003 + + + port-group.interface-id + slcp1447vbc.ipag + + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + vce + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml new file mode 100644 index 0000000000..8ed991608a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + BRG + BRG + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml new file mode 100644 index 0000000000..713c5e7ad5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml @@ -0,0 +1,51 @@ + + + b043d290-140d-4a38-a9b6-95d3b8bd27d1 + MIS%252F1604%252F0026%252FSW_INTERNET + deactvate + brg-topology-operation + http://localhost:28090/mso/SDNCAdapterCallbackService + + + + RaaTestRequestId1 + DeleteBRGInstance + MSO + + + + + + + + + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + arId-1 + brg + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + + + + + + + ${sourceNetworkId} + ${sourceNetworkRole} + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml new file mode 100644 index 0000000000..df61910355 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml @@ -0,0 +1,51 @@ + + + b043d290-140d-4a38-a9b6-95d3b8bd27d3 + MIS%252F1604%252F0026%252FSW_INTERNET + unassign + brg-topology-operation + http://localhost:28090/mso/SDNCAdapterCallbackService + + + + RaaTestRequestId1 + DeleteBRGInstance + MSO + + + + + + + + + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + arId-1 + brg + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + + + + + + + ${sourceNetworkId} + ${sourceNetworkRole} + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml new file mode 100644 index 0000000000..35c783539c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml @@ -0,0 +1,51 @@ + + + b043d290-140d-4a38-a9b6-95d3b8bd27d2 + MIS%252F1604%252F0026%252FSW_INTERNET + delete + brg-topology-operation + http://localhost:28090/mso/SDNCAdapterCallbackService + + + + RaaTestRequestId1 + DeleteBRGInstance + MSO + + + + + + + + + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + arId-1 + brg + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + + + + + + + ${sourceNetworkId} + ${sourceNetworkRole} + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..c2d197a2d8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml @@ -0,0 +1,24 @@ + + + + 36e20198-c67a-464b-96d0-aaa99eb2639e + 5b9b15d0-5dd7-47dc-95b9-0440c340a3ba + 1.0 + TXCmodelname + 013bd784-9bca-4919-ae2f-ae57af27bad9 + + + parent-service-instance-id + consuming-service-instance-id + namefromrequest + tunnelxconn + allottedresourceidfromrequest + + + my-vni + my-bearer-ip + my-lan-ip + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml new file mode 100644 index 0000000000..e352ff8f1f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml @@ -0,0 +1,8 @@ + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml new file mode 100644 index 0000000000..dfb7d46a68 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + TXCr + TXCt + TXC + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml new file mode 100644 index 0000000000..59c503036a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + brg + TXC + TXC + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml new file mode 100644 index 0000000000..14c7410995 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml @@ -0,0 +1,38 @@ + + MIS/1604/0026/SW_INTERNET + 123456789 + + Active + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + + + cvlan-tag + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/ + + cvlan-tag.cvlan-tag + 2003 + + + port-group.interface-id + slcp1447vbc.ipag + + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + vce + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml new file mode 100644 index 0000000000..bb7f4c20fd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + TunnelXConn + TunnelXConn + TunnelXConn + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml new file mode 100644 index 0000000000..35630b79a8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml @@ -0,0 +1,51 @@ + + + b043d290-140d-4a38-a9b6-95d3b8bd27d1 + MIS%252F1604%252F0026%252FSW_INTERNET + deactvate + tunnelxconn-topology-operation + http://localhost:8080/mso/SDNCAdapterCallbackService + + + + RaaTestRequestId1 + DeleteTunnelXConnInstance + MSO + + + + + + + + + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + arId-1 + tunnelxconn + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + + + + + + + ${sourceNetworkId} + ${sourceNetworkRole} + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml new file mode 100644 index 0000000000..f6c9cc4626 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml @@ -0,0 +1,51 @@ + + + b043d290-140d-4a38-a9b6-95d3b8bd27d3 + MIS%252F1604%252F0026%252FSW_INTERNET + unassign + tunnelxconn-topology-operation + http://localhost:8080/mso/SDNCAdapterCallbackService + + + + RaaTestRequestId1 + DeleteTunnelXConnInstance + MSO + + + + + + + + + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + arId-1 + tunnelxconn + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + + + + + + + ${sourceNetworkId} + ${sourceNetworkRole} + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml new file mode 100644 index 0000000000..2a5597ca77 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml @@ -0,0 +1,51 @@ + + + b043d290-140d-4a38-a9b6-95d3b8bd27d2 + MIS%252F1604%252F0026%252FSW_INTERNET + delete + tunnelxconn-topology-operation + http://localhost:8080/mso/SDNCAdapterCallbackService + + + + RaaTestRequestId1 + DeleteTunnelXConnInstance + MSO + + + + + + + + + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + arId-1 + tunnelxconn + MIS%252F1604%252F0026%252FSW_INTERNET + + + + + + + + + + + ${sourceNetworkId} + ${sourceNetworkRole} + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml new file mode 100644 index 0000000000..8ed991608a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + BRG + BRG + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml new file mode 100644 index 0000000000..bb7f4c20fd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + TunnelXConn + TunnelXConn + TunnelXConn + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesData.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesData.json new file mode 100644 index 0000000000..d05fccf98a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesData.json @@ -0,0 +1,94 @@ +{ "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" : "6ea0b528-e303-4686-aa77-aa2fcbdccb96", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "da86dd87-43c5-458c-b226-5315b7be9ad5", + "modelInstanceName" : "vHNF for DHV Test 17" + }, + "toscaNodeType" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null, + "multiStageDesign" : null, + "vfModules": [ + { + "modelInfo" : { + "modelName" : "VhnfForDhvTest..base_TEST..module-0", + "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0a", + "modelInvariantUuid" : "f5696ec0-ec71-4916-bf3b-93a654efcba4", + "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/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json new file mode 100644 index 0000000000..b6e8a94888 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForReplaceVnfInfra.json @@ -0,0 +1,98 @@ +{ "serviceResources" : { + "serviceType" : "PortMirroring", + "serviceRole" : "InfraRole", + "environmentContext" : "Luna", + "workloadContext" : "Oxygen", + "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, + "multiStageDesign" : 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/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json new file mode 100644 index 0000000000..e1d3118537 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json @@ -0,0 +1,110 @@ +{ "serviceResources" : { + "serviceType" : "PortMirroring", + "serviceRole" : "InfraRole", + "environmentContext" : "Luna", + "workloadContext" : "Oxygen", + "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, + "multiStageDesign" : 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/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfData.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfData.json new file mode 100644 index 0000000000..c7938d1af6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfData.json @@ -0,0 +1,44 @@ +{"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, + "multiStageDesign" : 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 + } + ] + } + ] +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfNoTwoPhasedForVfModule.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfNoTwoPhasedForVfModule.json new file mode 100644 index 0000000000..3067d124c3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfNoTwoPhasedForVfModule.json @@ -0,0 +1,44 @@ +{"serviceVnfs": [ + { "modelInfo" : { + "modelName" : "vSAMP12", + "modelUuid" : "7097d8bb-f6ad-4cf7-866e-6a04c8f1b332", + "modelInvariantUuid" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "MODEL-123", + "modelInstanceName" : "VNF for VF Module Create Test Two Phased" + }, + "toscaNodeType" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : "vSCP", + "nfNamingCode" : null, + "multiStageDesign" : null, + "vfModules": [ + { + "modelInfo" : { + "modelName" : "STMTN5MMSC21-MMSC::model-1-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 + } + ] + } + ] +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfYesTwoPhasedForVfModule.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfYesTwoPhasedForVfModule.json new file mode 100644 index 0000000000..a9b3226483 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/getCatalogVnfYesTwoPhasedForVfModule.json @@ -0,0 +1,44 @@ +{"serviceVnfs": [ + { "modelInfo" : { + "modelName" : "vSAMP12", + "modelUuid" : "7097d8bb-f6ad-4cf7-866e-6a04c8f1b332", + "modelInvariantUuid" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersion" : "2.0", + "modelCustomizationUuid" : "MODEL-123", + "modelInstanceName" : "VNF for VF Module Create Test Two Phased" + }, + "toscaNodeType" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : "vSCP", + "nfNamingCode" : null, + "multiStageDesign" : "true", + "vfModules": [ + { + "modelInfo" : { + "modelName" : "STMTN5MMSC21-MMSC::model-1-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 + } + ] + } + ] +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VIPR/serviceDecompositionATMFW.json new file mode 100644 index 0000000000..bc54c557e1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..0688ea51e4 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + fqdn123 + slowburn + 145878989 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml new file mode 100644 index 0000000000..a421355aba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml @@ -0,0 +1,53 @@ + + + {{MESSAGE-ID}} + true + d485ecee-957c-4a0a-8b95-27a22b90103f + + + mmsc_vol_1 + a73e0fe9-1ce8-49c2-8fef-e2788605be29 + + + mmsc_vol_2 + 37b6455a-5ea8-463a-89e3-0efeaf7b7c6d + + + nemsfe_vol_1 + b7ff1c21-d138-49a3-bf13-4cfd91efaf48 + + + nemsbe_vol_1 + a5988471-cd42-44d8-b078-64f2f13d3d4c + + + mmsc_vol_5 + f7b91c1e-ab8c-413a-a850-ba80a246c7e0 + + + nemsfe_vol_2 + 957ea3f3-2d4a-4707-bfd2-ba66f42037c2 + + + mmsc_vol_3 + de6fccfe-d61a-48b0-b03b-87bf1bf749b3 + + + mmsc_vol_4 + 76162310-2c38-4c32-981c-5c2880190077 + + + + RDM2WAGPLCP + e585e4f4-9452-437a-b294-45a2d6d3b7a3 + + c30b9453-4b68-4c2e-aacf-58a5ba648bf5 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + 1bbab536a19b4756926e7d0ec1eb543c + true + 78987 + ZRDM1MMSC01_base_vol/7f74e5e1-5fc1-4593-ac7e-cc9899a106ef + + ZRDM1MMSC01_base_vol/7f74e5e1-5fc1-4593-ac7e-cc9899a106ef + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DBUpdateResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DBUpdateResponse.xml new file mode 100644 index 0000000000..0ae5b79484 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml new file mode 100644 index 0000000000..5232e530e9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml @@ -0,0 +1,29 @@ + + + DEV-VF-0011 + UPDATE_VF_MODULE + PORTAL + + + skask + supercool + pcrf-capacity + PCRF::module-0 + + serviceIdUUID + MDTWNJ21 + fba1bd1e195a404cacb9ce17a9b2b421 + 78987 + introvert + 3.14 + myhost.appl.edu + introvert + 3.14 + + + VLAN-OAM-1323 + slcp34246vbc246ceb + 970cd2b9-7f09-4a12-af47-182ea38ba1f0 + 545cc2c3-1930-4100-b534-5d82d0e12bb6 + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml new file mode 100644 index 0000000000..1c736453bc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml @@ -0,0 +1,51 @@ + + 12345678-f41f-4822-9323-b75962763d74 + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + pending-create + false + false + introvert + 2.0 + 0000020 + + + lukewarm + PCRF::module-0-0 + extrovert + 2.0 + true + fastburn + 2 + pending-create + 0000074 + + + supercool + PCRF::module-1-0 + extrovert + 2.0 + false + slowburn + 0 + pending-create + 0000075 + + + supercool + PCRF::module-1-0 + introvert + 2.0 + false + slowburn + 1 + pending-create + 0000075 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenericVnf.xml new file mode 100644 index 0000000000..ed96028908 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/GenericVnf.xml @@ -0,0 +1,38 @@ + + skask + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + pending-create + false + false + introvert + 2.0 + 0000020 + + + lukewarm + PCRF::module-0-0 + introvert + 2.0 + true + fastburn + pending-create + 0000074 + + + supercool + PCRF::module-1-0 + extrovert + 2.0 + false + slowburn + pending-create + 0000075 + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml new file mode 100644 index 0000000000..f3009e0f4c --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 195159195 + 14567890 + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml new file mode 100644 index 0000000000..d476b728bd --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml @@ -0,0 +1,11 @@ + + 094d311c-40bc-4ff1-9617-37c4226efcc3 + 200 + + Y + + 8462db9b-3e91-4e90-a2c8-6471313f87bf + restconf/config/GENERIC-RESOURCE-API:services/service/8462db9b-3e91-4e90-a2c8-6471313f87bf/service-data/service-topology/ + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml new file mode 100644 index 0000000000..4cab6c6615 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml new file mode 100644 index 0000000000..7512435415 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml new file mode 100644 index 0000000000..7d3d0e54d1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml new file mode 100644 index 0000000000..c1a03539cc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml new file mode 100644 index 0000000000..e43a1319ca --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml new file mode 100644 index 0000000000..d061cda9e0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml @@ -0,0 +1,8 @@ + + + skask + + 404 + {{REQUEST-ID}} + Y + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml new file mode 100644 index 0000000000..c1a03539cc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..0ee3f2827d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml @@ -0,0 +1,315 @@ + + + bd1b3789-6474-4935-94b2-90b656e035d0 + + bd1b3789-6474-4935-94b2-90b656e035d0 + + 9ddf628a-9eca-430e-8974-22d520a31be1 + assign + https://localhost:8443/adapters/rest/SDNCNotify + + + notsurewecare + bd1b3789-6474-4935-94b2-90b656e035d0 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + PendingCreate + + + VNN1CA52LCP + skask + afd0f02a-1ddb-43bb-aded-5113e46e82ae + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + 33d209df14ac4c08ad60747185d2f3e0 + bd1b3789-6474-4935-94b2-90b656e035d0 + ZVNN1MOGX01 - VF AUG 1::module-0 + + + + + mog_exn + 03dbd833-785c-40c0-bf32-37594b5334bc + MNS-25180-P-VNNYCA01_exn_protected_net_1 + + + 6f82d234-41a4-48e9-a9e8-415667a72929 + + filter1 + + + filter2 + + + + mog_oam + 3f181cde-9380-4c20-9d3a-e1a4ee74f994 + MNS-25180-P-VNNYCA01_oam_protected_net_1 + + + 713b6770-13fa-4949-8dbb-a1288c5e5932 + + + mog_cor_B + 821a550a-3f50-4725-995b-f212d5caec7c + MNS-25180-P-VNNYCA01_cor_direct_net_1 + + + 18926e56-12b6-4a4d-98b6-37e0c05626ee + + + mog_cor_A + 3dabf5c0-cffb-420c-8960-8499c74eb25f + MNS-25180-P-VNNYCA01_cor_direct_net_2 + + + 35530b29-a4de-48ff-a014-111110ccc652 + + + mog_gn + 3ce97321-6e7f-49af-bd12-f833e377c310 + MNS-25180-P-VNNYCA01_gn_direct_net_1 + + + 32bfdd2c-28e1-4895-87a6-373bf12c3129 + + + mog_dmz + d43ca910-02a5-47dc-8510-100a68a3c9e0 + MNS-25180-P-VNNYCA01_dmz_protected_net_1 + + + cb9500fb-943f-412e-aea6-458711564a75 + + + nova + + + ps + + ZVNN1MOGX01MPS001 + + + ZVNN1MOGX01MPS002 + + + ZVNN1MOGX01MPS003 + + + ZVNN1MOGX01MPS004 + + 4 + + mog_cor_B + + 107.224.36.251 + + + 107.224.36.252 + + + 107.224.36.253 + + + 107.224.36.254 + + N + + + + cm + + ZVNN1MOGX01MCM001 + + + ZVNN1MOGX01OAM002 + + 1 + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + N + + + mog_oam + + 107.239.167.250 + + + 107.239.167.251 + + N + + + + oam + + ZVNN1MOGX01OAM001 + + + ZVNN1MOGX01OAM002 + + 2 + + mog_oam + + 107.239.167.252 + + + 107.239.167.251 + + N + + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + N + + + + pd + + ZVNN1MOGX01MPD001 + + + ZVNN1MOGX01MPD002 + + 2 + + mog_dmz + + 107.225.25.253 + + + 107.225.25.254 + + N + 107.225.254.253 + + + mog_oam + + 107.239.167.254 + + + 107.239.167.253 + + N + 107.239.167.249 + + + mog_exn + + 107.224.46.253 + + + 107.224.46.254 + + N + 107.224.46.252 + + + mog_cor_B + + 107.224.36.247 + + + 107.224.36.248 + + N + 107.224.41.252 + + + mog_gn + + 107.224.41.253 + + + 107.224.41.254 + + N + 107.224.41.252 + + + mog_cor_A + + 107.224.38.253 + + + 107.224.38.254 + + N + + + + sm + + ZVNN1MOGX01MSM001 + + + ZVNN1MOGX01MSM002 + + + ZVNN1MOGX01MSM003 + + + ZVNN1MOGX01MSM004 + + 4 + + mog_cor_B + + 107.224.36.243 + + + 107.224.36.244 + + + 107.224.36.245 + + + 107.224.36.246 + + N + + + + + ZVNNMOGX01_base + SDN-MOBILITY + ZVNN1MOGX01 - VF AUG 1::module-0 + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + + + + 9ddf628a-9eca-430e-8974-22d520a31be1 + + PORTAL + VNFActivateRequest + + + + 200 + Y + synccomplete + 2016-08-05T16:15:19.398Z + vnf-topology-operation + VNFActivateRequest + assign + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml new file mode 100644 index 0000000000..677ecb7444 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml @@ -0,0 +1,141 @@ + + + 28455973-1ee5-4ad1-8d35-c4732679743a + + 200 + Y + synccomplete + 2016-06-08T19:44:59.138Z + vnf-topology-operation + VNFActivateRequest + assign + + + 28455973-1ee5-4ad1-8d35-c4732679743 + + notsurewecare + 28455973-1ee5-4ad1-8d35-c4732679743a + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + 5e168556-a5c6-4813-bff3-cc03007afbbc + http://localhost:8080/adapters/rest/SDNCNotify + assign + + + AAIAIC25 + MSOTEST06-vSAMP3::base::module-0 + 91ad7ab0-9ffd-471d-971c-3eb913a2cc75 + Test/vSAMP3 1 + MSOTEST06 + 4ae1d3446a4c48b2bec44b6cfba06d68 + 28455973-1ee5-4ad1-8d35-c4732679743a + vSAMP3::base::module-0 + + + PendingCreate + + + + image + Ubuntu_Perf + + + flavor + m1.small + + + + int_imbl + 680b7453-0ec4-4d96-b355-280d981d418f + Nimbus-25193-T-Willows2_int_imbl_net_1 + default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_int_imbl_net_1 + + 775607fb-e16a-45ef-94a7-82fba0d16eec + 640d07fb-e16a-45ef-94a7-82fba0d169bf + + filter1 + + + filter2 + + + + sgi_protected + f9039ce9-e3cf-4716-b2d1-ec7912178ea4 + Nimbus-25193-T-Willows2_sgi_protected_net_1 + default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_sgi_protected_net_1 + b9999ce9-e3cf-4716-b2d1-ec791217678c + + bf11bba8-b971-4ab5-8281-215b3fedcd3c + + + cm + + ZVNN1MOGX01MCM001 + + + ZVNN1MOGX01OAM002 + + 1 + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + + 2606:ae00:2e01:800::67 + + N + 107.224.41.252 + 2001:1890:1001:2B32::29:C + + + mog_oam + + 107.239.167.250 + + + 107.239.167.251 + + + aa::aa::aa::aa::aa::aa + + + bb::bb::bb::bb::bb::bb + + + 1.2.3.4/26 + + + 2002::/64 + + N + 1111:1890:1001:2B32::29:D + + + + nova + + + + MSOTEST06-vSAMP3::base::module-0 + SDN-MOBILITY + vSAMP3::base::module-0 + Test/vSAMP3 1 + MSOTEST06 + + + + 5e168556-a5c6-4813-bff3-cc03007afbbc + + SoapUI-bns-vf-base-vSAMP3-9001 + VNFActivateRequest + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml new file mode 100644 index 0000000000..c50c25671b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml new file mode 100644 index 0000000000..ba98ef8838 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/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/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml new file mode 100644 index 0000000000..c1a03539cc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml new file mode 100644 index 0000000000..77528ccf61 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml new file mode 100644 index 0000000000..49ecd0bf3f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml @@ -0,0 +1,55 @@ + + skask + supercool + slowburn + true + + + key1 + value1 + + + key2 + value2 + + +server1_private_ip +192.168.28.3 + + +contrail-service-instance-fqdn +default-domain:MSOTest:MsoNW-RA + + +policyKey1_contrail_network_policy_fqdn +MSOTest:DefaultPolicyFQDN1 + + +policyKey2_contrail_network_policy_fqdn +MSOTest:DefaultPolicyFQDN2 + + +oam_management_v6_address +2000:abc:bce:1111 + + +oam_management_v4_address +127.0.0.1 + + + + skask + supercool + slowburn + true + tenantId + cloudSiteId + + requestId + serviceInstanceId + + {{MESSAGE-ID}} + + {{MESSAGE-ID}} + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteRequest.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteRequest.xml new file mode 100644 index 0000000000..61aeaa7d66 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteRequest.xml @@ -0,0 +1,15 @@ + + testMessageId + true + testNotificationUrl + testAicCloudRegion} + testTenantId + testVnfId + testVfModuleId + testVfModuleStackId + + testRequestId + testServiceInstanceId + false + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteResponse.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteResponse.xml new file mode 100644 index 0000000000..b5b61192f7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestDeleteResponse.xml @@ -0,0 +1,56 @@ + + testMessageId + true + testVfModuleId + + + key1 + value1 + + + key2 + value2 + + + server1_private_ip + 192.168.28.3 + + + contrail-service-instance-fqdn + default-domain:MSOTest:MsoNW-RA + + + policyKey1_contrail_network_policy_fqdn + MSOTest:DefaultPolicyFQDN1 + + + policyKey2_contrail_network_policy_fqdn + MSOTest:DefaultPolicyFQDN2 + + + oam_management_v6_address + 2000:abc:bce:1111 + + + oam_management_v4_address + 127.0.0.1 + + + internal_security_group + test_internal_security_group + + + int_internal_net_id + test_int_internal_net_id + + + dsx_server_group_id + test_dsx_server_group_id + + + mcas_host_key + test_mcas_host_key + + + testVnfId + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml new file mode 100644 index 0000000000..c602dd9667 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml @@ -0,0 +1,16 @@ + + skask + supercool + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml new file mode 100644 index 0000000000..830d2e2237 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml @@ -0,0 +1,15 @@ + + 78987 + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml new file mode 100644 index 0000000000..ba0b4e4609 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml @@ -0,0 +1,10 @@ + + lukewarm + PCRF::module-1 + slowburn + pending-create + true + 330-90 + introvert + 2.0 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new-PendingActivation.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new-PendingActivation.xml new file mode 100644 index 0000000000..2ccba7d056 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new-PendingActivation.xml @@ -0,0 +1,9 @@ + + b37d96db-7d2c-47ce-bf61-a6c7b82fe161 + PCRF::module-0-2 + 00000000-0000-0000-0000-000000000000 + 1.0 + false + PendingActivation + 330-90 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new.xml new file mode 100644 index 0000000000..481410c3f6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-new.xml @@ -0,0 +1,9 @@ + + b37d96db-7d2c-47ce-bf61-a6c7b82fe161 + PCRF::module-0-2 + 00000000-0000-0000-0000-000000000000 + 1.0 + false + pending-create + 330-90 + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-supercool.xml new file mode 100644 index 0000000000..49513f1eac --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -0,0 +1,27 @@ + + supercool + PCRF::module-2 + fastburn + pending-create + false + 330-89 + introvert + 2.0 + + + volume-group + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + pdk1 + + + volume-group.volume-group-id + 78987 + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VolumeGroup.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VolumeGroup.xml new file mode 100644 index 0000000000..df84706ec5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VfModularity/VolumeGroup.xml @@ -0,0 +1,25 @@ + + 78987 + Volume_2 + slowburn + pcrf-capacity + Active + 0000020 + + + tenant + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + MDTWNJ21 + + + tenant.tenant-id + fba1bd1e195a404cacb9ce17a9b2b421 + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/deleteNetworkResponse_Success.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/deleteNetworkResponse_Success.xml new file mode 100644 index 0000000000..b8b8a4ff20 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/deleteNetworkResponse_Success.xml @@ -0,0 +1,3 @@ + + true + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/requestDetails.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/requestDetails.json new file mode 100644 index 0000000000..76616e14a5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/requestDetails.json @@ -0,0 +1,37 @@ +{ + "requestDetails": { + "project": { + "projectName": "vSAMP12 Project" + }, + "owningEntity": { + "owningEntityId": "MSO-Test-OE", + "owningEntityName": "MSO-Test123" + }, + "modelInfo": { + "modelType": "service", + "modelInvariantUuid": "d214abcc-2083-11e7-93ae-92361f002671", + "modelUuid": "c4503baa-2083-11e7-93ae-92361f002671", + "modelName": "MSOTADevInfra_vSAMP12_Service", + "modelVersion": "1.0" + }, + "subscriberInfo": { + "globalSubscriberId": "MSO_1610_dev", + "subscriberName": "MSO_1610_dev" + }, + "requestInfo": { + "instanceName": "bensServiceInstance3", + "source": "VID", + "suppressRollback": "true", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": { + "subscriptionServiceType": "MSO-dev-service-type", + "aLaCarte": "false", + "userParams": [] + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/schema.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/schema.json new file mode 100644 index 0000000000..36b51e9575 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/schema.json @@ -0,0 +1,16 @@ +{ + "CreateServiceInstanceV3": { + "serviceInstance": { + "@class": "inventory.aai.onap.org.v12.ServiceInstance" + }, + "project": { + "@class": "inventory.aai.onap.org.v12.Project" + }, + "owningEntity": { + "@class": "inventory.aai.onap.org.v12.OwningEntity" + }, + "customer": { + "@class": "inventory.aai.onap.org.v12.Customer" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml new file mode 100644 index 0000000000..007615e569 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml @@ -0,0 +1,340 @@ +aai: + auth: 757A94191D685FD2092AC1490730A4FC + dme2: + timeout: '30000' + endpoint: https://localhost:8443 +camunda: + bpm: + admin-user: + id: admin + password: admin + database: + type: h2 + history-level: FULL + metrics: + enabled: false + db-reporter-activate: false +canopi: + auth: 757A94191D685FD2092AC1490730A4FC +csi: + aots: + addincidentmanagement: + endpoint: http://localhost:28090/AddIncidentManagementTicketRequest + networkstatus: + endpoint: http://localhost:28090/SendManagedNetworkStatusNotification +entitymanager: + packagesToScan: com + +mso: + correlation: + timeout: PT60S + logPath: logs + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + adapters: + completemsoprocess: + endpoint: http://localhost:30253/CompleteMsoProcess + db: + auth: 757A94191D685FD2092AC1490730A4FC + password: wLg4sjrAFUS8rfVfdvTXeQ== + endpoint: http://localhost:28090 + spring: + endpoint: http://localhost:28090 + network: + endpoint: http://localhost:30253/services/NetworkAdapter + rest: + endpoint: http://localhost:30253/services/rest/v1/networks + openecomp: + db: + endpoint: http://localhost:30257/services/RequestsDbAdapter + po: + auth: 757A94191D685FD2092AC1490730A4FC + password: 3141634BF7E070AA289CF2892C986C0B + sdnc: + endpoint: http://localhost:30254/adapters/SDNCAdapter + rest: + endpoint: http://localhost:30254/adapters/rest/v1/sdnc + timeout: PT60S + tenant: + endpoint: http://localhost:30253/services/TenantAdapter + vnf: + endpoint: http://localhost:30253/services/VnfAdapter + rest: + endpoint: http://localhost:30253/services/rest/v1/vnfs + volume-groups: + rest: + endpoint: http://localhost:30253/services/rest/v1/volume-groups + vnf-async: + endpoint: http://localhost:30253/services/VnfAdapterAsync + adiod: + vce: + service: + model: + invariant: + uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8 + version: '5.0' + bpmn: + process: + historyTimeToLive: '30' + callbackRetryAttempts: '5' + catalog: + db: + endpoint: http://localhost:30258/ecomp/mso/catalog + spring: + endpoint: http://localhost:30258 + csi: + pwd: 4EA237303511EFBBC37F17A351562131 + sendmanagednetworkstatusnotification: + applicationname: NetworkManagementEthernetOverFiber + version: '212' + usrname: mso + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + default: + adapter: + namespace: http://com.att.mso + gateway: + service: + model: + name: HNGWaaS for DHV Test + healthcheck: + log: + debug: 'false' + infra: + customer: + id: testCustIdInfra + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + oam: + network: + role: + gateway: HngwOamNetVto.OAM + portal: HnportalOamNetVto.OAM + po: + timeout: PT60S + portal: + service: + model: + name: HNPortalaaS for DHV Test + request: + db: + endpoint: http://localhost:28090/ + rollback: 'true' + sdnc: + firewall: + yang: + model: + version: '2015-05-15' + password: 3141634BF7E070AA289CF2892C986C0B + timeout: + firewall: + minutes: '20' + ucpe: + async: + hours: '120' + minutes: '5' + service: + agnostic: + sniro: + endpoint: /sniro/api/v2/placement + host: http://localhost:30253 + site-name: CamundaEngine + sniro: + auth: test:testpwd + callback: http://localhost:28090/adapters/rest/SDNCNotify + endpoint: http://localhost:28090/optimizationInstance/V1/create + policies: + dhv: + 2vvig: SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 + 4vvig: SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.VNFPolicy_vvigprimary2_v1,SNIRO.VNFPolicy_vvigsecondary2_v1,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 + timeout: PT30M + sriov: + network: + role: + gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1 + gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2 + portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1 + portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2 + workflow: + aai: + distribution: + delay: PT5S + CreateGenericVNFV1: + aai: + volume-group: + uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group + DHVCreateService: + aai: + customer: + uri: /aai/v9/business/customers/customer + createvce: + delay: + seconds: '1' + default: + aai: + version: '8' + cloud-region: + version: '9' + generic-vnf: + version: '9' + v11: + customer: + uri: /aai/v11/business/customers/customer + generic-query: + uri: /aai/v11/search/generic-query + generic-vnf: + uri: /aai/v11/network/generic-vnfs/generic-vnf + l3-network: + uri: /aai/v11/network/l3-networks/l3-network + network-policy: + uri: /aai/v11/network/network-policies/network-policy + nodes-query: + uri: /aai/v11/search/nodes-query + route-table-reference: + uri: /aai/v11/network/route-table-references/route-table-reference + tenant: + uri: /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant + vce: + uri: /aai/v11/network/vces/vce + vpn-binding: + uri: /aai/v11/network/vpn-bindings/vpn-binding + v8: + configuration: + uri: /aai/v11/network/configurations/configuration + customer: + uri: /aai/v8/business/customers/customer + generic-query: + uri: /aai/v8/search/generic-query + l3-network: + uri: /aai/v8/network/l3-networks/l3-network + network-policy: + uri: /aai/v8/network/network-policies/network-policy + nodes-query: + uri: /aai/v8/search/nodes-query + route-table-reference: + uri: /aai/v8/network/route-table-references/route-table-reference + tenant: + uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant + vce: + uri: /aai/v8/network/vces/vce + vpn-binding: + uri: /aai/v8/network/vpn-bindings/vpn-binding + v9: + cloud-region: + uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic + generic-vnf: + uri: /aai/v9/network/generic-vnfs/generic-vnf + retry: + attempts: '1' + deleteCinderVolumeV1: + aai: + volume-group: + uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group + global: + default: + aai: + namespace: http://org.openecomp.aai.inventory/ + l3ToHigherLayerAddBonding: + model: + invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc + name: WAN Bonding v0.1 + version: '0.1' + versionid: 52dbec20-47aa-42e4-936c-331d8e350d44 + message: + endpoint: http://localhost:30252/mso/WorkflowMessage + notification: + name: GenericNotificationServiceATT + sdncadapter: + callback: http://localhost:30254/mso/SDNCAdapterCallbackService + vnfadapter: + create: + callback: http://localhost:30253/mso/vnfAdapterNotify + delete: + callback: http://localhost:30253/mso/vnfAdapterNotify + query: + callback: http://localhost:30253/mso/vnfAdapterNotify + rollback: + callback: http://localhost:30253/mso/vnfAdapterNotify +policy: + auth: Basic dGVzdHBkcDphbHBoYTEyMw== + client: + auth: Basic bTAzNzQzOnBvbGljeVIwY2sk + endpoint: https://localhost:8081/pdp/api/ + environment: TEST +sdnc: + auth: Basic YWRtaW46YWRtaW4= + host: https://localhost:8443 + path: /restconf/operations/GENERIC-RESOURCE-API +sdno: + health-check: + dmaap: + password: eHQ1cUJrOUc + publisher: + topic: com.att.sdno.test-health-diagnostic-v02 + subscriber: + topic: com.att.sdno.test-health-diagnostic-v02 + username: testuser +sniro: + conductor: + host: http://localhost:30253 + uri: /release + manager: + host: http://localhost:30253 + uri: /sniro/api/placement/v2 + headers.auth: Basic dGVzdDp0ZXN0cHdk + headers.patchVersion: 1 + headers.minorVersion: 1 + headers.latestVersion: 2 +server: + port: 8080 + tomcat: + max-threads: 50 + # ssl: + # key-store: /app/msoClientKeyStore.jks + # key-store-password: mso4you + # key-store-type: JKS + # trust-store: /app/msoTrustStore.jks + # trust-store-password: mso_Domain2.0_4you +spring: + h2: + console: + enabled: true + path: /h2 + datasource: + url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: sa + driverClassName: org.h2.Driver + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPMN-Client +# Hibernate +hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + show_sql: false + +management: + security: + enabled: false + +security: + basic: + enabled: false + +appc: + client: + topic: + read: + name: APPC-TEST-AMDOCS2 + timeout: 360000 + write: APPC-TEST-AMDOCS1-IST + response: + timeout: 360000 + key: LSl8QKolmKcC0yJR + secret: lgjXraD1HutKxv8jEN6tVouu + service: ueb + poolMembers: localhost:3904,localhost:3904,localhost:3904 \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/applicationContext_forPnfTesting.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/applicationContext_forPnfTesting.xml new file mode 100644 index 0000000000..ebefee7b08 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/applicationContext_forPnfTesting.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/catalogDBClientProps.properties b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/catalogDBClientProps.properties new file mode 100644 index 0000000000..bca529f960 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/catalogDBClientProps.properties @@ -0,0 +1 @@ +catalog.db.endpoint= http://localhost: \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..38a2ef6ef5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml @@ -0,0 +1,44 @@ + + + + + + + %d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level + %logger{1024} - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/requestsDBClientProps.properties b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/requestsDBClientProps.properties new file mode 100644 index 0000000000..758a6edd97 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/requestsDBClientProps.properties @@ -0,0 +1 @@ +requests.db.endpoint= http://localhost: \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn new file mode 100644 index 0000000000..66f458425e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn @@ -0,0 +1,35 @@ + + + + + SequenceFlow_0tyavm9 + + + SequenceFlow_0tyavm9 + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg